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' or $PLATFORM eq 'wince' or $PLATFORM eq "aix") {
40 # Add the compile-time options that miniperl was built with to %define.
41 # On Win32 these are not the same options as perl itself will be built
42 # with since miniperl is built with a canned config (one of the win32/
43 # config_H.*) and none of the BUILDOPT's that are set in the makefiles,
44 # but they do include some #define's that are hard-coded in various
45 # source files and header files and don't include any BUILDOPT's that
46 # the user might have chosen to disable because the canned configs are
47 # minimal configs that don't include any of those options.
48 my $opts = ($PLATFORM eq 'wince' ? '-MCross' : ''); # for wince need Cross.pm to get Config.pm
49 my $config = `$^X $opts -Ilib -V`;
50 my($options) = $config =~ /^ Compile-time options: (.*?)\n^ \S/ms;
51 $options =~ s/\s+/ /g;
52 print STDERR "Options: ($options)\n";
53 foreach (split /\s+/, $options) {
58 my %exportperlmalloc =
60 Perl_malloc => "malloc",
62 Perl_realloc => "realloc",
63 Perl_calloc => "calloc",
66 my $exportperlmalloc = $PLATFORM eq 'os2';
68 my $config_sh = "config.sh";
69 my $config_h = "config.h";
70 my $thrdvar_h = "thrdvar.h";
71 my $intrpvar_h = "intrpvar.h";
72 my $perlvars_h = "perlvars.h";
73 my $global_sym = "global.sym";
74 my $pp_sym = "pp.sym";
75 my $globvar_sym = "globvar.sym";
76 my $perlio_sym = "perlio.sym";
79 if ($PLATFORM eq 'aix') {
82 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
83 $CCTYPE = "MSVC" unless defined $CCTYPE;
84 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
85 $pp_sym, $globvar_sym, $perlio_sym) {
89 elsif ($PLATFORM eq 'MacOS') {
90 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
91 $pp_sym, $globvar_sym, $perlio_sym) {
96 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
97 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
99 if (/^(?:ccflags|optimize)='(.+)'$/) {
101 $define{$1} = 1 while /-D(\w+)/g;
103 if (/^(d_(?:mmap|sigaction))='(.+)'$/) {
106 if ($PLATFORM eq 'os2') {
107 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
108 $ARCHNAME = $1 if /^archname='(.+)'$/;
109 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
114 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
115 open(CFG,"<..\\$config_sh") || die "Cannot open ..\\$config_sh: $!\n";
116 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
122 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
124 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
125 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
126 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
127 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
131 # perl.h logic duplication begins
133 if ($define{PERL_IMPLICIT_SYS}) {
134 $define{PL_OP_SLAB_ALLOC} = 1;
137 if ($define{USE_ITHREADS}) {
138 if (!$define{MULTIPLICITY}) {
139 $define{MULTIPLICITY} = 1;
143 $define{PERL_IMPLICIT_CONTEXT} ||=
144 $define{USE_ITHREADS} ||
145 $define{MULTIPLICITY} ;
147 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
148 $define{USE_REENTRANT_API} = 1;
151 # perl.h logic duplication ends
155 print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n";
157 if ($PLATFORM =~ /^win(?:32|ce)$/) {
158 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
159 print "LIBRARY $dll\n";
160 print "DESCRIPTION 'Perl interpreter'\n";
162 if ($define{PERL_IMPLICIT_SYS}) {
163 output_symbol("perl_get_host_info");
164 output_symbol("perl_alloc_override");
166 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
167 output_symbol("perl_clone_host");
170 elsif ($PLATFORM eq 'os2') {
171 if (open my $fh, '<', 'perl5.def') {
173 last if /^\s*EXPORTS\b/;
176 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
177 # This allows skipping ordinals which were used in older versions
178 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
180 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
182 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
183 $v .= '-thread' if $ARCHNAME =~ /-thread/;
184 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
185 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
186 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
187 $d = substr($d, 0, 249) . "...'" if length $d > 253;
189 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
193 DATA LOADONCALL NONSHARED MULTIPLE
197 elsif ($PLATFORM eq 'aix') {
202 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
208 elsif ($PLATFORM eq 'netware') {
209 if ($FILETYPE eq 'def') {
210 print "LIBRARY perl59\n";
211 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
214 if ($define{PERL_IMPLICIT_SYS}) {
215 output_symbol("perl_get_host_info");
216 output_symbol("perl_alloc_override");
217 output_symbol("perl_clone_host");
226 foreach my $symbol (@$list) {
233 foreach my $symbol (@$list) {
234 my $skipsym = $symbol;
236 if ($define{MULTIPLICITY}) {
237 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
239 emit_symbol($symbol) unless exists $skip{$skipsym};
243 if ($PLATFORM eq 'win32') {
267 Perl_init_thread_intern
301 if ($PLATFORM eq 'wince') {
316 PL_collation_standard
344 Perl_init_thread_intern
371 elsif ($PLATFORM eq 'aix') {
390 Perl_sys_intern_clear
400 elsif ($PLATFORM eq 'os2') {
445 XS_Cwd_extLibpath_set
449 XS_Cwd_sys_is_absolute
450 XS_Cwd_sys_is_relative
452 XS_DynaLoader_mod2fname
453 XS_File__Copy_syscopy
457 Perl_Process_Messages
468 emit_symbols([qw(os2_cond_wait
473 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
475 elsif ($PLATFORM eq 'MacOS') {
499 Perl_sys_intern_clear
503 elsif ($PLATFORM eq 'netware') {
527 Perl_init_thread_intern
552 Perl_sys_intern_clear
560 Perl_PerlIO_setlinebuf
561 Perl_PerlIO_set_ptrcnt
567 Perl_PerlIO_get_bufsiz
580 unless ($define{'DEBUGGING'}) {
597 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
603 if ($define{'PERL_IMPLICIT_SYS'}) {
624 unless ($define{'PERL_OLD_COPY_ON_WRITE'}) {
631 unless ($define{'USE_REENTRANT_API'}) {
637 if ($define{'MYMALLOC'}) {
646 if ($define{'USE_ITHREADS'}) {
668 if ($define{'PERL_USE_SAFE_PUTENV'}) {
674 unless ($define{'USE_ITHREADS'}) {
680 # USE_5005THREADS symbols. Kept as reference for easier removal
699 Perl_new_struct_thread
700 Perl_per_thread_magicals
708 unless ($define{'USE_ITHREADS'}) {
714 PL_sharedsv_space_mutex
739 Perl_sharedsv_thrcnt_dec
740 Perl_sharedsv_thrcnt_inc
742 Perl_stashpv_hvname_match
743 Perl_regdupe_internal
747 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
758 Perl_load_module_nocontext
761 Perl_warner_nocontext
762 Perl_newSVpvf_nocontext
763 Perl_sv_catpvf_nocontext
764 Perl_sv_setpvf_nocontext
765 Perl_sv_catpvf_mg_nocontext
766 Perl_sv_setpvf_mg_nocontext
772 unless ($define{'PERL_IMPLICIT_SYS'}) {
779 unless ($define{'FAKE_THREADS'}) {
780 skip_symbols [qw(PL_curthr)];
783 unless ($define{'PL_OP_SLAB_ALLOC'}) {
793 unless ($define{'THREADS_HAVE_PIDS'}) {
794 skip_symbols [qw(PL_ppid)];
797 unless ($define{'PERL_NEED_APPCTX'}) {
803 unless ($define{'PERL_NEED_TIMESBASE'}) {
809 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
814 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
819 if ($define{'SPRINTF_RETURNS_STRLEN'}) {
824 unless ($define{'PERL_USES_PL_PIDSTATUS'}) {
831 unless ($define{'PERL_TRACK_MEMPOOL'}) {
833 PL_memory_debug_header
837 if ($define{'PERL_MAD'}) {
863 Perl_xmldump_packsubs
877 unless ($define{'PERL_GLOBAL_STRUCT_PRIVATE'}) {
884 unless ($define{'d_mmap'}) {
890 if ($define{'d_sigaction'}) {
897 # VMS does its own thing for these symbols.
898 skip_symbols [qw(PL_sig_handlers_initted
905 my $proc = shift || sub { "PL_$_[2]" };
906 open(VARS,$file) || die "Cannot open $file: $!\n";
909 # All symbols have a Perl_ prefix because that's what embed.h
910 # sticks in front of them. The A?I?S?C? is strictly speaking
912 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
918 if ($define{'PERL_GLOBAL_STRUCT'}) {
919 my $global = readvar($perlvars_h);
920 skip_symbols $global;
921 emit_symbol('Perl_GetVars');
922 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
924 skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
927 # functions from *.sym files
929 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
931 # Symbols that are the public face of the PerlIO layers implementation
932 # These are in _addition to_ the public face of the abstraction
933 # and need to be exported to allow XS modules to implement layers
947 PerlIOBase_setlinebuf
984 Perl_PerlIO_context_layers
991 Perl_PerlIO_get_bufsiz
997 Perl_PerlIO_set_ptrcnt
998 Perl_PerlIO_setlinebuf
1006 if ($PLATFORM eq 'netware') {
1007 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
1010 if ($define{'USE_PERLIO'}) {
1011 # Export the symols that make up the PerlIO abstraction, regardless
1012 # of its implementation - read from a file
1013 push @syms, $perlio_sym;
1015 # This part is then dependent on how the abstraction is implemented
1016 if ($define{'USE_SFIO'}) {
1017 # Old legacy non-stdio "PerlIO"
1018 skip_symbols \@layer_syms;
1019 skip_symbols [qw(perlsio_binmode)];
1020 # SFIO defines most of the PerlIO routines as macros
1021 # So undo most of what $perlio_sym has just done - d'oh !
1022 # Perhaps it would be better to list the ones which do exist
1067 Perl_PerlIO_clearerr
1074 Perl_PerlIO_get_base
1075 Perl_PerlIO_get_bufsiz
1081 Perl_PerlIO_set_ptrcnt
1082 Perl_PerlIO_setlinebuf
1095 # PerlIO with layers - export implementation
1096 emit_symbols \@layer_syms;
1097 emit_symbols [qw(perlsio_binmode)];
1099 if ($define{'USE_ITHREADS'}) {
1111 # Skip the PerlIO layer symbols - although
1112 # nothing should have exported them anyway.
1113 skip_symbols \@layer_syms;
1121 PL_perlio_fd_refcnt_size
1124 # Also do NOT add abstraction symbols from $perlio_sym
1125 # abstraction is done as #define to stdio
1126 # Remaining remnants that _may_ be functions
1127 # are handled in <DATA>
1130 for my $syms (@syms) {
1131 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1133 next if (!/^[A-Za-z]/);
1134 # Functions have a Perl_ prefix
1135 # Variables have a PL_ prefix
1137 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1139 emit_symbol($symbol) unless exists $skip{$symbol};
1146 if ($define{'MULTIPLICITY'}) {
1147 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
1148 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1151 # XXX AIX seems to want the perlvars.h symbols, for some reason
1152 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1153 my $glob = readvar($perlvars_h);
1158 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1159 my $glob = readvar($perlvars_h);
1162 unless ($define{'MULTIPLICITY'}) {
1163 my $glob = readvar($intrpvar_h);
1166 unless ($define{'MULTIPLICITY'}) {
1167 my $glob = readvar($thrdvar_h);
1175 return if $symbol !~ /^[A-Za-z_]/;
1176 return if $symbol =~ /^\#/;
1179 return if exists $skip{$symbol};
1180 emit_symbol($symbol);
1187 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1188 foreach my $symbol (qw(
1250 win32_getprotobyname
1251 win32_getprotobynumber
1280 win32_open_osfhandle
1351 try_symbol($symbol);
1353 if ($CCTYPE eq "BORLAND") {
1354 try_symbol('_matherr');
1357 elsif ($PLATFORM eq 'os2') {
1358 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1359 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1360 close MAP or die 'Cannot close miniperl.map';
1362 @missing = grep { !exists $mapped{$_} }
1364 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1365 delete $export{$_} foreach @missing;
1367 elsif ($PLATFORM eq 'MacOS') {
1368 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1376 elsif ($PLATFORM eq 'netware') {
1377 foreach my $symbol (qw(
1504 fnInsertHashListAddrs
1515 try_symbol($symbol);
1519 # records of type boot_module for statically linked modules (except Dynaloader)
1520 $static_ext =~ s/\//__/g;
1521 $static_ext =~ s/\bDynaLoader\b//;
1522 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1523 foreach my $symbol (@stat_mods)
1525 try_symbol($symbol);
1528 # Now all symbols should be defined because
1529 # next we are going to output them.
1531 foreach my $symbol (sort keys %export) {
1532 output_symbol($symbol);
1535 if ($PLATFORM eq 'os2') {
1540 Perl_OS2_handler_install
1542 ; LAST_ORDINAL=$sym_ord
1549 $export{$symbol} = 1;
1554 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1555 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1556 print "\t$symbol\n";
1557 # XXX: binary compatibility between compilers is an exercise
1558 # in frustration :-(
1559 # if ($CCTYPE eq "BORLAND") {
1560 # # workaround Borland quirk by exporting both the straight
1561 # # name and a name with leading underscore. Note the
1562 # # alias *must* come after the symbol itself, if both
1563 # # are to be exported. (Linker bug?)
1564 # print "\t_$symbol\n";
1565 # print "\t$symbol = _$symbol\n";
1567 # elsif ($CCTYPE eq 'GCC') {
1568 # # Symbols have leading _ whole process is $%@"% slow
1569 # # so skip aliases for now
1570 # nprint "\t$symbol\n";
1573 # # for binary coexistence, export both the symbol and
1574 # # alias with leading underscore
1575 # print "\t$symbol\n";
1576 # print "\t_$symbol = $symbol\n";
1579 elsif ($PLATFORM eq 'os2') {
1580 printf qq( %-31s \@%s\n),
1581 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1582 printf qq( %-31s \@%s\n),
1583 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1584 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1585 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1587 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1590 elsif ($PLATFORM eq 'netware') {
1591 print "\t$symbol,\n";
1597 # Oddities from PerlIO