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 $CONFIG_ARGS $ARCHNAME $PATCHLEVEL $TARG_DIR);
43 my (%define, %ordinal);
47 if ($flag =~ s/^CC_FLAGS=/ /) {
48 for my $fflag ($flag =~ /(?:^|\s)-D(\S+)/g) {
49 $fflag .= '=1' unless $fflag =~ /^(\w+)=/;
50 $define{$1} = $2 if $fflag =~ /^(\w+)=(.+)$/;
54 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
55 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
56 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
57 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
58 if ($PLATFORM eq 'netware') {
59 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
61 $TARG_DIR = $1 if $flag =~ /^TARG_DIR=(.+)$/;
64 my @PLATFORM = qw(aix win32 wince os2 netware vms);
66 @PLATFORM{@PLATFORM} = ();
68 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
69 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
71 if ($PLATFORM eq 'win32' or $PLATFORM eq 'wince' or $PLATFORM eq "aix") {
72 # Add the compile-time options that miniperl was built with to %define.
73 # On Win32 these are not the same options as perl itself will be built
74 # with since miniperl is built with a canned config (one of the win32/
75 # config_H.*) and none of the BUILDOPT's that are set in the makefiles,
76 # but they do include some #define's that are hard-coded in various
77 # source files and header files and don't include any BUILDOPT's that
78 # the user might have chosen to disable because the canned configs are
79 # minimal configs that don't include any of those options.
80 my $opts = ($PLATFORM eq 'wince' ? '-MCross' : ''); # for wince need Cross.pm to get Config.pm
82 $ENV{PERL5LIB} = join $Config{path_sep}, @INC;
83 my $cmd = "$^X $opts -V";
85 or die "Couldn't run [$cmd]: $!";
86 my($options) = $config =~ /^ Compile-time options: (.*?)\n^ \S/ms;
87 $options =~ s/\s+/ /g;
88 print STDERR "Options: ($options)\n";
89 foreach (split /\s+/, $options) {
94 my %exportperlmalloc =
96 Perl_malloc => "malloc",
98 Perl_realloc => "realloc",
99 Perl_calloc => "calloc",
102 my $exportperlmalloc = $PLATFORM eq 'os2';
104 my $config_sh = "config.sh";
105 my $config_h = "config.h";
106 my $intrpvar_h = "intrpvar.h";
107 my $perlvars_h = "perlvars.h";
108 my $global_sym = "global.sym";
109 my $globvar_sym = "globvar.sym";
110 my $perlio_sym = "perlio.sym";
113 if ($PLATFORM eq 'aix') {
116 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
117 $CCTYPE = "MSVC" unless defined $CCTYPE;
118 foreach ($intrpvar_h, $perlvars_h, $global_sym, $globvar_sym, $perlio_sym,
124 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'netware') {
125 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
127 if (/^(?:ccflags|optimize)='(.+)'$/) {
129 $define{$1} = 1 while /-D(\w+)/g;
131 if (/^(d_(?:mmap|sigaction))='(.+)'$/) {
134 if ($PLATFORM eq 'os2') {
135 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
136 $ARCHNAME = $1 if /^archname='(.+)'$/;
137 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
139 if ($PLATFORM eq 'vms') {
140 $define{DEBUGGING} = 1 if /^usedebugging_perl='Y'$/;
141 $define{UNLINK_ALL_VERSIONS} = 1 if /^d_unlink_all_versions='define'$/;
146 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
147 open(CFG, '<', $config_sh) || die "Cannot open $config_sh: $!\n";
148 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
154 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
156 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
157 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
158 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
159 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
160 $define{$1} = 1 if /^\s*#\s*define\s+(HAS_\w+)\b/;
164 # perl.h logic duplication begins
166 if ($define{PERL_IMPLICIT_SYS}) {
167 $define{PL_OP_SLAB_ALLOC} = 1;
170 if ($define{USE_ITHREADS}) {
171 if (!$define{MULTIPLICITY}) {
172 $define{MULTIPLICITY} = 1;
176 $define{PERL_IMPLICIT_CONTEXT} ||=
177 $define{USE_ITHREADS} ||
178 $define{MULTIPLICITY} ;
180 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
181 $define{USE_REENTRANT_API} = 1;
184 # perl.h logic duplication ends
188 print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n";
190 if ($PLATFORM =~ /^win(?:32|ce)$/) {
191 (my $dll = ($define{PERL_DLL} || "perl515")) =~ s/\.dll$//i;
192 print "LIBRARY $dll\n";
193 # The DESCRIPTION module definition file statement is not supported
195 if ($CCTYPE =~ /^(?:MSVC60|GCC|BORLAND)$/) {
196 print "DESCRIPTION 'Perl interpreter'\n";
199 if ($define{PERL_IMPLICIT_SYS}) {
200 output_symbol("perl_get_host_info");
201 output_symbol("perl_alloc_override");
203 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
204 output_symbol("perl_clone_host");
207 elsif ($PLATFORM eq 'os2') {
208 if (open my $fh, '<', 'perl5.def') {
210 last if /^\s*EXPORTS\b/;
213 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
214 # This allows skipping ordinals which were used in older versions
215 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
217 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
219 (my $v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
220 $v .= '-thread' if $ARCHNAME =~ /-thread/;
221 (my $dll = $define{PERL_DLL}) =~ s/\.dll$//i;
222 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
223 my $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
224 $d = substr($d, 0, 249) . "...'" if length $d > 253;
226 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
230 DATA LOADONCALL NONSHARED MULTIPLE
234 elsif ($PLATFORM eq 'aix') {
235 my $OSVER = `uname -v`;
237 my $OSREL = `uname -r`;
239 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
245 elsif ($PLATFORM eq 'netware') {
246 if ($FILETYPE eq 'def') {
247 print "LIBRARY perl515\n";
248 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
251 if ($define{PERL_IMPLICIT_SYS}) {
252 output_symbol("perl_get_host_info");
253 output_symbol("perl_alloc_override");
254 output_symbol("perl_clone_host");
263 foreach my $symbol (@$list) {
270 foreach my $symbol (@$list) {
271 my $skipsym = $symbol;
273 if ($define{MULTIPLICITY}) {
274 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
276 emit_symbol($symbol) unless exists $skip{$skipsym};
280 if ($PLATFORM eq 'win32') {
304 Perl_init_thread_intern
331 elsif ($PLATFORM ne 'vms') {
338 if ($PLATFORM eq 'wince') {
353 PL_collation_standard
380 Perl_init_thread_intern
407 elsif ($PLATFORM eq 'aix') {
426 Perl_sys_intern_clear
438 if $define{'HAS_SIGNBIT'};
443 elsif ($PLATFORM eq 'os2') {
488 XS_Cwd_extLibpath_set
492 XS_Cwd_sys_is_absolute
493 XS_Cwd_sys_is_relative
495 XS_DynaLoader_mod2fname
496 XS_File__Copy_syscopy
500 Perl_Process_Messages
511 emit_symbols([qw(os2_cond_wait
516 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
518 elsif ($PLATFORM eq 'netware') {
542 Perl_init_thread_intern
567 Perl_sys_intern_clear
575 Perl_PerlIO_setlinebuf
576 Perl_PerlIO_set_ptrcnt
582 Perl_PerlIO_get_bufsiz
594 elsif ($PLATFORM eq 'vms') {
600 Perl_csighandler_init
603 Perl_fileify_dirspec_ts
604 Perl_fileify_dirspec_utf8
605 Perl_fileify_dirspec_utf8_ts
638 Perl_pathify_dirspec_ts
639 Perl_pathify_dirspec_utf8
640 Perl_pathify_dirspec_utf8_ts
648 Perl_rmsexpand_utf8_ts
650 Perl_sig_to_vmscondition
655 Perl_tounixpath_utf8_ts
659 Perl_tounixspec_utf8_ts
663 Perl_tovmspath_utf8_ts
667 Perl_tovmsspec_utf8_ts
669 Perl_vms_case_tolerant
698 if $define{'HAS_SIGNBIT'};
702 unless $define{'UNLINK_ALL_VERSIONS'};
705 unless ($define{'DEBUGGING'}) {
722 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
728 if ($define{'PERL_IMPLICIT_SYS'}) {
749 unless ($define{'PERL_OLD_COPY_ON_WRITE'}) {
755 unless ($define{'USE_REENTRANT_API'}) {
761 if ($define{'MYMALLOC'}) {
770 if ($define{'USE_ITHREADS'}) {
787 Perl_malloc_good_size
793 if ($define{'PERL_USE_SAFE_PUTENV'}) {
799 unless ($define{'USE_ITHREADS'}) {
805 # USE_5005THREADS symbols. Kept as reference for easier removal
824 Perl_new_struct_thread
825 Perl_per_thread_magicals
833 unless ($define{'USE_ITHREADS'}) {
839 PL_sharedsv_space_mutex
845 Perl_clone_params_del
846 Perl_clone_params_new
870 Perl_sharedsv_thrcnt_dec
871 Perl_sharedsv_thrcnt_inc
873 Perl_stashpv_hvname_match
874 Perl_regdupe_internal
879 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
889 Perl_load_module_nocontext
892 Perl_warner_nocontext
893 Perl_newSVpvf_nocontext
894 Perl_sv_catpvf_nocontext
895 Perl_sv_setpvf_nocontext
896 Perl_sv_catpvf_mg_nocontext
897 Perl_sv_setpvf_mg_nocontext
903 unless ($define{'PERL_IMPLICIT_SYS'}) {
910 unless ($define{'FAKE_THREADS'}) {
911 skip_symbols [qw(PL_curthr)];
914 unless ($define{'PL_OP_SLAB_ALLOC'}) {
924 unless ($define{'PERL_DEBUG_READONLY_OPS'}) {
931 unless ($define{'THREADS_HAVE_PIDS'}) {
932 skip_symbols [qw(PL_ppid)];
935 unless ($define{'PERL_NEED_APPCTX'}) {
941 unless ($define{'PERL_NEED_TIMESBASE'}) {
947 unless ($define{'DEBUG_LEAKING_SCALARS'}) {
953 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
958 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
963 if ($define{'SPRINTF_RETURNS_STRLEN'}) {
968 unless ($define{'PERL_USES_PL_PIDSTATUS'}) {
975 unless ($define{'PERL_TRACK_MEMPOOL'}) {
977 PL_memory_debug_header
981 if ($define{'PERL_MAD'}) {
1005 Perl_xmldump_vindent
1007 Perl_xmldump_packsubs
1014 Perl_do_pmop_xmldump
1021 unless ($define{'MULTIPLICITY'}) {
1024 PL_interp_size_5_16_0
1028 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1030 PL_global_struct_size
1034 unless ($define{'PERL_GLOBAL_STRUCT_PRIVATE'}) {
1041 unless ($define{'d_mmap'}) {
1047 if ($define{'d_sigaction'}) {
1054 # VMS does its own thing for these symbols.
1055 skip_symbols [qw(PL_sig_handlers_initted
1057 PL_sig_defaulting)];
1062 my $proc = shift || sub { "PL_$_[2]" };
1063 open(VARS,$file) || die "Cannot open $file: $!\n";
1066 # All symbols have a Perl_ prefix because that's what embed.h
1067 # sticks in front of them. The A?I?S?C? is strictly speaking
1069 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
1075 if ($define{'PERL_GLOBAL_STRUCT'}) {
1076 my $global = readvar($perlvars_h);
1077 skip_symbols $global;
1078 emit_symbol('Perl_GetVars');
1079 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
1081 skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
1084 # functions from *.sym files
1086 my @syms = ($global_sym, $globvar_sym);
1088 # Symbols that are the public face of the PerlIO layers implementation
1089 # These are in _addition to_ the public face of the abstraction
1090 # and need to be exported to allow XS modules to implement layers
1091 my @layer_syms = qw(
1099 PerlIOBase_noop_fail
1104 PerlIOBase_setlinebuf
1119 PerlIOBuf_set_ptrcnt
1141 Perl_PerlIO_clearerr
1143 Perl_PerlIO_context_layers
1149 Perl_PerlIO_get_base
1150 Perl_PerlIO_get_bufsiz
1156 Perl_PerlIO_set_ptrcnt
1157 Perl_PerlIO_setlinebuf
1165 if ($PLATFORM eq 'netware') {
1166 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
1169 if ($define{'USE_PERLIO'}) {
1170 # Export the symols that make up the PerlIO abstraction, regardless
1171 # of its implementation - read from a file
1172 push @syms, $perlio_sym;
1174 # This part is then dependent on how the abstraction is implemented
1175 if ($define{'USE_SFIO'}) {
1176 # Old legacy non-stdio "PerlIO"
1177 skip_symbols \@layer_syms;
1178 skip_symbols [qw(perlsio_binmode)];
1179 # SFIO defines most of the PerlIO routines as macros
1180 # So undo most of what $perlio_sym has just done - d'oh !
1181 # Perhaps it would be better to list the ones which do exist
1226 Perl_PerlIO_clearerr
1233 Perl_PerlIO_get_base
1234 Perl_PerlIO_get_bufsiz
1240 Perl_PerlIO_set_ptrcnt
1241 Perl_PerlIO_setlinebuf
1254 # PerlIO with layers - export implementation
1255 emit_symbols \@layer_syms;
1256 emit_symbols [qw(perlsio_binmode)];
1258 if ($define{'USE_ITHREADS'}) {
1270 # Skip the PerlIO layer symbols - although
1271 # nothing should have exported them anyway.
1272 skip_symbols \@layer_syms;
1280 PL_perlio_fd_refcnt_size
1283 # Also do NOT add abstraction symbols from $perlio_sym
1284 # abstraction is done as #define to stdio
1285 # Remaining remnants that _may_ be functions
1286 # are handled in <DATA>
1289 for my $syms (@syms) {
1290 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1292 next if (!/^[A-Za-z]/);
1293 # Functions have a Perl_ prefix
1294 # Variables have a PL_ prefix
1296 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1298 emit_symbol($symbol) unless exists $skip{$symbol};
1305 if ($define{'MULTIPLICITY'} && $define{PERL_GLOBAL_STRUCT}) {
1306 for my $f ($perlvars_h) {
1307 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1310 # XXX AIX seems to want the perlvars.h symbols, for some reason
1311 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1312 my $glob = readvar($perlvars_h);
1317 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1318 my $glob = readvar($perlvars_h);
1321 unless ($define{MULTIPLICITY}) {
1322 my $glob = readvar($intrpvar_h);
1330 return if $symbol !~ /^[A-Za-z_]/;
1331 return if $symbol =~ /^\#/;
1334 return if exists $skip{$symbol};
1335 emit_symbol($symbol);
1342 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1343 foreach my $symbol (qw(
1406 win32_getprotobyname
1407 win32_getprotobynumber
1436 win32_open_osfhandle
1507 try_symbol($symbol);
1509 if ($CCTYPE eq "BORLAND") {
1510 try_symbol('_matherr');
1513 elsif ($PLATFORM eq 'os2') {
1514 my (%mapped, @missing);
1515 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1516 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1517 close MAP or die 'Cannot close miniperl.map';
1519 @missing = grep { !exists $mapped{$_} }
1521 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1522 delete $export{$_} foreach @missing;
1524 elsif ($PLATFORM eq 'netware') {
1525 foreach my $symbol (qw(
1652 fnInsertHashListAddrs
1663 try_symbol($symbol);
1667 # records of type boot_module for statically linked modules (except Dynaloader)
1668 $static_ext =~ s/\//__/g;
1669 $static_ext =~ s/\bDynaLoader\b//;
1670 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1671 foreach my $symbol (@stat_mods)
1673 try_symbol($symbol);
1676 try_symbol("init_Win32CORE") if $static_ext =~ /\bWin32CORE\b/;
1678 # Now all symbols should be defined because
1679 # next we are going to output them.
1681 foreach my $symbol (sort keys %export) {
1682 output_symbol($symbol);
1685 if ($PLATFORM eq 'os2') {
1690 Perl_OS2_handler_install
1692 ; LAST_ORDINAL=$sym_ord
1699 $export{$symbol} = 1;
1704 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1705 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1706 print "\t$symbol\n";
1707 # XXX: binary compatibility between compilers is an exercise
1708 # in frustration :-(
1709 # if ($CCTYPE eq "BORLAND") {
1710 # # workaround Borland quirk by exporting both the straight
1711 # # name and a name with leading underscore. Note the
1712 # # alias *must* come after the symbol itself, if both
1713 # # are to be exported. (Linker bug?)
1714 # print "\t_$symbol\n";
1715 # print "\t$symbol = _$symbol\n";
1717 # elsif ($CCTYPE eq 'GCC') {
1718 # # Symbols have leading _ whole process is $%@"% slow
1719 # # so skip aliases for now
1720 # nprint "\t$symbol\n";
1723 # # for binary coexistence, export both the symbol and
1724 # # alias with leading underscore
1725 # print "\t$symbol\n";
1726 # print "\t_$symbol = $symbol\n";
1729 elsif ($PLATFORM eq 'os2') {
1730 printf qq( %-31s \@%s\n),
1731 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1732 printf qq( %-31s \@%s\n),
1733 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1734 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1735 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1737 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'vms') {
1740 elsif ($PLATFORM eq 'netware') {
1741 print "\t$symbol,\n";
1747 # Oddities from PerlIO