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);
41 my (%define, %ordinal);
45 if ($flag =~ s/^CC_FLAGS=/ /) {
46 for my $fflag ($flag =~ /(?:^|\s)-D(\S+)/g) {
47 $fflag .= '=1' unless $fflag =~ /^(\w+)=/;
48 $define{$1} = $2 if $fflag =~ /^(\w+)=(.+)$/;
52 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
53 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
54 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
55 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
56 if ($PLATFORM eq 'netware') {
57 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
61 my @PLATFORM = qw(aix win32 wince os2 netware vms);
63 @PLATFORM{@PLATFORM} = ();
65 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
66 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
68 if ($PLATFORM eq 'win32' or $PLATFORM eq 'wince' or $PLATFORM eq "aix") {
69 # Add the compile-time options that miniperl was built with to %define.
70 # On Win32 these are not the same options as perl itself will be built
71 # with since miniperl is built with a canned config (one of the win32/
72 # config_H.*) and none of the BUILDOPT's that are set in the makefiles,
73 # but they do include some #define's that are hard-coded in various
74 # source files and header files and don't include any BUILDOPT's that
75 # the user might have chosen to disable because the canned configs are
76 # minimal configs that don't include any of those options.
77 my $opts = ($PLATFORM eq 'wince' ? '-MCross' : ''); # for wince need Cross.pm to get Config.pm
79 $ENV{PERL5LIB} = join $Config{path_sep}, @INC;
80 my $cmd = "$^X $opts -V";
82 or die "Couldn't run [$cmd]: $!";
83 my($options) = $config =~ /^ Compile-time options: (.*?)\n^ \S/ms;
84 $options =~ s/\s+/ /g;
85 print STDERR "Options: ($options)\n";
86 foreach (split /\s+/, $options) {
91 my %exportperlmalloc =
93 Perl_malloc => "malloc",
95 Perl_realloc => "realloc",
96 Perl_calloc => "calloc",
99 my $exportperlmalloc = $PLATFORM eq 'os2';
101 my $config_sh = "config.sh";
102 my $config_h = "config.h";
103 my $intrpvar_h = "intrpvar.h";
104 my $perlvars_h = "perlvars.h";
105 my $global_sym = "global.sym";
106 my $globvar_sym = "globvar.sym";
107 my $perlio_sym = "perlio.sym";
110 if ($PLATFORM eq 'aix') {
113 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
114 $CCTYPE = "MSVC" unless defined $CCTYPE;
115 foreach ($intrpvar_h, $perlvars_h, $global_sym, $globvar_sym, $perlio_sym) {
120 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'netware') {
121 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
123 if (/^(?:ccflags|optimize)='(.+)'$/) {
125 $define{$1} = 1 while /-D(\w+)/g;
127 if (/^(d_(?:mmap|sigaction))='(.+)'$/) {
130 if ($PLATFORM eq 'os2') {
131 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
132 $ARCHNAME = $1 if /^archname='(.+)'$/;
133 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
135 if ($PLATFORM eq 'vms') {
136 $define{DEBUGGING} = 1 if /^usedebugging_perl='Y'$/;
137 $define{UNLINK_ALL_VERSIONS} = 1 if /^d_unlink_all_versions='define'$/;
142 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
143 open(CFG,"<..\\$config_sh") || die "Cannot open ..\\$config_sh: $!\n";
144 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
150 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
152 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
153 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
154 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
155 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
156 $define{$1} = 1 if /^\s*#\s*define\s+(HAS_\w+)\b/;
160 # perl.h logic duplication begins
162 if ($define{PERL_IMPLICIT_SYS}) {
163 $define{PL_OP_SLAB_ALLOC} = 1;
166 if ($define{USE_ITHREADS}) {
167 if (!$define{MULTIPLICITY}) {
168 $define{MULTIPLICITY} = 1;
172 $define{PERL_IMPLICIT_CONTEXT} ||=
173 $define{USE_ITHREADS} ||
174 $define{MULTIPLICITY} ;
176 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
177 $define{USE_REENTRANT_API} = 1;
180 # perl.h logic duplication ends
184 print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n";
186 if ($PLATFORM =~ /^win(?:32|ce)$/) {
187 (my $dll = ($define{PERL_DLL} || "perl515")) =~ s/\.dll$//i;
188 print "LIBRARY $dll\n";
189 # The DESCRIPTION module definition file statement is not supported
191 if ($CCTYPE =~ /^(?:MSVC60|GCC|BORLAND)$/) {
192 print "DESCRIPTION 'Perl interpreter'\n";
195 if ($define{PERL_IMPLICIT_SYS}) {
196 output_symbol("perl_get_host_info");
197 output_symbol("perl_alloc_override");
199 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
200 output_symbol("perl_clone_host");
203 elsif ($PLATFORM eq 'os2') {
204 if (open my $fh, '<', 'perl5.def') {
206 last if /^\s*EXPORTS\b/;
209 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
210 # This allows skipping ordinals which were used in older versions
211 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
213 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
215 (my $v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
216 $v .= '-thread' if $ARCHNAME =~ /-thread/;
217 (my $dll = $define{PERL_DLL}) =~ s/\.dll$//i;
218 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
219 my $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
220 $d = substr($d, 0, 249) . "...'" if length $d > 253;
222 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
226 DATA LOADONCALL NONSHARED MULTIPLE
230 elsif ($PLATFORM eq 'aix') {
231 my $OSVER = `uname -v`;
233 my $OSREL = `uname -r`;
235 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
241 elsif ($PLATFORM eq 'netware') {
242 if ($FILETYPE eq 'def') {
243 print "LIBRARY perl515\n";
244 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
247 if ($define{PERL_IMPLICIT_SYS}) {
248 output_symbol("perl_get_host_info");
249 output_symbol("perl_alloc_override");
250 output_symbol("perl_clone_host");
259 foreach my $symbol (@$list) {
266 foreach my $symbol (@$list) {
267 my $skipsym = $symbol;
269 if ($define{MULTIPLICITY}) {
270 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
272 emit_symbol($symbol) unless exists $skip{$skipsym};
276 if ($PLATFORM eq 'win32') {
300 Perl_init_thread_intern
327 elsif ($PLATFORM ne 'vms') {
334 if ($PLATFORM eq 'wince') {
349 PL_collation_standard
376 Perl_init_thread_intern
403 elsif ($PLATFORM eq 'aix') {
422 Perl_sys_intern_clear
434 if $define{'HAS_SIGNBIT'};
439 elsif ($PLATFORM eq 'os2') {
484 XS_Cwd_extLibpath_set
488 XS_Cwd_sys_is_absolute
489 XS_Cwd_sys_is_relative
491 XS_DynaLoader_mod2fname
492 XS_File__Copy_syscopy
496 Perl_Process_Messages
507 emit_symbols([qw(os2_cond_wait
512 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
514 elsif ($PLATFORM eq 'netware') {
538 Perl_init_thread_intern
563 Perl_sys_intern_clear
571 Perl_PerlIO_setlinebuf
572 Perl_PerlIO_set_ptrcnt
578 Perl_PerlIO_get_bufsiz
590 elsif ($PLATFORM eq 'vms') {
596 Perl_csighandler_init
599 Perl_fileify_dirspec_ts
600 Perl_fileify_dirspec_utf8
601 Perl_fileify_dirspec_utf8_ts
634 Perl_pathify_dirspec_ts
635 Perl_pathify_dirspec_utf8
636 Perl_pathify_dirspec_utf8_ts
644 Perl_rmsexpand_utf8_ts
646 Perl_sig_to_vmscondition
651 Perl_tounixpath_utf8_ts
655 Perl_tounixspec_utf8_ts
659 Perl_tovmspath_utf8_ts
663 Perl_tovmsspec_utf8_ts
665 Perl_vms_case_tolerant
694 if $define{'HAS_SIGNBIT'};
698 unless $define{'UNLINK_ALL_VERSIONS'};
701 unless ($define{'DEBUGGING'}) {
718 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
724 if ($define{'PERL_IMPLICIT_SYS'}) {
745 unless ($define{'PERL_OLD_COPY_ON_WRITE'}) {
751 unless ($define{'USE_REENTRANT_API'}) {
757 if ($define{'MYMALLOC'}) {
766 if ($define{'USE_ITHREADS'}) {
783 Perl_malloc_good_size
789 if ($define{'PERL_USE_SAFE_PUTENV'}) {
795 unless ($define{'USE_ITHREADS'}) {
801 # USE_5005THREADS symbols. Kept as reference for easier removal
820 Perl_new_struct_thread
821 Perl_per_thread_magicals
829 unless ($define{'USE_ITHREADS'}) {
835 PL_sharedsv_space_mutex
841 Perl_clone_params_del
842 Perl_clone_params_new
866 Perl_sharedsv_thrcnt_dec
867 Perl_sharedsv_thrcnt_inc
869 Perl_stashpv_hvname_match
870 Perl_regdupe_internal
875 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
885 Perl_load_module_nocontext
888 Perl_warner_nocontext
889 Perl_newSVpvf_nocontext
890 Perl_sv_catpvf_nocontext
891 Perl_sv_setpvf_nocontext
892 Perl_sv_catpvf_mg_nocontext
893 Perl_sv_setpvf_mg_nocontext
899 unless ($define{'PERL_IMPLICIT_SYS'}) {
906 unless ($define{'FAKE_THREADS'}) {
907 skip_symbols [qw(PL_curthr)];
910 unless ($define{'PL_OP_SLAB_ALLOC'}) {
920 unless ($define{'PERL_DEBUG_READONLY_OPS'}) {
927 unless ($define{'THREADS_HAVE_PIDS'}) {
928 skip_symbols [qw(PL_ppid)];
931 unless ($define{'PERL_NEED_APPCTX'}) {
937 unless ($define{'PERL_NEED_TIMESBASE'}) {
943 unless ($define{'DEBUG_LEAKING_SCALARS'}) {
949 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
954 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
959 if ($define{'SPRINTF_RETURNS_STRLEN'}) {
964 unless ($define{'PERL_USES_PL_PIDSTATUS'}) {
971 unless ($define{'PERL_TRACK_MEMPOOL'}) {
973 PL_memory_debug_header
977 if ($define{'PERL_MAD'}) {
1001 Perl_xmldump_vindent
1003 Perl_xmldump_packsubs
1010 Perl_do_pmop_xmldump
1017 unless ($define{'MULTIPLICITY'}) {
1020 PL_interp_size_5_16_0
1024 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1026 PL_global_struct_size
1030 unless ($define{'PERL_GLOBAL_STRUCT_PRIVATE'}) {
1037 unless ($define{'d_mmap'}) {
1043 if ($define{'d_sigaction'}) {
1050 # VMS does its own thing for these symbols.
1051 skip_symbols [qw(PL_sig_handlers_initted
1053 PL_sig_defaulting)];
1058 my $proc = shift || sub { "PL_$_[2]" };
1059 open(VARS,$file) || die "Cannot open $file: $!\n";
1062 # All symbols have a Perl_ prefix because that's what embed.h
1063 # sticks in front of them. The A?I?S?C? is strictly speaking
1065 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
1071 if ($define{'PERL_GLOBAL_STRUCT'}) {
1072 my $global = readvar($perlvars_h);
1073 skip_symbols $global;
1074 emit_symbol('Perl_GetVars');
1075 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
1077 skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
1080 # functions from *.sym files
1082 my @syms = ($global_sym, $globvar_sym);
1084 # Symbols that are the public face of the PerlIO layers implementation
1085 # These are in _addition to_ the public face of the abstraction
1086 # and need to be exported to allow XS modules to implement layers
1087 my @layer_syms = qw(
1095 PerlIOBase_noop_fail
1100 PerlIOBase_setlinebuf
1115 PerlIOBuf_set_ptrcnt
1137 Perl_PerlIO_clearerr
1139 Perl_PerlIO_context_layers
1145 Perl_PerlIO_get_base
1146 Perl_PerlIO_get_bufsiz
1152 Perl_PerlIO_set_ptrcnt
1153 Perl_PerlIO_setlinebuf
1161 if ($PLATFORM eq 'netware') {
1162 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
1165 if ($define{'USE_PERLIO'}) {
1166 # Export the symols that make up the PerlIO abstraction, regardless
1167 # of its implementation - read from a file
1168 push @syms, $perlio_sym;
1170 # This part is then dependent on how the abstraction is implemented
1171 if ($define{'USE_SFIO'}) {
1172 # Old legacy non-stdio "PerlIO"
1173 skip_symbols \@layer_syms;
1174 skip_symbols [qw(perlsio_binmode)];
1175 # SFIO defines most of the PerlIO routines as macros
1176 # So undo most of what $perlio_sym has just done - d'oh !
1177 # Perhaps it would be better to list the ones which do exist
1222 Perl_PerlIO_clearerr
1229 Perl_PerlIO_get_base
1230 Perl_PerlIO_get_bufsiz
1236 Perl_PerlIO_set_ptrcnt
1237 Perl_PerlIO_setlinebuf
1250 # PerlIO with layers - export implementation
1251 emit_symbols \@layer_syms;
1252 emit_symbols [qw(perlsio_binmode)];
1254 if ($define{'USE_ITHREADS'}) {
1266 # Skip the PerlIO layer symbols - although
1267 # nothing should have exported them anyway.
1268 skip_symbols \@layer_syms;
1276 PL_perlio_fd_refcnt_size
1279 # Also do NOT add abstraction symbols from $perlio_sym
1280 # abstraction is done as #define to stdio
1281 # Remaining remnants that _may_ be functions
1282 # are handled in <DATA>
1285 for my $syms (@syms) {
1286 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1288 next if (!/^[A-Za-z]/);
1289 # Functions have a Perl_ prefix
1290 # Variables have a PL_ prefix
1292 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1294 emit_symbol($symbol) unless exists $skip{$symbol};
1301 if ($define{'MULTIPLICITY'} && $define{PERL_GLOBAL_STRUCT}) {
1302 for my $f ($perlvars_h) {
1303 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1306 # XXX AIX seems to want the perlvars.h symbols, for some reason
1307 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1308 my $glob = readvar($perlvars_h);
1313 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1314 my $glob = readvar($perlvars_h);
1317 unless ($define{MULTIPLICITY}) {
1318 my $glob = readvar($intrpvar_h);
1326 return if $symbol !~ /^[A-Za-z_]/;
1327 return if $symbol =~ /^\#/;
1330 return if exists $skip{$symbol};
1331 emit_symbol($symbol);
1338 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1339 foreach my $symbol (qw(
1402 win32_getprotobyname
1403 win32_getprotobynumber
1432 win32_open_osfhandle
1503 try_symbol($symbol);
1505 if ($CCTYPE eq "BORLAND") {
1506 try_symbol('_matherr');
1509 elsif ($PLATFORM eq 'os2') {
1510 my (%mapped, @missing);
1511 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1512 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1513 close MAP or die 'Cannot close miniperl.map';
1515 @missing = grep { !exists $mapped{$_} }
1517 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1518 delete $export{$_} foreach @missing;
1520 elsif ($PLATFORM eq 'netware') {
1521 foreach my $symbol (qw(
1648 fnInsertHashListAddrs
1659 try_symbol($symbol);
1663 # records of type boot_module for statically linked modules (except Dynaloader)
1664 $static_ext =~ s/\//__/g;
1665 $static_ext =~ s/\bDynaLoader\b//;
1666 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1667 foreach my $symbol (@stat_mods)
1669 try_symbol($symbol);
1672 try_symbol("init_Win32CORE") if $static_ext =~ /\bWin32CORE\b/;
1674 # Now all symbols should be defined because
1675 # next we are going to output them.
1677 foreach my $symbol (sort keys %export) {
1678 output_symbol($symbol);
1681 if ($PLATFORM eq 'os2') {
1686 Perl_OS2_handler_install
1688 ; LAST_ORDINAL=$sym_ord
1695 $export{$symbol} = 1;
1700 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1701 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1702 print "\t$symbol\n";
1703 # XXX: binary compatibility between compilers is an exercise
1704 # in frustration :-(
1705 # if ($CCTYPE eq "BORLAND") {
1706 # # workaround Borland quirk by exporting both the straight
1707 # # name and a name with leading underscore. Note the
1708 # # alias *must* come after the symbol itself, if both
1709 # # are to be exported. (Linker bug?)
1710 # print "\t_$symbol\n";
1711 # print "\t$symbol = _$symbol\n";
1713 # elsif ($CCTYPE eq 'GCC') {
1714 # # Symbols have leading _ whole process is $%@"% slow
1715 # # so skip aliases for now
1716 # nprint "\t$symbol\n";
1719 # # for binary coexistence, export both the symbol and
1720 # # alias with leading underscore
1721 # print "\t$symbol\n";
1722 # print "\t_$symbol = $symbol\n";
1725 elsif ($PLATFORM eq 'os2') {
1726 printf qq( %-31s \@%s\n),
1727 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1728 printf qq( %-31s \@%s\n),
1729 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1730 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1731 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1733 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'vms') {
1736 elsif ($PLATFORM eq 'netware') {
1737 print "\t$symbol,\n";
1743 # Oddities from PerlIO