3 # Create the export list for perl.
5 # Needed by WIN32 and OS/2 for creating perl.dll,
6 # and by AIX for creating libperl.a when -Dusershrplib is in effect,
7 # and by VMS for creating perlshr.exe.
9 # Reads from information stored in
16 # miniperl.map (on OS/2)
17 # perl5.def (on OS/2; this is the old version of the file being made)
21 # plus long lists of function names hard-coded directly in this script and
22 # in the DATA section.
24 # Writes the result to STDOUT.
26 # Normally this script is invoked from a makefile (e.g. win32/Makefile),
27 # which redirects STDOUT to a suitable file, such as:
35 BEGIN { unshift @INC, "lib" }
39 use vars qw($PLATFORM $CCTYPE $FILETYPE $TARG_DIR);
44 my (%define, %ordinal);
48 if ($flag =~ s/^CC_FLAGS=/ /) {
49 for my $fflag ($flag =~ /(?:^|\s)-D(\S+)/g) {
50 $fflag .= '=1' unless $fflag =~ /^(\w+)=/;
51 $define{$1} = $2 if $fflag =~ /^(\w+)=(.+)$/;
55 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
56 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
57 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
58 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
59 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
60 $TARG_DIR = $1 if $flag =~ /^TARG_DIR=(.+)$/;
63 my @PLATFORM = qw(aix win32 wince os2 netware vms);
65 @PLATFORM{@PLATFORM} = ();
67 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
68 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
70 if ($PLATFORM eq 'win32' or $PLATFORM eq 'wince' or $PLATFORM eq "aix") {
71 # Add the compile-time options that miniperl was built with to %define.
72 # On Win32 these are not the same options as perl itself will be built
73 # with since miniperl is built with a canned config (one of the win32/
74 # config_H.*) and none of the BUILDOPT's that are set in the makefiles,
75 # but they do include some #define's that are hard-coded in various
76 # source files and header files and don't include any BUILDOPT's that
77 # the user might have chosen to disable because the canned configs are
78 # minimal configs that don't include any of those options.
81 = sort(Config::bincompat_options(), Config::non_bincompat_options());
82 print STDERR "Options: (@options)\n";
83 $define{$_} = 1 foreach @options;
86 my %exportperlmalloc =
88 Perl_malloc => "malloc",
90 Perl_realloc => "realloc",
91 Perl_calloc => "calloc",
94 my $exportperlmalloc = $PLATFORM eq 'os2';
96 my $config_sh = "config.sh";
97 my $config_h = "config.h";
98 my $intrpvar_h = "intrpvar.h";
99 my $perlvars_h = "perlvars.h";
100 my $global_sym = "global.sym";
101 my $globvar_sym = "globvar.sym";
102 my $perlio_sym = "perlio.sym";
106 # All platforms export boot_DynaLoader unconditionally.
107 my %export = ( boot_DynaLoader => 1 );
109 s/^/$TARG_DIR/ foreach($intrpvar_h, $perlvars_h, $global_sym, $globvar_sym,
110 $perlio_sym, $config_sh);
112 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'netware') {
113 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
115 if (/^(?:ccflags|optimize)='(.+)'$/) {
117 $define{$1} = 1 while /-D(\w+)/g;
120 if /^(config_args|archname|perl_patchlevel)='(.+)'$/;
121 if ($PLATFORM eq 'vms') {
122 $define{DEBUGGING} = 1 if /^usedebugging_perl='Y'$/;
123 $define{UNLINK_ALL_VERSIONS} = 1 if /^d_unlink_all_versions='define'$/;
128 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
129 open(CFG, '<', $config_sh) || die "Cannot open $config_sh: $!\n";
130 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
136 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
138 $define{$1} = 1 if /^\s*\#\s*define\s+(MYMALLOC|MULTIPLICITY
139 |SPRINTF_RETURNS_STRLEN
140 |(?:PERL|USE|HAS)_\w+)\b/x;
144 # perl.h logic duplication begins
146 if ($define{PERL_IMPLICIT_SYS}) {
147 $define{PL_OP_SLAB_ALLOC} = 1;
150 if ($define{USE_ITHREADS}) {
151 if (!$define{MULTIPLICITY}) {
152 $define{MULTIPLICITY} = 1;
156 $define{PERL_IMPLICIT_CONTEXT} ||=
157 $define{USE_ITHREADS} ||
158 $define{MULTIPLICITY} ;
160 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
161 $define{USE_REENTRANT_API} = 1;
164 # perl.h logic duplication ends
168 print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n";
170 if ($PLATFORM =~ /^win(?:32|ce)$/) {
171 (my $dll = ($define{PERL_DLL} || "perl515")) =~ s/\.dll$//i;
172 print "LIBRARY $dll\n";
173 # The DESCRIPTION module definition file statement is not supported
175 if ($CCTYPE =~ /^(?:MSVC60|GCC|BORLAND)$/) {
176 print "DESCRIPTION 'Perl interpreter'\n";
179 if ($define{PERL_IMPLICIT_SYS}) {
180 ++$export{$_} foreach qw(perl_get_host_info perl_alloc_override);
182 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
183 ++$export{perl_clone_host};
186 elsif ($PLATFORM eq 'os2') {
187 if (open my $fh, '<', 'perl5.def') {
189 last if /^\s*EXPORTS\b/;
192 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
193 # This allows skipping ordinals which were used in older versions
194 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
196 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
198 (my $v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
199 $v .= '-thread' if $define{archname} =~ /-thread/;
200 (my $dll = $define{PERL_DLL}) =~ s/\.dll$//i;
201 $v .= "\@$define{perl_patchlevel}" if $define{perl_patchlevel};
202 my $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $define{config_args}'";
203 $d = substr($d, 0, 249) . "...'" if length $d > 253;
205 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
209 DATA LOADONCALL NONSHARED MULTIPLE
213 elsif ($PLATFORM eq 'aix') {
214 my $OSVER = `uname -v`;
216 my $OSREL = `uname -r`;
218 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
224 elsif ($PLATFORM eq 'netware') {
225 if ($FILETYPE eq 'def') {
226 print "LIBRARY perl515\n";
227 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
230 if ($define{PERL_IMPLICIT_SYS}) {
232 foreach qw(perl_get_host_info perl_alloc_override perl_clone_host);
238 foreach my $symbol (@$list) {
245 foreach my $symbol (@$list) {
246 my $skipsym = $symbol;
248 if ($define{MULTIPLICITY}) {
249 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
251 emit_symbol($symbol) unless exists $skip{$skipsym};
255 if ($PLATFORM ne 'os2') {
270 if ($PLATFORM eq 'vms') {
278 if ($PLATFORM ne 'aix') {
291 if ($PLATFORM ne 'vms') {
292 # VMS does its own thing for these symbols.
294 PL_sig_handlers_initted
298 if ($PLATFORM ne 'win32') {
307 if ($PLATFORM eq 'os2') {
352 XS_Cwd_extLibpath_set
356 XS_Cwd_sys_is_absolute
357 XS_Cwd_sys_is_relative
359 XS_DynaLoader_mod2fname
360 XS_File__Copy_syscopy
364 Perl_Process_Messages
375 emit_symbols([qw(os2_cond_wait
380 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
382 elsif ($PLATFORM eq 'vms') {
387 Perl_csighandler_init
390 Perl_fileify_dirspec_ts
391 Perl_fileify_dirspec_utf8
392 Perl_fileify_dirspec_utf8_ts
425 Perl_pathify_dirspec_ts
426 Perl_pathify_dirspec_utf8
427 Perl_pathify_dirspec_utf8_ts
435 Perl_rmsexpand_utf8_ts
437 Perl_sig_to_vmscondition
442 Perl_tounixpath_utf8_ts
446 Perl_tounixspec_utf8_ts
450 Perl_tovmspath_utf8_ts
454 Perl_tovmsspec_utf8_ts
456 Perl_vms_case_tolerant
468 unless ($define{UNLINK_ALL_VERSIONS}) {
474 unless ($define{'DEBUGGING'}) {
491 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
497 if ($define{'PERL_IMPLICIT_SYS'}) {
517 unless ($define{'PERL_OLD_COPY_ON_WRITE'}) {
523 unless ($define{'USE_REENTRANT_API'}) {
529 if ($define{'MYMALLOC'}) {
538 if ($define{'USE_ITHREADS'}) {
555 Perl_malloc_good_size
561 if ($define{'PERL_USE_SAFE_PUTENV'}) {
567 unless ($define{'USE_ITHREADS'}) {
573 # USE_5005THREADS symbols. Kept as reference for easier removal
592 Perl_new_struct_thread
593 Perl_per_thread_magicals
601 unless ($define{'USE_ITHREADS'}) {
607 PL_sharedsv_space_mutex
612 Perl_clone_params_del
613 Perl_clone_params_new
637 Perl_sharedsv_thrcnt_dec
638 Perl_sharedsv_thrcnt_inc
640 Perl_stashpv_hvname_match
641 Perl_regdupe_internal
646 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
656 Perl_load_module_nocontext
659 Perl_warner_nocontext
660 Perl_newSVpvf_nocontext
661 Perl_sv_catpvf_nocontext
662 Perl_sv_setpvf_nocontext
663 Perl_sv_catpvf_mg_nocontext
664 Perl_sv_setpvf_mg_nocontext
670 unless ($define{'PERL_IMPLICIT_SYS'}) {
677 unless ($define{'PL_OP_SLAB_ALLOC'}) {
687 unless ($define{'PERL_DEBUG_READONLY_OPS'}) {
694 unless ($define{'THREADS_HAVE_PIDS'}) {
695 skip_symbols [qw(PL_ppid)];
698 unless ($define{'PERL_NEED_APPCTX'}) {
704 unless ($define{'PERL_NEED_TIMESBASE'}) {
710 unless ($define{'DEBUG_LEAKING_SCALARS'}) {
716 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
721 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
726 if ($define{'SPRINTF_RETURNS_STRLEN'}) {
731 unless ($define{'PERL_USES_PL_PIDSTATUS'}) {
738 unless ($define{'PERL_TRACK_MEMPOOL'}) {
740 PL_memory_debug_header
744 unless ($define{PERL_MAD}) {
752 Perl_xmldump_packsubs
766 unless ($define{'MULTIPLICITY'}) {
769 PL_interp_size_5_16_0
773 unless ($define{'PERL_GLOBAL_STRUCT'}) {
775 PL_global_struct_size
779 unless ($define{'PERL_GLOBAL_STRUCT_PRIVATE'}) {
786 unless ($define{HAS_MMAP}) {
792 if ($define{HAS_SIGACTION}) {
798 unless ($define{USE_LOCALE_COLLATE}) {
802 PL_collation_standard
806 Perl_sv_collxfrm_flags
810 unless ($define{USE_LOCALE_NUMERIC}) {
819 unless ($define{HAVE_INTERP_INTERN}) {
821 Perl_sys_intern_clear
828 if ($define{HAS_SIGNBIT}) {
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);
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
917 Perl_PerlIO_context_layers
924 Perl_PerlIO_get_bufsiz
930 Perl_PerlIO_set_ptrcnt
931 Perl_PerlIO_setlinebuf
939 if ($PLATFORM eq 'netware') {
940 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
943 if ($define{'USE_PERLIO'}) {
944 # Export the symols that make up the PerlIO abstraction, regardless
945 # of its implementation - read from a file
946 push @syms, $perlio_sym;
948 # This part is then dependent on how the abstraction is implemented
949 if ($define{'USE_SFIO'}) {
950 # Old legacy non-stdio "PerlIO"
951 skip_symbols \@layer_syms;
952 skip_symbols [qw(perlsio_binmode)];
953 # SFIO defines most of the PerlIO routines as macros
954 # So undo most of what $perlio_sym has just done - d'oh !
955 # Perhaps it would be better to list the ones which do exist
1000 Perl_PerlIO_clearerr
1007 Perl_PerlIO_get_base
1008 Perl_PerlIO_get_bufsiz
1014 Perl_PerlIO_set_ptrcnt
1015 Perl_PerlIO_setlinebuf
1028 # PerlIO with layers - export implementation
1029 emit_symbols \@layer_syms;
1030 emit_symbols [qw(perlsio_binmode)];
1032 if ($define{'USE_ITHREADS'}) {
1044 # Skip the PerlIO layer symbols - although
1045 # nothing should have exported them anyway.
1046 skip_symbols \@layer_syms;
1054 PL_perlio_fd_refcnt_size
1057 # Also do NOT add abstraction symbols from $perlio_sym
1058 # abstraction is done as #define to stdio
1059 # Remaining remnants that _may_ be functions
1060 # are handled in <DATA>
1063 for my $syms (@syms) {
1064 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1066 next if (!/^[A-Za-z]/);
1067 # Functions have a Perl_ prefix
1068 # Variables have a PL_ prefix
1070 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1072 emit_symbol($symbol) unless exists $skip{$symbol};
1079 if ($define{'MULTIPLICITY'} && $define{PERL_GLOBAL_STRUCT}) {
1080 for my $f ($perlvars_h) {
1081 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1084 # XXX AIX seems to want the perlvars.h symbols, for some reason
1085 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1086 my $glob = readvar($perlvars_h);
1091 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1092 my $glob = readvar($perlvars_h);
1095 unless ($define{MULTIPLICITY}) {
1096 my $glob = readvar($intrpvar_h);
1104 return if $symbol !~ /^[A-Za-z_]/;
1105 return if $symbol =~ /^\#/;
1108 return if exists $skip{$symbol};
1109 emit_symbol($symbol);
1116 if ($PLATFORM eq 'win32') {
1117 try_symbol($_) foreach qw(
1128 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1129 foreach my $symbol (qw(
1188 win32_getprotobyname
1189 win32_getprotobynumber
1218 win32_open_osfhandle
1285 try_symbol($symbol);
1287 if ($CCTYPE eq "BORLAND") {
1288 try_symbol('_matherr');
1291 elsif ($PLATFORM eq 'os2') {
1292 my (%mapped, @missing);
1293 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1294 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1295 close MAP or die 'Cannot close miniperl.map';
1297 @missing = grep { !exists $mapped{$_} }
1299 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1300 delete $export{$_} foreach @missing;
1302 elsif ($PLATFORM eq 'netware') {
1303 foreach my $symbol (qw(
1429 fnInsertHashListAddrs
1440 try_symbol($symbol);
1444 # records of type boot_module for statically linked modules (except Dynaloader)
1445 $static_ext =~ s/\//__/g;
1446 $static_ext =~ s/\bDynaLoader\b//;
1447 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1448 foreach my $symbol (@stat_mods)
1450 try_symbol($symbol);
1453 try_symbol("init_Win32CORE") if $static_ext =~ /\bWin32CORE\b/;
1455 # Now all symbols should be defined because
1456 # next we are going to output them.
1458 foreach my $symbol (sort keys %export) {
1459 output_symbol($symbol);
1462 if ($PLATFORM eq 'os2') {
1467 Perl_OS2_handler_install
1469 ; LAST_ORDINAL=$sym_ord
1476 $export{$symbol} = 1;
1481 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1482 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1483 print "\t$symbol\n";
1484 # XXX: binary compatibility between compilers is an exercise
1485 # in frustration :-(
1486 # if ($CCTYPE eq "BORLAND") {
1487 # # workaround Borland quirk by exporting both the straight
1488 # # name and a name with leading underscore. Note the
1489 # # alias *must* come after the symbol itself, if both
1490 # # are to be exported. (Linker bug?)
1491 # print "\t_$symbol\n";
1492 # print "\t$symbol = _$symbol\n";
1494 # elsif ($CCTYPE eq 'GCC') {
1495 # # Symbols have leading _ whole process is $%@"% slow
1496 # # so skip aliases for now
1497 # nprint "\t$symbol\n";
1500 # # for binary coexistence, export both the symbol and
1501 # # alias with leading underscore
1502 # print "\t$symbol\n";
1503 # print "\t_$symbol = $symbol\n";
1506 elsif ($PLATFORM eq 'os2') {
1507 printf qq( %-31s \@%s\n),
1508 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1509 printf qq( %-31s \@%s\n),
1510 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1511 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1512 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1514 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'vms') {
1517 elsif ($PLATFORM eq 'netware') {
1518 print "\t$symbol,\n";
1524 # Oddities from PerlIO