2 # Create the export list for perl.
4 # Needed by WIN32 for creating perl.dll and by AIX for creating libperl.a
5 # when -Dusershrplib is in effect.
7 # reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
15 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
16 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
17 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
20 my @PLATFORM = qw(aix win32);
22 @PLATFORM{@PLATFORM} = ();
24 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
25 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
27 my $config_sh = "config.sh";
28 my $config_h = "config.h";
29 my $thrdvar_h = "thrdvar.h";
30 my $intrpvar_h = "intrpvar.h";
31 my $perlvars_h = "perlvars.h";
32 my $global_sym = "global.sym";
33 my $pp_sym = "pp.sym";
34 my $globvar_sym = "globvar.sym";
35 my $perlio_sym = "perlio.sym";
37 if ($PLATFORM eq 'aix') {
39 } elsif ($PLATFORM eq 'win32') {
40 $CCTYPE = "MSVC" unless defined $CCTYPE;
41 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym, $pp_sym, $globvar_sym) {
46 unless ($PLATFORM eq 'win32') {
47 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
50 if (/^(?:ccflags|optimize)='(.+)'$/) {
52 $define{$1} = 1 while /-D(\w+)/g;
58 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
61 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
62 $define{$1} = 1 if /^\s*#\s*define\s+(USE_THREADS)\b/;
63 $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
64 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
68 if ($PLATFORM eq 'win32') {
69 warn join(' ',keys %define)."\n";
70 if ($define{PERL_OBJECT}) {
71 print "LIBRARY PerlCore\n";
72 print "DESCRIPTION 'Perl interpreter'\n";
74 # output_symbol("perl_alloc");
75 output_symbol("perl_get_host_info");
76 output_symbol("perl_alloc_using");
77 # output_symbol("perl_construct");
78 # output_symbol("perl_destruct");
79 # output_symbol("perl_free");
80 # output_symbol("perl_parse");
81 # output_symbol("perl_run");
82 # output_symbol("RunPerl");
86 if ($CCTYPE ne 'GCC') {
87 print "LIBRARY Perl\n";
88 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
91 $define{'PERL_GLOBAL_STRUCT'} = 1;
92 $define{'MULTIPLICITY'} = 1;
96 } elsif ($PLATFORM eq 'aix') {
105 foreach my $symbol (@$list) {
112 foreach my $symbol (@$list) {
113 my $skipsym = $symbol;
115 if ($define{PERL_OBJECT}) {
116 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
118 emit_symbol($symbol) unless exists $skip{$skipsym};
122 if ($PLATFORM eq 'win32') {
147 Perl_init_thread_intern
167 } elsif ($PLATFORM eq 'aix') {
193 if ($define{'PERL_OBJECT'}) {
212 if ($define{'MYMALLOC'})
229 Perl_malloced_size)];
232 unless ($define{'USE_THREADS'})
254 Perl_new_struct_thread
255 Perl_per_thread_magicals
262 unless ($define{'USE_THREADS'} or $define{'PERL_IMPLICIT_CONTEXT'}
263 or $define{'PERL_OBJECT'})
271 Perl_warner_nocontext
272 Perl_newSVpvf_nocontext
273 Perl_sv_catpvf_nocontext
274 Perl_sv_setpvf_nocontext
275 Perl_sv_catpvf_mg_nocontext
276 Perl_sv_setpvf_mg_nocontext
280 unless ($define{'FAKE_THREADS'})
282 skip_symbols [qw(PL_curthr)];
288 my $proc = shift || sub { "PL_$_[2]" };
289 open(VARS,$file) || die "Cannot open $file: $!\n";
293 # All symbols have a Perl_ prefix because that's what embed.h
294 # sticks in front of them.
295 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
301 if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
303 my $thrd = readvar($thrdvar_h);
307 if ($define{'MULTIPLICITY'})
309 my $interp = readvar($intrpvar_h);
310 skip_symbols $interp;
313 if ($define{'PERL_GLOBAL_STRUCT'})
315 my $global = readvar($perlvars_h);
316 skip_symbols $global;
317 emit_symbols [qw(Perl_GetVars)];
318 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
321 unless ($define{'DEBUGGING'})
337 if ($PLATFORM eq 'win32' && $define{'HAVE_DES_FCRYPT'})
339 emit_symbols [qw(win32_crypt)];
342 # functions from *.sym files
344 my @syms = ($global_sym, $pp_sym, $globvar_sym);
346 if ($define{'USE_PERLIO'})
348 push @syms, $perlio_sym;
353 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
356 next if (!/^[A-Za-z]/);
357 # Functions have a Perl_ prefix
358 # Variables have a PL_ prefix
360 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
362 emit_symbol($symbol) unless exists $skip{$symbol};
369 if ($define{'PERL_OBJECT'}) {
370 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
371 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
376 unless ($define{'PERL_GLOBAL_STRUCT'}) {
377 my $glob = readvar($perlvars_h);
380 unless ($define{'MULTIPLICITY'}) {
381 my $glob = readvar($intrpvar_h);
385 unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'}) {
386 my $glob = readvar($thrdvar_h);
394 return if $symbol !~ /^[A-Za-z]/;
395 return if $symbol =~ /^\#/;
398 return if exists $skip{$symbol};
399 emit_symbol($symbol);
406 if ($PLATFORM eq 'win32') {
407 foreach my $symbol (qw(
498 win32_getprotobynumber
558 # Now all symbols should be defined because
559 # next we are going to output them.
561 foreach my $symbol (sort keys %export)
563 output_symbol($symbol);
569 $export{$symbol} = 1;
574 if ($PLATFORM eq 'win32') {
576 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
577 # XXX: binary compatibility between compilers is an exercise
579 # if ($CCTYPE eq "BORLAND") {
580 # # workaround Borland quirk by exporting both the straight
581 # # name and a name with leading underscore. Note the
582 # # alias *must* come after the symbol itself, if both
583 # # are to be exported. (Linker bug?)
584 # print "\t_$symbol\n";
585 # print "\t$symbol = _$symbol\n";
587 # elsif ($CCTYPE eq 'GCC') {
588 # # Symbols have leading _ whole process is $%@"% slow
589 # # so skip aliases for now
590 # nprint "\t$symbol\n";
593 # # for binary coexistence, export both the symbol and
594 # # alias with leading underscore
595 # print "\t$symbol\n";
596 # print "\t_$symbol = $symbol\n";
598 } elsif ($PLATFORM eq 'aix') {
605 # extra globals not included above.