2 # Create the export list for perl.
4 # Needed by WIN32 and OS/2 for creating perl.dll
5 # and by AIX for creating libperl.a when -Dusershrplib is in effect.
7 # reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
8 # On OS/2 reads miniperl.map as well
16 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
17 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
18 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
19 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
22 my @PLATFORM = qw(aix win32 os2);
24 @PLATFORM{@PLATFORM} = ();
26 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
27 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
29 my $config_sh = "config.sh";
30 my $config_h = "config.h";
31 my $thrdvar_h = "thrdvar.h";
32 my $intrpvar_h = "intrpvar.h";
33 my $perlvars_h = "perlvars.h";
34 my $global_sym = "global.sym";
35 my $pp_sym = "pp.sym";
36 my $globvar_sym = "globvar.sym";
37 my $perlio_sym = "perlio.sym";
39 if ($PLATFORM eq 'aix') {
41 } elsif ($PLATFORM eq 'win32') {
42 $CCTYPE = "MSVC" unless defined $CCTYPE;
43 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym, $pp_sym, $globvar_sym) {
48 unless ($PLATFORM eq 'win32') {
49 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
52 if (/^(?:ccflags|optimize)='(.+)'$/) {
54 $define{$1} = 1 while /-D(\w+)/g;
56 if ($PLATFORM eq 'os2') {
57 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
58 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
64 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
67 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
68 $define{$1} = 1 if /^\s*#\s*define\s+(USE_THREADS)\b/;
69 $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
70 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
74 if ($PLATFORM eq 'win32') {
75 warn join(' ',keys %define)."\n";
76 if ($define{PERL_OBJECT}) {
77 print "LIBRARY Perl56\n";
78 print "DESCRIPTION 'Perl interpreter'\n";
80 # output_symbol("perl_alloc");
81 output_symbol("perl_get_host_info");
82 output_symbol("perl_alloc_using");
83 # output_symbol("perl_construct");
84 # output_symbol("perl_destruct");
85 # output_symbol("perl_free");
86 # output_symbol("perl_parse");
87 # output_symbol("perl_run");
88 # output_symbol("RunPerl");
92 if ($CCTYPE ne 'GCC') {
93 print "LIBRARY Perl\n";
94 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
97 $define{'PERL_GLOBAL_STRUCT'} = 1;
98 $define{'MULTIPLICITY'} = 1;
102 } elsif ($PLATFORM eq 'os2') {
103 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
104 $v .= '-thread' if $ARCHNAME =~ /-thread/;
106 #for (split //, $v) {
107 # $sum = ($sum * 33) + ord;
112 #$sum = printf '%X', $sum;
113 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
114 # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
116 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
117 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'
120 DATA LOADONCALL NONSHARED MULTIPLE
123 } elsif ($PLATFORM eq 'aix') {
132 foreach my $symbol (@$list) {
139 foreach my $symbol (@$list) {
140 my $skipsym = $symbol;
142 if ($define{PERL_OBJECT}) {
143 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
145 emit_symbol($symbol) unless exists $skip{$skipsym};
149 if ($PLATFORM eq 'win32') {
174 Perl_init_thread_intern
194 } elsif ($PLATFORM eq 'aix') {
220 if ($PLATFORM eq 'os2') {
243 XS_Cwd_extLibpath_set
247 XS_Cwd_sys_is_absolute
248 XS_Cwd_sys_is_relative
250 XS_DynaLoader_mod2fname
251 XS_File__Copy_syscopy
255 Perl_Process_Messages
262 if ($define{'PERL_OBJECT'}) {
281 if ($define{'MYMALLOC'})
298 Perl_malloced_size)];
301 unless ($define{'USE_THREADS'})
323 Perl_new_struct_thread
324 Perl_per_thread_magicals
331 unless ($define{'USE_THREADS'} or $define{'PERL_IMPLICIT_CONTEXT'}
332 or $define{'PERL_OBJECT'})
340 Perl_warner_nocontext
341 Perl_newSVpvf_nocontext
342 Perl_sv_catpvf_nocontext
343 Perl_sv_setpvf_nocontext
344 Perl_sv_catpvf_mg_nocontext
345 Perl_sv_setpvf_mg_nocontext
349 unless ($define{'FAKE_THREADS'})
351 skip_symbols [qw(PL_curthr)];
357 my $proc = shift || sub { "PL_$_[2]" };
358 open(VARS,$file) || die "Cannot open $file: $!\n";
362 # All symbols have a Perl_ prefix because that's what embed.h
363 # sticks in front of them.
364 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
370 if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
372 my $thrd = readvar($thrdvar_h);
376 if ($define{'MULTIPLICITY'})
378 my $interp = readvar($intrpvar_h);
379 skip_symbols $interp;
382 if ($define{'PERL_GLOBAL_STRUCT'})
384 my $global = readvar($perlvars_h);
385 skip_symbols $global;
386 emit_symbols [qw(Perl_GetVars)];
387 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
390 unless ($define{'DEBUGGING'})
406 if ($PLATFORM eq 'win32' && $define{'HAVE_DES_FCRYPT'})
408 emit_symbols [qw(win32_crypt)];
411 # functions from *.sym files
413 my @syms = ($global_sym, $pp_sym, $globvar_sym);
415 if ($define{'USE_PERLIO'})
417 push @syms, $perlio_sym;
422 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
425 next if (!/^[A-Za-z]/);
426 # Functions have a Perl_ prefix
427 # Variables have a PL_ prefix
429 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
431 emit_symbol($symbol) unless exists $skip{$symbol};
438 if ($define{'PERL_OBJECT'}) {
439 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
440 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
445 unless ($define{'PERL_GLOBAL_STRUCT'}) {
446 my $glob = readvar($perlvars_h);
449 unless ($define{'MULTIPLICITY'}) {
450 my $glob = readvar($intrpvar_h);
454 unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'}) {
455 my $glob = readvar($thrdvar_h);
463 return if $symbol !~ /^[A-Za-z]/;
464 return if $symbol =~ /^\#/;
467 return if exists $skip{$symbol};
468 emit_symbol($symbol);
475 if ($PLATFORM eq 'win32') {
476 foreach my $symbol (qw(
567 win32_getprotobynumber
626 elsif ($PLATFORM eq 'os2') {
627 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
628 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
629 close MAP or die 'Cannot close miniperl.map';
631 @missing = grep { !exists $mapped{$_} } keys %export;
632 delete $export{$_} foreach @missing;
635 # Now all symbols should be defined because
636 # next we are going to output them.
638 foreach my $symbol (sort keys %export)
640 output_symbol($symbol);
646 $export{$symbol} = 1;
651 if ($PLATFORM eq 'win32') {
652 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
654 # XXX: binary compatibility between compilers is an exercise
656 # if ($CCTYPE eq "BORLAND") {
657 # # workaround Borland quirk by exporting both the straight
658 # # name and a name with leading underscore. Note the
659 # # alias *must* come after the symbol itself, if both
660 # # are to be exported. (Linker bug?)
661 # print "\t_$symbol\n";
662 # print "\t$symbol = _$symbol\n";
664 # elsif ($CCTYPE eq 'GCC') {
665 # # Symbols have leading _ whole process is $%@"% slow
666 # # so skip aliases for now
667 # nprint "\t$symbol\n";
670 # # for binary coexistence, export both the symbol and
671 # # alias with leading underscore
672 # print "\t$symbol\n";
673 # print "\t_$symbol = $symbol\n";
675 } elsif ($PLATFORM eq 'os2') {
676 print qq( "$symbol"\n);
677 } elsif ($PLATFORM eq 'aix') {
684 # extra globals not included above.