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 "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 $config = `$^X -Ilib -V`;
49 my($options) = $config =~ /^ Compile-time options: (.*?)\n^ \S/ms;
50 $options =~ s/\s+/ /g;
51 print STDERR "Options: ($options)\n";
52 foreach (split /\s+/, $options) {
57 my %exportperlmalloc =
59 Perl_malloc => "malloc",
61 Perl_realloc => "realloc",
62 Perl_calloc => "calloc",
65 my $exportperlmalloc = $PLATFORM eq 'os2';
67 my $config_sh = "config.sh";
68 my $config_h = "config.h";
69 my $thrdvar_h = "thrdvar.h";
70 my $intrpvar_h = "intrpvar.h";
71 my $perlvars_h = "perlvars.h";
72 my $global_sym = "global.sym";
73 my $pp_sym = "pp.sym";
74 my $globvar_sym = "globvar.sym";
75 my $perlio_sym = "perlio.sym";
78 if ($PLATFORM eq 'aix') {
81 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
82 $CCTYPE = "MSVC" unless defined $CCTYPE;
83 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
84 $pp_sym, $globvar_sym, $perlio_sym) {
88 elsif ($PLATFORM eq 'MacOS') {
89 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
90 $pp_sym, $globvar_sym, $perlio_sym) {
95 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
96 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
98 if (/^(?:ccflags|optimize)='(.+)'$/) {
100 $define{$1} = 1 while /-D(\w+)/g;
102 if (/^(d_(?:mmap|sigaction))='(.+)'$/) {
105 if ($PLATFORM eq 'os2') {
106 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
107 $ARCHNAME = $1 if /^archname='(.+)'$/;
108 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
113 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
114 open(CFG,"<..\\$config_sh") || die "Cannot open ..\\$config_sh: $!\n";
115 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
121 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
123 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
124 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
125 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
126 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
130 # perl.h logic duplication begins
132 if ($define{PERL_IMPLICIT_SYS}) {
133 $define{PL_OP_SLAB_ALLOC} = 1;
136 if ($define{USE_ITHREADS}) {
137 if (!$define{MULTIPLICITY}) {
138 $define{MULTIPLICITY} = 1;
142 $define{PERL_IMPLICIT_CONTEXT} ||=
143 $define{USE_ITHREADS} ||
144 $define{MULTIPLICITY} ;
146 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
147 $define{USE_REENTRANT_API} = 1;
150 # perl.h logic duplication ends
154 print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n";
156 if ($PLATFORM =~ /^win(?:32|ce)$/) {
157 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
158 print "LIBRARY $dll\n";
159 print "DESCRIPTION 'Perl interpreter'\n";
161 if ($define{PERL_IMPLICIT_SYS}) {
162 output_symbol("perl_get_host_info");
163 output_symbol("perl_alloc_override");
165 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
166 output_symbol("perl_clone_host");
169 elsif ($PLATFORM eq 'os2') {
170 if (open my $fh, '<', 'perl5.def') {
172 last if /^\s*EXPORTS\b/;
175 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
176 # This allows skipping ordinals which were used in older versions
177 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
179 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
181 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
182 $v .= '-thread' if $ARCHNAME =~ /-thread/;
183 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
184 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
185 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
186 $d = substr($d, 0, 249) . "...'" if length $d > 253;
188 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
192 DATA LOADONCALL NONSHARED MULTIPLE
196 elsif ($PLATFORM eq 'aix') {
201 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
207 elsif ($PLATFORM eq 'netware') {
208 if ($FILETYPE eq 'def') {
209 print "LIBRARY perl59\n";
210 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
213 if ($define{PERL_IMPLICIT_SYS}) {
214 output_symbol("perl_get_host_info");
215 output_symbol("perl_alloc_override");
216 output_symbol("perl_clone_host");
225 foreach my $symbol (@$list) {
232 foreach my $symbol (@$list) {
233 my $skipsym = $symbol;
235 if ($define{MULTIPLICITY}) {
236 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
238 emit_symbol($symbol) unless exists $skip{$skipsym};
242 if ($PLATFORM eq 'win32') {
267 Perl_init_thread_intern
300 if ($PLATFORM eq 'wince') {
316 PL_collation_standard
344 Perl_init_thread_intern
370 elsif ($PLATFORM eq 'aix') {
389 Perl_sys_intern_clear
398 elsif ($PLATFORM eq 'os2') {
443 XS_Cwd_extLibpath_set
447 XS_Cwd_sys_is_absolute
448 XS_Cwd_sys_is_relative
450 XS_DynaLoader_mod2fname
451 XS_File__Copy_syscopy
455 Perl_Process_Messages
466 emit_symbols([qw(os2_cond_wait
471 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
473 elsif ($PLATFORM eq 'MacOS') {
497 Perl_sys_intern_clear
501 elsif ($PLATFORM eq 'netware') {
526 Perl_init_thread_intern
551 Perl_sys_intern_clear
559 Perl_PerlIO_setlinebuf
560 Perl_PerlIO_set_ptrcnt
566 Perl_PerlIO_get_bufsiz
579 unless ($define{'DEBUGGING'}) {
594 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
600 if ($define{'PERL_IMPLICIT_SYS'}) {
621 unless ($define{'PERL_OLD_COPY_ON_WRITE'}) {
628 unless ($define{'USE_REENTRANT_API'}) {
634 if ($define{'MYMALLOC'}) {
643 if ($define{'USE_ITHREADS'}) {
665 unless ($define{'PERL_MALLOC_WRAP'}) {
671 if ($define{'PERL_USE_SAFE_PUTENV'}) {
677 unless ($define{'USE_ITHREADS'}) {
683 # USE_5005THREADS symbols. Kept as reference for easier removal
702 Perl_new_struct_thread
703 Perl_per_thread_magicals
711 unless ($define{'USE_ITHREADS'}) {
720 PL_sharedsv_space_mutex
750 Perl_sharedsv_thrcnt_dec
751 Perl_sharedsv_thrcnt_inc
753 Perl_stashpv_hvname_match
757 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
763 Perl_load_module_nocontext
766 Perl_warner_nocontext
767 Perl_newSVpvf_nocontext
768 Perl_sv_catpvf_nocontext
769 Perl_sv_setpvf_nocontext
770 Perl_sv_catpvf_mg_nocontext
771 Perl_sv_setpvf_mg_nocontext
775 unless ($define{'PERL_IMPLICIT_SYS'}) {
782 unless ($define{'FAKE_THREADS'}) {
783 skip_symbols [qw(PL_curthr)];
786 unless ($define{'PL_OP_SLAB_ALLOC'}) {
796 unless ($define{'THREADS_HAVE_PIDS'}) {
797 skip_symbols [qw(PL_ppid)];
800 unless ($define{'PERL_NEED_APPCTX'}) {
806 unless ($define{'PERL_NEED_TIMESBASE'}) {
812 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
817 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
822 if ($define{'SPRINTF_RETURNS_STRLEN'}) {
827 unless ($define{'PERL_USES_PL_PIDSTATUS'}) {
834 unless ($define{'d_mmap'}) {
840 if ($define{'d_sigaction'}) {
847 # VMS does its own thing for these symbols.
848 skip_symbols [qw(PL_sig_handlers_initted
855 my $proc = shift || sub { "PL_$_[2]" };
856 open(VARS,$file) || die "Cannot open $file: $!\n";
859 # All symbols have a Perl_ prefix because that's what embed.h
860 # sticks in front of them. The A?I?S?C? is strictly speaking
862 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
868 if ($define{'PERL_GLOBAL_STRUCT'}) {
869 my $global = readvar($perlvars_h);
870 skip_symbols $global;
871 emit_symbol('Perl_GetVars');
872 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
874 skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
877 # functions from *.sym files
879 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
881 # Symbols that are the public face of the PerlIO layers implementation
882 # These are in _addition to_ the public face of the abstraction
883 # and need to be exported to allow XS modules to implement layers
897 PerlIOBase_setlinebuf
940 Perl_PerlIO_get_bufsiz
946 Perl_PerlIO_set_ptrcnt
947 Perl_PerlIO_setlinebuf
955 if ($PLATFORM eq 'netware') {
956 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
959 if ($define{'USE_PERLIO'}) {
960 # Export the symols that make up the PerlIO abstraction, regardless
961 # of its implementation - read from a file
962 push @syms, $perlio_sym;
964 # This part is then dependent on how the abstraction is implemented
965 if ($define{'USE_SFIO'}) {
966 # Old legacy non-stdio "PerlIO"
967 skip_symbols \@layer_syms;
968 skip_symbols [qw(perlsio_binmode)];
969 # SFIO defines most of the PerlIO routines as macros
970 # So undo most of what $perlio_sym has just done - d'oh !
971 # Perhaps it would be better to list the ones which do exist
1016 Perl_PerlIO_clearerr
1023 Perl_PerlIO_get_base
1024 Perl_PerlIO_get_bufsiz
1030 Perl_PerlIO_set_ptrcnt
1031 Perl_PerlIO_setlinebuf
1044 # PerlIO with layers - export implementation
1045 emit_symbols \@layer_syms;
1046 emit_symbols [qw(perlsio_binmode)];
1050 # Skip the PerlIO layer symbols - although
1051 # nothing should have exported them anyway.
1052 skip_symbols \@layer_syms;
1053 skip_symbols [qw(perlsio_binmode)];
1054 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
1056 # Also do NOT add abstraction symbols from $perlio_sym
1057 # abstraction is done as #define to stdio
1058 # Remaining remnants that _may_ be functions
1059 # are handled in <DATA>
1062 for my $syms (@syms) {
1063 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1065 next if (!/^[A-Za-z]/);
1066 # Functions have a Perl_ prefix
1067 # Variables have a PL_ prefix
1069 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1071 emit_symbol($symbol) unless exists $skip{$symbol};
1078 if ($define{'MULTIPLICITY'}) {
1079 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
1080 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1083 # XXX AIX seems to want the perlvars.h symbols, for some reason
1084 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1085 my $glob = readvar($perlvars_h);
1090 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1091 my $glob = readvar($perlvars_h);
1094 unless ($define{'MULTIPLICITY'}) {
1095 my $glob = readvar($intrpvar_h);
1098 unless ($define{'MULTIPLICITY'}) {
1099 my $glob = readvar($thrdvar_h);
1107 return if $symbol !~ /^[A-Za-z_]/;
1108 return if $symbol =~ /^\#/;
1111 return if exists $skip{$symbol};
1112 emit_symbol($symbol);
1119 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1120 foreach my $symbol (qw(
1182 win32_getprotobyname
1183 win32_getprotobynumber
1212 win32_open_osfhandle
1282 try_symbol($symbol);
1284 if ($CCTYPE eq "BORLAND") {
1285 try_symbol('_matherr');
1288 elsif ($PLATFORM eq 'os2') {
1289 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1290 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1291 close MAP or die 'Cannot close miniperl.map';
1293 @missing = grep { !exists $mapped{$_} }
1295 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1296 delete $export{$_} foreach @missing;
1298 elsif ($PLATFORM eq 'MacOS') {
1299 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1307 elsif ($PLATFORM eq 'netware') {
1308 foreach my $symbol (qw(
1435 fnInsertHashListAddrs
1446 try_symbol($symbol);
1450 # records of type boot_module for statically linked modules (except Dynaloader)
1451 $static_ext =~ s/\//__/g;
1452 $static_ext =~ s/\bDynaLoader\b//;
1453 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1454 foreach my $symbol (@stat_mods)
1456 try_symbol($symbol);
1459 # Now all symbols should be defined because
1460 # next we are going to output them.
1462 foreach my $symbol (sort keys %export) {
1463 output_symbol($symbol);
1466 if ($PLATFORM eq 'os2') {
1471 Perl_OS2_handler_install
1473 ; LAST_ORDINAL=$sym_ord
1480 $export{$symbol} = 1;
1485 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1486 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1487 print "\t$symbol\n";
1488 # XXX: binary compatibility between compilers is an exercise
1489 # in frustration :-(
1490 # if ($CCTYPE eq "BORLAND") {
1491 # # workaround Borland quirk by exporting both the straight
1492 # # name and a name with leading underscore. Note the
1493 # # alias *must* come after the symbol itself, if both
1494 # # are to be exported. (Linker bug?)
1495 # print "\t_$symbol\n";
1496 # print "\t$symbol = _$symbol\n";
1498 # elsif ($CCTYPE eq 'GCC') {
1499 # # Symbols have leading _ whole process is $%@"% slow
1500 # # so skip aliases for now
1501 # nprint "\t$symbol\n";
1504 # # for binary coexistence, export both the symbol and
1505 # # alias with leading underscore
1506 # print "\t$symbol\n";
1507 # print "\t_$symbol = $symbol\n";
1510 elsif ($PLATFORM eq 'os2') {
1511 printf qq( %-31s \@%s\n),
1512 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1513 printf qq( %-31s \@%s\n),
1514 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1515 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1516 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1518 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1521 elsif ($PLATFORM eq 'netware') {
1522 print "\t$symbol,\n";
1528 # extra globals not included above.
1539 # Oddities from PerlIO