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,
6 # and by MacOS Classic.
8 # reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
9 # On OS/2 reads miniperl.map and the previous version of perl5.def as well
16 if ($flag =~ s/^CC_FLAGS=/ /) {
17 for my $fflag ($flag =~ /(?:^|\s)-D(\S+)/g) {
18 $fflag .= '=1' unless $fflag =~ /^(\w+)=/;
19 $define{$1} = $2 if $fflag =~ /^(\w+)=(.+)$/;
23 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
24 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
25 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
26 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
27 if ($PLATFORM eq 'netware') {
28 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
32 my @PLATFORM = qw(aix win32 wince os2 MacOS netware);
34 @PLATFORM{@PLATFORM} = ();
36 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
37 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
39 if ($PLATFORM eq 'win32') {
40 # Add the compile-time options that miniperl was built with to %define.
41 # These are not the same options as perl itself will be built with since
42 # miniperl is built with a canned config (one of the win32/config_H.*)
43 # and none of the BUILDOPT's that are set in the makefiles, but they do
44 # include some #define's that are hard-coded in various source files and
45 # header files and don't include any BUILDOPT's that the user might have
46 # chosen to disable because the canned configs are minimal configs that
47 # don't include any of those options.
48 my $config = `$^X -V`;
49 my($options) = $config =~ /^ Compile-time options: (.*?)^ \S/ms;
50 foreach (split /\s+/, $options) {
55 my %exportperlmalloc =
57 Perl_malloc => "malloc",
59 Perl_realloc => "realloc",
60 Perl_calloc => "calloc",
63 my $exportperlmalloc = $PLATFORM eq 'os2';
65 my $config_sh = "config.sh";
66 my $config_h = "config.h";
67 my $thrdvar_h = "thrdvar.h";
68 my $intrpvar_h = "intrpvar.h";
69 my $perlvars_h = "perlvars.h";
70 my $global_sym = "global.sym";
71 my $pp_sym = "pp.sym";
72 my $globvar_sym = "globvar.sym";
73 my $perlio_sym = "perlio.sym";
76 if ($PLATFORM eq 'aix') {
79 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
80 $CCTYPE = "MSVC" unless defined $CCTYPE;
81 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
82 $pp_sym, $globvar_sym, $perlio_sym) {
86 elsif ($PLATFORM eq 'MacOS') {
87 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
88 $pp_sym, $globvar_sym, $perlio_sym) {
93 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
94 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
96 if (/^(?:ccflags|optimize)='(.+)'$/) {
98 $define{$1} = 1 while /-D(\w+)/g;
100 if (/^(d_(?:mmap|sigaction))='(.+)'$/) {
103 if ($PLATFORM eq 'os2') {
104 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
105 $ARCHNAME = $1 if /^archname='(.+)'$/;
106 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
111 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
112 open(CFG,"<..\\$config_sh") || die "Cannot open ..\\$config_sh: $!\n";
113 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
119 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
121 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
122 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
123 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
124 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
128 # perl.h logic duplication begins
130 if ($define{PERL_IMPLICIT_SYS}) {
131 $define{PL_OP_SLAB_ALLOC} = 1;
134 if ($define{USE_ITHREADS}) {
135 if (!$define{MULTIPLICITY}) {
136 $define{MULTIPLICITY} = 1;
140 $define{PERL_IMPLICIT_CONTEXT} ||=
141 $define{USE_ITHREADS} ||
142 $define{MULTIPLICITY} ;
144 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
145 $define{USE_REENTRANT_API} = 1;
148 # perl.h logic duplication ends
152 if ($PLATFORM =~ /^win(?:32|ce)$/) {
153 warn join(' ',keys %define)."\n";
154 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
155 print "LIBRARY $dll\n";
156 print "DESCRIPTION 'Perl interpreter'\n";
158 if ($define{PERL_IMPLICIT_SYS}) {
159 output_symbol("perl_get_host_info");
160 output_symbol("perl_alloc_override");
162 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
163 output_symbol("perl_clone_host");
166 elsif ($PLATFORM eq 'os2') {
167 if (open my $fh, '<', 'perl5.def') {
169 last if /^\s*EXPORTS\b/;
172 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
173 # This allows skipping ordinals which were used in older versions
174 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
176 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
178 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
179 $v .= '-thread' if $ARCHNAME =~ /-thread/;
180 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
181 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
182 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
183 $d = substr($d, 0, 249) . "...'" if length $d > 253;
185 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
189 DATA LOADONCALL NONSHARED MULTIPLE
193 elsif ($PLATFORM eq 'aix') {
198 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
204 elsif ($PLATFORM eq 'netware') {
205 if ($FILETYPE eq 'def') {
206 print "LIBRARY perl59\n";
207 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
210 if ($define{PERL_IMPLICIT_SYS}) {
211 output_symbol("perl_get_host_info");
212 output_symbol("perl_alloc_override");
213 output_symbol("perl_clone_host");
222 foreach my $symbol (@$list) {
229 foreach my $symbol (@$list) {
230 my $skipsym = $symbol;
232 if ($define{MULTIPLICITY}) {
233 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
235 emit_symbol($symbol) unless exists $skip{$skipsym};
239 if ($PLATFORM eq 'win32') {
264 Perl_init_thread_intern
297 if ($PLATFORM eq 'wince') {
313 PL_collation_standard
341 Perl_init_thread_intern
367 elsif ($PLATFORM eq 'aix') {
386 Perl_sys_intern_clear
395 elsif ($PLATFORM eq 'os2') {
440 XS_Cwd_extLibpath_set
444 XS_Cwd_sys_is_absolute
445 XS_Cwd_sys_is_relative
447 XS_DynaLoader_mod2fname
448 XS_File__Copy_syscopy
452 Perl_Process_Messages
463 emit_symbols([qw(os2_cond_wait
468 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
470 elsif ($PLATFORM eq 'MacOS') {
494 Perl_sys_intern_clear
498 elsif ($PLATFORM eq 'netware') {
523 Perl_init_thread_intern
548 Perl_sys_intern_clear
556 Perl_PerlIO_setlinebuf
557 Perl_PerlIO_set_ptrcnt
563 Perl_PerlIO_get_bufsiz
576 unless ($define{'DEBUGGING'}) {
591 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
597 if ($define{'PERL_IMPLICIT_SYS'}) {
618 unless ($define{'PERL_OLD_COPY_ON_WRITE'}) {
625 unless ($define{'USE_REENTRANT_API'}) {
631 if ($define{'MYMALLOC'}) {
640 if ($define{'USE_ITHREADS'}) {
662 unless ($define{'PERL_MALLOC_WRAP'}) {
668 unless ($define{'USE_ITHREADS'}) {
674 # USE_5005THREADS symbols. Kept as reference for easier removal
693 Perl_new_struct_thread
694 Perl_per_thread_magicals
702 unless ($define{'USE_ITHREADS'}) {
711 PL_sharedsv_space_mutex
741 Perl_sharedsv_thrcnt_dec
742 Perl_sharedsv_thrcnt_inc
744 Perl_stashpv_hvname_match
748 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
754 Perl_load_module_nocontext
757 Perl_warner_nocontext
758 Perl_newSVpvf_nocontext
759 Perl_sv_catpvf_nocontext
760 Perl_sv_setpvf_nocontext
761 Perl_sv_catpvf_mg_nocontext
762 Perl_sv_setpvf_mg_nocontext
766 unless ($define{'PERL_IMPLICIT_SYS'}) {
773 unless ($define{'FAKE_THREADS'}) {
774 skip_symbols [qw(PL_curthr)];
777 unless ($define{'PL_OP_SLAB_ALLOC'}) {
787 unless ($define{'THREADS_HAVE_PIDS'}) {
788 skip_symbols [qw(PL_ppid)];
791 unless ($define{'PERL_NEED_APPCTX'}) {
797 unless ($define{'PERL_NEED_TIMESBASE'}) {
803 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
808 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
814 unless ($define{'d_mmap'}) {
820 if ($define{'d_sigaction'}) {
827 # VMS does its own thing for these symbols.
828 skip_symbols [qw(PL_sig_handlers_initted
835 my $proc = shift || sub { "PL_$_[2]" };
836 open(VARS,$file) || die "Cannot open $file: $!\n";
839 # All symbols have a Perl_ prefix because that's what embed.h
840 # sticks in front of them. The A?I?S?C? is strictly speaking
842 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
848 if ($define{'PERL_GLOBAL_STRUCT'}) {
849 my $global = readvar($perlvars_h);
850 skip_symbols $global;
851 emit_symbol('Perl_GetVars');
852 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
854 skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
857 # functions from *.sym files
859 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
861 # Symbols that are the public face of the PerlIO layers implementation
862 # These are in _addition to_ the public face of the abstraction
863 # and need to be exported to allow XS modules to implement layers
877 PerlIOBase_setlinebuf
920 Perl_PerlIO_get_bufsiz
926 Perl_PerlIO_set_ptrcnt
927 Perl_PerlIO_setlinebuf
935 if ($PLATFORM eq 'netware') {
936 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
939 if ($define{'USE_PERLIO'}) {
940 # Export the symols that make up the PerlIO abstraction, regardless
941 # of its implementation - read from a file
942 push @syms, $perlio_sym;
944 # This part is then dependent on how the abstraction is implemented
945 if ($define{'USE_SFIO'}) {
946 # Old legacy non-stdio "PerlIO"
947 skip_symbols \@layer_syms;
948 skip_symbols [qw(perlsio_binmode)];
949 # SFIO defines most of the PerlIO routines as macros
950 # So undo most of what $perlio_sym has just done - d'oh !
951 # Perhaps it would be better to list the ones which do exist
1003 Perl_PerlIO_get_base
1004 Perl_PerlIO_get_bufsiz
1010 Perl_PerlIO_set_ptrcnt
1011 Perl_PerlIO_setlinebuf
1024 # PerlIO with layers - export implementation
1025 emit_symbols \@layer_syms;
1026 emit_symbols [qw(perlsio_binmode)];
1030 # Skip the PerlIO layer symbols - although
1031 # nothing should have exported them anyway.
1032 skip_symbols \@layer_syms;
1033 skip_symbols [qw(perlsio_binmode)];
1034 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
1036 # Also do NOT add abstraction symbols from $perlio_sym
1037 # abstraction is done as #define to stdio
1038 # Remaining remnants that _may_ be functions
1039 # are handled in <DATA>
1042 for my $syms (@syms) {
1043 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1045 next if (!/^[A-Za-z]/);
1046 # Functions have a Perl_ prefix
1047 # Variables have a PL_ prefix
1049 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1051 emit_symbol($symbol) unless exists $skip{$symbol};
1058 if ($define{'MULTIPLICITY'}) {
1059 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
1060 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1063 # XXX AIX seems to want the perlvars.h symbols, for some reason
1064 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1065 my $glob = readvar($perlvars_h);
1070 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1071 my $glob = readvar($perlvars_h);
1074 unless ($define{'MULTIPLICITY'}) {
1075 my $glob = readvar($intrpvar_h);
1078 unless ($define{'MULTIPLICITY'}) {
1079 my $glob = readvar($thrdvar_h);
1087 return if $symbol !~ /^[A-Za-z_]/;
1088 return if $symbol =~ /^\#/;
1091 return if exists $skip{$symbol};
1092 emit_symbol($symbol);
1099 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1100 foreach my $symbol (qw(
1162 win32_getprotobyname
1163 win32_getprotobynumber
1192 win32_open_osfhandle
1262 try_symbol($symbol);
1264 if ($CCTYPE eq "BORLAND") {
1265 try_symbol('_matherr');
1268 elsif ($PLATFORM eq 'os2') {
1269 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1270 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1271 close MAP or die 'Cannot close miniperl.map';
1273 @missing = grep { !exists $mapped{$_} }
1275 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1276 delete $export{$_} foreach @missing;
1278 elsif ($PLATFORM eq 'MacOS') {
1279 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1287 elsif ($PLATFORM eq 'netware') {
1288 foreach my $symbol (qw(
1415 fnInsertHashListAddrs
1426 try_symbol($symbol);
1430 # records of type boot_module for statically linked modules (except Dynaloader)
1431 $static_ext =~ s/\//__/g;
1432 $static_ext =~ s/\bDynaLoader\b//;
1433 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1434 foreach my $symbol (@stat_mods)
1436 try_symbol($symbol);
1439 # Now all symbols should be defined because
1440 # next we are going to output them.
1442 foreach my $symbol (sort keys %export) {
1443 output_symbol($symbol);
1446 if ($PLATFORM eq 'os2') {
1451 Perl_OS2_handler_install
1453 ; LAST_ORDINAL=$sym_ord
1460 $export{$symbol} = 1;
1465 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1466 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1467 print "\t$symbol\n";
1468 # XXX: binary compatibility between compilers is an exercise
1469 # in frustration :-(
1470 # if ($CCTYPE eq "BORLAND") {
1471 # # workaround Borland quirk by exporting both the straight
1472 # # name and a name with leading underscore. Note the
1473 # # alias *must* come after the symbol itself, if both
1474 # # are to be exported. (Linker bug?)
1475 # print "\t_$symbol\n";
1476 # print "\t$symbol = _$symbol\n";
1478 # elsif ($CCTYPE eq 'GCC') {
1479 # # Symbols have leading _ whole process is $%@"% slow
1480 # # so skip aliases for now
1481 # nprint "\t$symbol\n";
1484 # # for binary coexistence, export both the symbol and
1485 # # alias with leading underscore
1486 # print "\t$symbol\n";
1487 # print "\t_$symbol = $symbol\n";
1490 elsif ($PLATFORM eq 'os2') {
1491 printf qq( %-31s \@%s\n),
1492 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1493 printf qq( %-31s \@%s\n),
1494 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1495 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1496 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1498 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1501 elsif ($PLATFORM eq 'netware') {
1502 print "\t$symbol,\n";
1508 # extra globals not included above.
1519 # Oddities from PerlIO