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 # 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 -Ilib -V`;
49 my($options) = $config =~ /^ Compile-time options: (.*?)^ \S/ms;
50 print STDERR "Options: ($options)\n";
51 foreach (split /\s+/, $options) {
56 my %exportperlmalloc =
58 Perl_malloc => "malloc",
60 Perl_realloc => "realloc",
61 Perl_calloc => "calloc",
64 my $exportperlmalloc = $PLATFORM eq 'os2';
66 my $config_sh = "config.sh";
67 my $config_h = "config.h";
68 my $thrdvar_h = "thrdvar.h";
69 my $intrpvar_h = "intrpvar.h";
70 my $perlvars_h = "perlvars.h";
71 my $global_sym = "global.sym";
72 my $pp_sym = "pp.sym";
73 my $globvar_sym = "globvar.sym";
74 my $perlio_sym = "perlio.sym";
77 if ($PLATFORM eq 'aix') {
80 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
81 $CCTYPE = "MSVC" unless defined $CCTYPE;
82 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
83 $pp_sym, $globvar_sym, $perlio_sym) {
87 elsif ($PLATFORM eq 'MacOS') {
88 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
89 $pp_sym, $globvar_sym, $perlio_sym) {
94 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
95 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
97 if (/^(?:ccflags|optimize)='(.+)'$/) {
99 $define{$1} = 1 while /-D(\w+)/g;
101 if (/^(d_(?:mmap|sigaction))='(.+)'$/) {
104 if ($PLATFORM eq 'os2') {
105 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
106 $ARCHNAME = $1 if /^archname='(.+)'$/;
107 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
112 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
113 open(CFG,"<..\\$config_sh") || die "Cannot open ..\\$config_sh: $!\n";
114 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
120 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
122 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
123 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
124 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
125 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
129 # perl.h logic duplication begins
131 if ($define{PERL_IMPLICIT_SYS}) {
132 $define{PL_OP_SLAB_ALLOC} = 1;
135 if ($define{USE_ITHREADS}) {
136 if (!$define{MULTIPLICITY}) {
137 $define{MULTIPLICITY} = 1;
141 $define{PERL_IMPLICIT_CONTEXT} ||=
142 $define{USE_ITHREADS} ||
143 $define{MULTIPLICITY} ;
145 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
146 $define{USE_REENTRANT_API} = 1;
149 # perl.h logic duplication ends
153 if ($PLATFORM =~ /^win(?:32|ce)$/) {
154 warn join(' ',keys %define)."\n";
155 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
156 print "LIBRARY $dll\n";
157 print "DESCRIPTION 'Perl interpreter'\n";
159 if ($define{PERL_IMPLICIT_SYS}) {
160 output_symbol("perl_get_host_info");
161 output_symbol("perl_alloc_override");
163 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
164 output_symbol("perl_clone_host");
167 elsif ($PLATFORM eq 'os2') {
168 if (open my $fh, '<', 'perl5.def') {
170 last if /^\s*EXPORTS\b/;
173 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
174 # This allows skipping ordinals which were used in older versions
175 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
177 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
179 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
180 $v .= '-thread' if $ARCHNAME =~ /-thread/;
181 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
182 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
183 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
184 $d = substr($d, 0, 249) . "...'" if length $d > 253;
186 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
190 DATA LOADONCALL NONSHARED MULTIPLE
194 elsif ($PLATFORM eq 'aix') {
199 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
205 elsif ($PLATFORM eq 'netware') {
206 if ($FILETYPE eq 'def') {
207 print "LIBRARY perl59\n";
208 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
211 if ($define{PERL_IMPLICIT_SYS}) {
212 output_symbol("perl_get_host_info");
213 output_symbol("perl_alloc_override");
214 output_symbol("perl_clone_host");
223 foreach my $symbol (@$list) {
230 foreach my $symbol (@$list) {
231 my $skipsym = $symbol;
233 if ($define{MULTIPLICITY}) {
234 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
236 emit_symbol($symbol) unless exists $skip{$skipsym};
240 if ($PLATFORM eq 'win32') {
265 Perl_init_thread_intern
298 if ($PLATFORM eq 'wince') {
314 PL_collation_standard
342 Perl_init_thread_intern
368 elsif ($PLATFORM eq 'aix') {
387 Perl_sys_intern_clear
396 elsif ($PLATFORM eq 'os2') {
441 XS_Cwd_extLibpath_set
445 XS_Cwd_sys_is_absolute
446 XS_Cwd_sys_is_relative
448 XS_DynaLoader_mod2fname
449 XS_File__Copy_syscopy
453 Perl_Process_Messages
464 emit_symbols([qw(os2_cond_wait
469 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
471 elsif ($PLATFORM eq 'MacOS') {
495 Perl_sys_intern_clear
499 elsif ($PLATFORM eq 'netware') {
524 Perl_init_thread_intern
549 Perl_sys_intern_clear
557 Perl_PerlIO_setlinebuf
558 Perl_PerlIO_set_ptrcnt
564 Perl_PerlIO_get_bufsiz
577 unless ($define{'DEBUGGING'}) {
592 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
598 if ($define{'PERL_IMPLICIT_SYS'}) {
619 unless ($define{'PERL_OLD_COPY_ON_WRITE'}) {
626 unless ($define{'USE_REENTRANT_API'}) {
632 if ($define{'MYMALLOC'}) {
641 if ($define{'USE_ITHREADS'}) {
663 unless ($define{'PERL_MALLOC_WRAP'}) {
669 unless ($define{'USE_ITHREADS'}) {
675 # USE_5005THREADS symbols. Kept as reference for easier removal
694 Perl_new_struct_thread
695 Perl_per_thread_magicals
703 unless ($define{'USE_ITHREADS'}) {
712 PL_sharedsv_space_mutex
742 Perl_sharedsv_thrcnt_dec
743 Perl_sharedsv_thrcnt_inc
745 Perl_stashpv_hvname_match
749 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
755 Perl_load_module_nocontext
758 Perl_warner_nocontext
759 Perl_newSVpvf_nocontext
760 Perl_sv_catpvf_nocontext
761 Perl_sv_setpvf_nocontext
762 Perl_sv_catpvf_mg_nocontext
763 Perl_sv_setpvf_mg_nocontext
767 unless ($define{'PERL_IMPLICIT_SYS'}) {
774 unless ($define{'FAKE_THREADS'}) {
775 skip_symbols [qw(PL_curthr)];
778 unless ($define{'PL_OP_SLAB_ALLOC'}) {
788 unless ($define{'THREADS_HAVE_PIDS'}) {
789 skip_symbols [qw(PL_ppid)];
792 unless ($define{'PERL_NEED_APPCTX'}) {
798 unless ($define{'PERL_NEED_TIMESBASE'}) {
804 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
809 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
815 unless ($define{'d_mmap'}) {
821 if ($define{'d_sigaction'}) {
828 # VMS does its own thing for these symbols.
829 skip_symbols [qw(PL_sig_handlers_initted
836 my $proc = shift || sub { "PL_$_[2]" };
837 open(VARS,$file) || die "Cannot open $file: $!\n";
840 # All symbols have a Perl_ prefix because that's what embed.h
841 # sticks in front of them. The A?I?S?C? is strictly speaking
843 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
849 if ($define{'PERL_GLOBAL_STRUCT'}) {
850 my $global = readvar($perlvars_h);
851 skip_symbols $global;
852 emit_symbol('Perl_GetVars');
853 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
855 skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
858 # functions from *.sym files
860 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
862 # Symbols that are the public face of the PerlIO layers implementation
863 # These are in _addition to_ the public face of the abstraction
864 # and need to be exported to allow XS modules to implement layers
878 PerlIOBase_setlinebuf
921 Perl_PerlIO_get_bufsiz
927 Perl_PerlIO_set_ptrcnt
928 Perl_PerlIO_setlinebuf
936 if ($PLATFORM eq 'netware') {
937 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
940 if ($define{'USE_PERLIO'}) {
941 # Export the symols that make up the PerlIO abstraction, regardless
942 # of its implementation - read from a file
943 push @syms, $perlio_sym;
945 # This part is then dependent on how the abstraction is implemented
946 if ($define{'USE_SFIO'}) {
947 # Old legacy non-stdio "PerlIO"
948 skip_symbols \@layer_syms;
949 skip_symbols [qw(perlsio_binmode)];
950 # SFIO defines most of the PerlIO routines as macros
951 # So undo most of what $perlio_sym has just done - d'oh !
952 # Perhaps it would be better to list the ones which do exist
1004 Perl_PerlIO_get_base
1005 Perl_PerlIO_get_bufsiz
1011 Perl_PerlIO_set_ptrcnt
1012 Perl_PerlIO_setlinebuf
1025 # PerlIO with layers - export implementation
1026 emit_symbols \@layer_syms;
1027 emit_symbols [qw(perlsio_binmode)];
1031 # Skip the PerlIO layer symbols - although
1032 # nothing should have exported them anyway.
1033 skip_symbols \@layer_syms;
1034 skip_symbols [qw(perlsio_binmode)];
1035 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
1037 # Also do NOT add abstraction symbols from $perlio_sym
1038 # abstraction is done as #define to stdio
1039 # Remaining remnants that _may_ be functions
1040 # are handled in <DATA>
1043 for my $syms (@syms) {
1044 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1046 next if (!/^[A-Za-z]/);
1047 # Functions have a Perl_ prefix
1048 # Variables have a PL_ prefix
1050 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1052 emit_symbol($symbol) unless exists $skip{$symbol};
1059 if ($define{'MULTIPLICITY'}) {
1060 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
1061 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1064 # XXX AIX seems to want the perlvars.h symbols, for some reason
1065 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1066 my $glob = readvar($perlvars_h);
1071 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1072 my $glob = readvar($perlvars_h);
1075 unless ($define{'MULTIPLICITY'}) {
1076 my $glob = readvar($intrpvar_h);
1079 unless ($define{'MULTIPLICITY'}) {
1080 my $glob = readvar($thrdvar_h);
1088 return if $symbol !~ /^[A-Za-z_]/;
1089 return if $symbol =~ /^\#/;
1092 return if exists $skip{$symbol};
1093 emit_symbol($symbol);
1100 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1101 foreach my $symbol (qw(
1163 win32_getprotobyname
1164 win32_getprotobynumber
1193 win32_open_osfhandle
1263 try_symbol($symbol);
1265 if ($CCTYPE eq "BORLAND") {
1266 try_symbol('_matherr');
1269 elsif ($PLATFORM eq 'os2') {
1270 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1271 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1272 close MAP or die 'Cannot close miniperl.map';
1274 @missing = grep { !exists $mapped{$_} }
1276 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1277 delete $export{$_} foreach @missing;
1279 elsif ($PLATFORM eq 'MacOS') {
1280 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1288 elsif ($PLATFORM eq 'netware') {
1289 foreach my $symbol (qw(
1416 fnInsertHashListAddrs
1427 try_symbol($symbol);
1431 # records of type boot_module for statically linked modules (except Dynaloader)
1432 $static_ext =~ s/\//__/g;
1433 $static_ext =~ s/\bDynaLoader\b//;
1434 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1435 foreach my $symbol (@stat_mods)
1437 try_symbol($symbol);
1440 # Now all symbols should be defined because
1441 # next we are going to output them.
1443 foreach my $symbol (sort keys %export) {
1444 output_symbol($symbol);
1447 if ($PLATFORM eq 'os2') {
1452 Perl_OS2_handler_install
1454 ; LAST_ORDINAL=$sym_ord
1461 $export{$symbol} = 1;
1466 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1467 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1468 print "\t$symbol\n";
1469 # XXX: binary compatibility between compilers is an exercise
1470 # in frustration :-(
1471 # if ($CCTYPE eq "BORLAND") {
1472 # # workaround Borland quirk by exporting both the straight
1473 # # name and a name with leading underscore. Note the
1474 # # alias *must* come after the symbol itself, if both
1475 # # are to be exported. (Linker bug?)
1476 # print "\t_$symbol\n";
1477 # print "\t$symbol = _$symbol\n";
1479 # elsif ($CCTYPE eq 'GCC') {
1480 # # Symbols have leading _ whole process is $%@"% slow
1481 # # so skip aliases for now
1482 # nprint "\t$symbol\n";
1485 # # for binary coexistence, export both the symbol and
1486 # # alias with leading underscore
1487 # print "\t$symbol\n";
1488 # print "\t_$symbol = $symbol\n";
1491 elsif ($PLATFORM eq 'os2') {
1492 printf qq( %-31s \@%s\n),
1493 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1494 printf qq( %-31s \@%s\n),
1495 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1496 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1497 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1499 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1502 elsif ($PLATFORM eq 'netware') {
1503 print "\t$symbol,\n";
1509 # extra globals not included above.
1520 # Oddities from PerlIO