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'}) {
717 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
723 if ($define{'PERL_IMPLICIT_SYS'}) {
744 unless ($define{'PERL_OLD_COPY_ON_WRITE'}) {
750 unless ($define{'USE_REENTRANT_API'}) {
756 if ($define{'MYMALLOC'}) {
765 if ($define{'USE_ITHREADS'}) {
782 Perl_malloc_good_size
788 if ($define{'PERL_USE_SAFE_PUTENV'}) {
794 unless ($define{'USE_ITHREADS'}) {
800 # USE_5005THREADS symbols. Kept as reference for easier removal
819 Perl_new_struct_thread
820 Perl_per_thread_magicals
828 unless ($define{'USE_ITHREADS'}) {
834 PL_sharedsv_space_mutex
840 Perl_clone_params_del
841 Perl_clone_params_new
865 Perl_sharedsv_thrcnt_dec
866 Perl_sharedsv_thrcnt_inc
868 Perl_stashpv_hvname_match
869 Perl_regdupe_internal
874 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
884 Perl_load_module_nocontext
887 Perl_warner_nocontext
888 Perl_newSVpvf_nocontext
889 Perl_sv_catpvf_nocontext
890 Perl_sv_setpvf_nocontext
891 Perl_sv_catpvf_mg_nocontext
892 Perl_sv_setpvf_mg_nocontext
898 unless ($define{'PERL_IMPLICIT_SYS'}) {
905 unless ($define{'FAKE_THREADS'}) {
906 skip_symbols [qw(PL_curthr)];
909 unless ($define{'PL_OP_SLAB_ALLOC'}) {
919 unless ($define{'PERL_DEBUG_READONLY_OPS'}) {
926 unless ($define{'THREADS_HAVE_PIDS'}) {
927 skip_symbols [qw(PL_ppid)];
930 unless ($define{'PERL_NEED_APPCTX'}) {
936 unless ($define{'PERL_NEED_TIMESBASE'}) {
942 unless ($define{'DEBUG_LEAKING_SCALARS'}) {
948 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
953 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
958 if ($define{'SPRINTF_RETURNS_STRLEN'}) {
963 unless ($define{'PERL_USES_PL_PIDSTATUS'}) {
970 unless ($define{'PERL_TRACK_MEMPOOL'}) {
972 PL_memory_debug_header
976 if ($define{'PERL_MAD'}) {
1000 Perl_xmldump_vindent
1002 Perl_xmldump_packsubs
1009 Perl_do_pmop_xmldump
1016 unless ($define{'MULTIPLICITY'}) {
1019 PL_interp_size_5_16_0
1023 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1025 PL_global_struct_size
1029 unless ($define{'PERL_GLOBAL_STRUCT_PRIVATE'}) {
1036 unless ($define{'d_mmap'}) {
1042 if ($define{'d_sigaction'}) {
1049 # VMS does its own thing for these symbols.
1050 skip_symbols [qw(PL_sig_handlers_initted
1052 PL_sig_defaulting)];
1057 my $proc = shift || sub { "PL_$_[2]" };
1058 open(VARS,$file) || die "Cannot open $file: $!\n";
1061 # All symbols have a Perl_ prefix because that's what embed.h
1062 # sticks in front of them. The A?I?S?C? is strictly speaking
1064 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
1070 if ($define{'PERL_GLOBAL_STRUCT'}) {
1071 my $global = readvar($perlvars_h);
1072 skip_symbols $global;
1073 emit_symbol('Perl_GetVars');
1074 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
1076 skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
1079 # functions from *.sym files
1081 my @syms = ($global_sym, $globvar_sym);
1083 # Symbols that are the public face of the PerlIO layers implementation
1084 # These are in _addition to_ the public face of the abstraction
1085 # and need to be exported to allow XS modules to implement layers
1086 my @layer_syms = qw(
1094 PerlIOBase_noop_fail
1099 PerlIOBase_setlinebuf
1114 PerlIOBuf_set_ptrcnt
1136 Perl_PerlIO_clearerr
1138 Perl_PerlIO_context_layers
1144 Perl_PerlIO_get_base
1145 Perl_PerlIO_get_bufsiz
1151 Perl_PerlIO_set_ptrcnt
1152 Perl_PerlIO_setlinebuf
1160 if ($PLATFORM eq 'netware') {
1161 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
1164 if ($define{'USE_PERLIO'}) {
1165 # Export the symols that make up the PerlIO abstraction, regardless
1166 # of its implementation - read from a file
1167 push @syms, $perlio_sym;
1169 # This part is then dependent on how the abstraction is implemented
1170 if ($define{'USE_SFIO'}) {
1171 # Old legacy non-stdio "PerlIO"
1172 skip_symbols \@layer_syms;
1173 skip_symbols [qw(perlsio_binmode)];
1174 # SFIO defines most of the PerlIO routines as macros
1175 # So undo most of what $perlio_sym has just done - d'oh !
1176 # Perhaps it would be better to list the ones which do exist
1221 Perl_PerlIO_clearerr
1228 Perl_PerlIO_get_base
1229 Perl_PerlIO_get_bufsiz
1235 Perl_PerlIO_set_ptrcnt
1236 Perl_PerlIO_setlinebuf
1249 # PerlIO with layers - export implementation
1250 emit_symbols \@layer_syms;
1251 emit_symbols [qw(perlsio_binmode)];
1253 if ($define{'USE_ITHREADS'}) {
1265 # Skip the PerlIO layer symbols - although
1266 # nothing should have exported them anyway.
1267 skip_symbols \@layer_syms;
1275 PL_perlio_fd_refcnt_size
1278 # Also do NOT add abstraction symbols from $perlio_sym
1279 # abstraction is done as #define to stdio
1280 # Remaining remnants that _may_ be functions
1281 # are handled in <DATA>
1284 for my $syms (@syms) {
1285 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1287 next if (!/^[A-Za-z]/);
1288 # Functions have a Perl_ prefix
1289 # Variables have a PL_ prefix
1291 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1293 emit_symbol($symbol) unless exists $skip{$symbol};
1300 if ($define{'MULTIPLICITY'} && $define{PERL_GLOBAL_STRUCT}) {
1301 for my $f ($perlvars_h) {
1302 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1305 # XXX AIX seems to want the perlvars.h symbols, for some reason
1306 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1307 my $glob = readvar($perlvars_h);
1312 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1313 my $glob = readvar($perlvars_h);
1316 unless ($define{MULTIPLICITY}) {
1317 my $glob = readvar($intrpvar_h);
1325 return if $symbol !~ /^[A-Za-z_]/;
1326 return if $symbol =~ /^\#/;
1329 return if exists $skip{$symbol};
1330 emit_symbol($symbol);
1337 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1338 foreach my $symbol (qw(
1401 win32_getprotobyname
1402 win32_getprotobynumber
1431 win32_open_osfhandle
1502 try_symbol($symbol);
1504 if ($CCTYPE eq "BORLAND") {
1505 try_symbol('_matherr');
1508 elsif ($PLATFORM eq 'os2') {
1509 my (%mapped, @missing);
1510 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1511 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1512 close MAP or die 'Cannot close miniperl.map';
1514 @missing = grep { !exists $mapped{$_} }
1516 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1517 delete $export{$_} foreach @missing;
1519 elsif ($PLATFORM eq 'netware') {
1520 foreach my $symbol (qw(
1647 fnInsertHashListAddrs
1658 try_symbol($symbol);
1662 # records of type boot_module for statically linked modules (except Dynaloader)
1663 $static_ext =~ s/\//__/g;
1664 $static_ext =~ s/\bDynaLoader\b//;
1665 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1666 foreach my $symbol (@stat_mods)
1668 try_symbol($symbol);
1671 try_symbol("init_Win32CORE") if $static_ext =~ /\bWin32CORE\b/;
1673 # Now all symbols should be defined because
1674 # next we are going to output them.
1676 foreach my $symbol (sort keys %export) {
1677 output_symbol($symbol);
1680 if ($PLATFORM eq 'os2') {
1685 Perl_OS2_handler_install
1687 ; LAST_ORDINAL=$sym_ord
1694 $export{$symbol} = 1;
1699 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1700 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1701 print "\t$symbol\n";
1702 # XXX: binary compatibility between compilers is an exercise
1703 # in frustration :-(
1704 # if ($CCTYPE eq "BORLAND") {
1705 # # workaround Borland quirk by exporting both the straight
1706 # # name and a name with leading underscore. Note the
1707 # # alias *must* come after the symbol itself, if both
1708 # # are to be exported. (Linker bug?)
1709 # print "\t_$symbol\n";
1710 # print "\t$symbol = _$symbol\n";
1712 # elsif ($CCTYPE eq 'GCC') {
1713 # # Symbols have leading _ whole process is $%@"% slow
1714 # # so skip aliases for now
1715 # nprint "\t$symbol\n";
1718 # # for binary coexistence, export both the symbol and
1719 # # alias with leading underscore
1720 # print "\t$symbol\n";
1721 # print "\t_$symbol = $symbol\n";
1724 elsif ($PLATFORM eq 'os2') {
1725 printf qq( %-31s \@%s\n),
1726 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1727 printf qq( %-31s \@%s\n),
1728 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1729 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1730 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1732 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'vms') {
1735 elsif ($PLATFORM eq 'netware') {
1736 print "\t$symbol,\n";
1742 # Oddities from PerlIO