don't write along symlinks into a read only source tree (was Re: [ID 20010129.006...
[p5sagit/p5-mst-13.2.git] / makedef.pl
1 #
2 # Create the export list for perl.
3 #
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 #
7 # reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
8 # On OS/2 reads miniperl.map as well
9
10 my $PLATFORM;
11 my $CCTYPE;
12
13 my %bincompat5005 =
14       (
15        Perl_call_atexit         =>      "perl_atexit",
16        Perl_eval_sv             =>      "perl_eval_sv",
17        Perl_eval_pv             =>      "perl_eval_pv",
18        Perl_call_argv           =>      "perl_call_argv",
19        Perl_call_method         =>      "perl_call_method",
20        Perl_call_pv             =>      "perl_call_pv",
21        Perl_call_sv             =>      "perl_call_sv",
22        Perl_get_av              =>      "perl_get_av",
23        Perl_get_cv              =>      "perl_get_cv",
24        Perl_get_hv              =>      "perl_get_hv",
25        Perl_get_sv              =>      "perl_get_sv",
26        Perl_init_i18nl10n       =>      "perl_init_i18nl10n",
27        Perl_init_i18nl14n       =>      "perl_init_i18nl14n",
28        Perl_new_collate         =>      "perl_new_collate",
29        Perl_new_ctype           =>      "perl_new_ctype",
30        Perl_new_numeric         =>      "perl_new_numeric",
31        Perl_require_pv          =>      "perl_require_pv",
32        Perl_safesyscalloc       =>      "Perl_safecalloc",
33        Perl_safesysfree         =>      "Perl_safefree",
34        Perl_safesysmalloc       =>      "Perl_safemalloc",
35        Perl_safesysrealloc      =>      "Perl_saferealloc",
36        Perl_set_numeric_local   =>      "perl_set_numeric_local",
37        Perl_set_numeric_standard  =>    "perl_set_numeric_standard",
38        Perl_malloc              =>      "malloc",
39        Perl_mfree               =>      "free",
40        Perl_realloc             =>      "realloc",
41        Perl_calloc              =>      "calloc",
42       );
43
44 my $bincompat5005 = join("|", keys %bincompat5005);
45
46 while (@ARGV) {
47     my $flag = shift;
48     $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
49     $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
50     $CCTYPE   = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
51     $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
52 }
53
54 my @PLATFORM = qw(aix win32 os2 MacOS);
55 my %PLATFORM;
56 @PLATFORM{@PLATFORM} = ();
57
58 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
59 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n"; 
60
61 my $config_sh   = "config.sh";
62 my $config_h    = "config.h";
63 my $thrdvar_h   = "thrdvar.h";
64 my $intrpvar_h  = "intrpvar.h";
65 my $perlvars_h  = "perlvars.h";
66 my $global_sym  = "global.sym";
67 my $pp_sym      = "pp.sym";
68 my $globvar_sym = "globvar.sym";
69 my $perlio_sym  = "perlio.sym";
70
71 if ($PLATFORM eq 'aix') { 
72     # Nothing for now.
73 }
74 elsif ($PLATFORM eq 'win32') {
75     $CCTYPE = "MSVC" unless defined $CCTYPE;
76     foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
77                 $pp_sym, $globvar_sym, $perlio_sym) {
78         s!^!..\\!;
79     }
80 }
81 elsif ($PLATFORM eq 'MacOS') {
82     foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
83                 $pp_sym, $globvar_sym, $perlio_sym) {
84         s!^!::!;
85     }
86 }
87
88 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS') {
89     open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
90     while (<CFG>) {
91         if (/^(?:ccflags|optimize)='(.+)'$/) {
92             $_ = $1;
93             $define{$1} = 1 while /-D(\w+)/g;
94         }
95         if ($PLATFORM eq 'os2') {
96             $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
97             $ARCHNAME =    $1 if /^(?:archname)='(.+)'$/;
98         }
99     }
100     close(CFG);
101 }
102
103 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
104 while (<CFG>) {
105     $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
106     $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
107     $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
108     $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
109 }
110 close(CFG);
111
112 # perl.h logic duplication begins
113
114 if ($define{USE_ITHREADS}) {
115     if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
116         $define{MULTIPLICITY} = 1;
117     }
118 }
119
120 $define{PERL_IMPLICIT_CONTEXT} ||=
121     $define{USE_ITHREADS} ||
122     $define{USE_5005THREADS}  ||
123     $define{MULTIPLICITY} ;
124
125 if ($define{PERL_CAPI}) {
126     delete $define{PERL_OBJECT};
127     $define{MULTIPLICITY} = 1; 
128     $define{PERL_IMPLICIT_CONTEXT} = 1;
129     $define{PERL_IMPLICIT_SYS}     = 1;
130 }
131
132 if ($define{PERL_OBJECT}) {
133     $define{PERL_IMPLICIT_CONTEXT} = 1;
134     $define{PERL_IMPLICIT_SYS}     = 1;
135 }
136
137 # perl.h logic duplication ends
138
139 if ($PLATFORM eq 'win32') {
140     warn join(' ',keys %define)."\n";
141     print "LIBRARY Perl57\n";
142     print "DESCRIPTION 'Perl interpreter'\n";
143     print "EXPORTS\n";
144     if ($define{PERL_IMPLICIT_SYS}) {
145         output_symbol("perl_get_host_info");
146         output_symbol("perl_alloc_override");
147     }
148 }
149 elsif ($PLATFORM eq 'os2') {
150     ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
151     $v .= '-thread' if $ARCHNAME =~ /-thread/;
152     ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
153     print <<"---EOP---";
154 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
155 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter'
156 STACKSIZE 32768
157 CODE LOADONCALL
158 DATA LOADONCALL NONSHARED MULTIPLE
159 EXPORTS
160 ---EOP---
161 }
162 elsif ($PLATFORM eq 'aix') {
163     print "#!\n";
164 }
165
166 my %skip;
167 my %export;
168
169 sub skip_symbols {
170     my $list = shift;
171     foreach my $symbol (@$list) {
172         $skip{$symbol} = 1;
173     }
174 }
175
176 sub emit_symbols {
177     my $list = shift;
178     foreach my $symbol (@$list) {
179         my $skipsym = $symbol;
180         # XXX hack
181         if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
182             $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
183         }
184         emit_symbol($symbol) unless exists $skip{$skipsym};
185     }
186 }
187
188 if ($PLATFORM eq 'win32') {
189     skip_symbols [qw(
190                      PL_statusvalue_vms
191                      PL_archpat_auto
192                      PL_cryptseen
193                      PL_DBcv
194                      PL_generation
195                      PL_lastgotoprobe
196                      PL_linestart
197                      PL_modcount
198                      PL_pending_ident
199                      PL_sortcxix
200                      PL_sublex_info
201                      PL_timesbuf
202                      main
203                      Perl_ErrorNo
204                      Perl_GetVars
205                      Perl_do_exec3
206                      Perl_do_ipcctl
207                      Perl_do_ipcget
208                      Perl_do_msgrcv
209                      Perl_do_msgsnd
210                      Perl_do_semop
211                      Perl_do_shmio
212                      Perl_dump_fds
213                      Perl_init_thread_intern
214                      Perl_my_bzero
215                      Perl_my_htonl
216                      Perl_my_ntohl
217                      Perl_my_swap
218                      Perl_my_chsize
219                      Perl_same_dirent
220                      Perl_setenv_getix
221                      Perl_unlnk
222                      Perl_watch
223                      Perl_safexcalloc
224                      Perl_safexmalloc
225                      Perl_safexfree
226                      Perl_safexrealloc
227                      Perl_my_memcmp
228                      Perl_my_memset
229                      PL_cshlen
230                      PL_cshname
231                      PL_opsave
232                      Perl_do_exec
233                      Perl_getenv_len
234                      Perl_my_pclose
235                      Perl_my_popen
236                      )];
237 }
238 elsif ($PLATFORM eq 'aix') {
239     skip_symbols([qw(
240                      Perl_dump_fds
241                      Perl_ErrorNo
242                      Perl_GetVars
243                      Perl_my_bcopy
244                      Perl_my_bzero
245                      Perl_my_chsize
246                      Perl_my_htonl
247                      Perl_my_memcmp
248                      Perl_my_memset
249                      Perl_my_ntohl
250                      Perl_my_swap
251                      Perl_safexcalloc
252                      Perl_safexfree
253                      Perl_safexmalloc
254                      Perl_safexrealloc
255                      Perl_same_dirent
256                      Perl_unlnk
257                      Perl_sys_intern_clear
258                      Perl_sys_intern_dup
259                      Perl_sys_intern_init
260                      PL_cryptseen
261                      PL_opsave
262                      PL_statusvalue_vms
263                      PL_sys_intern
264                      )]);
265 }
266 elsif ($PLATFORM eq 'os2') {
267     emit_symbols([qw(
268                     ctermid
269                     get_sysinfo
270                     Perl_OS2_init
271                     OS2_Perl_data
272                     dlopen
273                     dlsym
274                     dlerror
275                     dlclose
276                     my_tmpfile
277                     my_tmpnam
278                     my_flock
279                     malloc_mutex
280                     threads_mutex
281                     nthreads
282                     nthreads_cond
283                     os2_cond_wait
284                     os2_stat
285                     pthread_join
286                     pthread_create
287                     pthread_detach
288                     XS_Cwd_change_drive
289                     XS_Cwd_current_drive
290                     XS_Cwd_extLibpath
291                     XS_Cwd_extLibpath_set
292                     XS_Cwd_sys_abspath
293                     XS_Cwd_sys_chdir
294                     XS_Cwd_sys_cwd
295                     XS_Cwd_sys_is_absolute
296                     XS_Cwd_sys_is_relative
297                     XS_Cwd_sys_is_rooted
298                     XS_DynaLoader_mod2fname
299                     XS_File__Copy_syscopy
300                     Perl_Register_MQ
301                     Perl_Deregister_MQ
302                     Perl_Serve_Messages
303                     Perl_Process_Messages
304                     init_PMWIN_entries
305                     PMWIN_entries
306                     Perl_hab_GET
307                     )]);
308 }
309 elsif ($PLATFORM eq 'MacOS') {
310     skip_symbols [qw(
311                     Perl_GetVars
312                     PL_cryptseen
313                     PL_cshlen
314                     PL_cshname
315                     PL_statusvalue_vms
316                     PL_sys_intern
317                     PL_opsave
318                     PL_timesbuf
319                     Perl_dump_fds
320                     Perl_my_bcopy
321                     Perl_my_bzero
322                     Perl_my_chsize
323                     Perl_my_htonl
324                     Perl_my_memcmp
325                     Perl_my_memset
326                     Perl_my_ntohl
327                     Perl_my_swap
328                     Perl_safexcalloc
329                     Perl_safexfree
330                     Perl_safexmalloc
331                     Perl_safexrealloc
332                     Perl_unlnk
333                     Perl_sys_intern_clear
334                     Perl_sys_intern_init
335                     )];
336 }
337
338
339 unless ($define{'DEBUGGING'}) {
340     skip_symbols [qw(
341                     Perl_deb_growlevel
342                     Perl_debop
343                     Perl_debprofdump
344                     Perl_debstack
345                     Perl_debstackptrs
346                     Perl_runops_debug
347                     Perl_sv_peek
348                     PL_block_type
349                     PL_watchaddr
350                     PL_watchok
351                     )];
352 }
353
354 if ($define{'PERL_IMPLICIT_SYS'}) {
355     skip_symbols [qw(
356                     Perl_getenv_len
357                     Perl_my_popen
358                     Perl_my_pclose
359                     )];
360 }
361 else {
362     skip_symbols [qw(
363                     PL_Mem
364                     PL_MemShared
365                     PL_MemParse
366                     PL_Env
367                     PL_StdIO
368                     PL_LIO
369                     PL_Dir
370                     PL_Sock
371                     PL_Proc
372                     )];
373 }
374
375 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
376     skip_symbols [qw(
377                     PL_protect
378                     Perl_default_protect
379                     Perl_vdefault_protect
380                     )];
381 }
382
383 if ($define{'MYMALLOC'}) {
384     emit_symbols [qw(
385                     Perl_dump_mstats
386                     Perl_get_mstats
387                     Perl_malloc
388                     Perl_mfree
389                     Perl_realloc
390                     Perl_calloc
391                     )];
392     if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
393         emit_symbols [qw(
394                         PL_malloc_mutex
395                         )];
396     }
397     else {
398         skip_symbols [qw(
399                         PL_malloc_mutex
400                         )];
401     }
402 }
403 else {
404     skip_symbols [qw(
405                     PL_malloc_mutex
406                     Perl_dump_mstats
407                     Perl_get_mstats
408                     Perl_malloc
409                     Perl_mfree
410                     Perl_realloc
411                     Perl_calloc
412                     Perl_malloced_size
413                     )];
414 }
415
416 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
417     skip_symbols [qw(
418                     PL_thr_key
419                     )];
420 }
421
422 unless ($define{'USE_5005THREADS'}) {
423     skip_symbols [qw(
424                     PL_sv_mutex
425                     PL_strtab_mutex
426                     PL_svref_mutex
427                     PL_cred_mutex
428                     PL_eval_mutex
429                     PL_fdpid_mutex
430                     PL_sv_lock_mutex
431                     PL_eval_cond
432                     PL_eval_owner
433                     PL_threads_mutex
434                     PL_nthreads
435                     PL_nthreads_cond
436                     PL_threadnum
437                     PL_threadsv_names
438                     PL_thrsv
439                     PL_vtbl_mutex
440                     Perl_condpair_magic
441                     Perl_new_struct_thread
442                     Perl_per_thread_magicals
443                     Perl_thread_create
444                     Perl_find_threadsv
445                     Perl_unlock_condpair
446                     Perl_magic_mutexfree
447                     Perl_sv_lock
448                     )];
449 }
450
451 unless ($define{'USE_ITHREADS'}) {
452     skip_symbols [qw(
453                     PL_ptr_table
454                     PL_op_mutex
455                     Perl_dirp_dup
456                     Perl_cx_dup
457                     Perl_si_dup
458                     Perl_any_dup
459                     Perl_ss_dup
460                     Perl_fp_dup
461                     Perl_gp_dup
462                     Perl_he_dup
463                     Perl_mg_dup
464                     Perl_re_dup
465                     Perl_sv_dup
466                     Perl_sys_intern_dup
467                     Perl_ptr_table_fetch
468                     Perl_ptr_table_new
469                     Perl_ptr_table_clear
470                     Perl_ptr_table_free
471                     Perl_ptr_table_split
472                     Perl_ptr_table_store
473                     perl_clone
474                     perl_clone_using
475                     )];
476 }
477
478 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
479     skip_symbols [qw(
480                     Perl_croak_nocontext
481                     Perl_die_nocontext
482                     Perl_deb_nocontext
483                     Perl_form_nocontext
484                     Perl_load_module_nocontext
485                     Perl_mess_nocontext
486                     Perl_warn_nocontext
487                     Perl_warner_nocontext
488                     Perl_newSVpvf_nocontext
489                     Perl_sv_catpvf_nocontext
490                     Perl_sv_setpvf_nocontext
491                     Perl_sv_catpvf_mg_nocontext
492                     Perl_sv_setpvf_mg_nocontext
493                     )];
494 }
495
496 unless ($define{'PERL_IMPLICIT_SYS'}) {
497     skip_symbols [qw(
498                     perl_alloc_using
499                     perl_clone_using
500                     )];
501 }
502
503 unless ($define{'FAKE_THREADS'}) {
504     skip_symbols [qw(PL_curthr)];
505 }
506
507 sub readvar {
508     my $file = shift;
509     my $proc = shift || sub { "PL_$_[2]" };
510     open(VARS,$file) || die "Cannot open $file: $!\n";
511     my @syms;
512     while (<VARS>) {
513         # All symbols have a Perl_ prefix because that's what embed.h
514         # sticks in front of them.
515         push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
516     } 
517     close(VARS); 
518     return \@syms;
519 }
520
521 if ($define{'USE_5005THREADS'}) {
522     my $thrd = readvar($thrdvar_h);
523     skip_symbols $thrd;
524 }
525
526 if ($define{'PERL_GLOBAL_STRUCT'}) {
527     my $global = readvar($perlvars_h);
528     skip_symbols $global;
529     emit_symbol('Perl_GetVars');
530     emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
531 }
532
533 # functions from *.sym files
534
535 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
536
537 if ($define{'USE_PERLIO'}) {
538     push @syms, $perlio_sym;
539     if ($define{'USE_SFIO'}) {
540         # SFIO defines most of the PerlIO routines as macros
541         skip_symbols [qw(
542                          PerlIO_canset_cnt
543                          PerlIO_clearerr
544                          PerlIO_close
545                          PerlIO_eof
546                          PerlIO_error
547                          PerlIO_exportFILE
548                          PerlIO_fast_gets
549                          PerlIO_fdopen
550                          PerlIO_fileno
551                          PerlIO_findFILE
552                          PerlIO_flush
553                          PerlIO_get_base
554                          PerlIO_get_bufsiz
555                          PerlIO_get_cnt
556                          PerlIO_get_ptr
557                          PerlIO_getc
558                          PerlIO_getname
559                          PerlIO_has_base
560                          PerlIO_has_cntptr
561                          PerlIO_importFILE
562                          PerlIO_open
563                          PerlIO_printf
564                          PerlIO_putc
565                          PerlIO_puts
566                          PerlIO_read
567                          PerlIO_releaseFILE
568                          PerlIO_reopen
569                          PerlIO_rewind
570                          PerlIO_seek
571                          PerlIO_set_cnt
572                          PerlIO_set_ptrcnt
573                          PerlIO_setlinebuf
574                          PerlIO_sprintf
575                          PerlIO_stderr
576                          PerlIO_stdin
577                          PerlIO_stdout
578                          PerlIO_stdoutf
579                          PerlIO_tell
580                          PerlIO_ungetc
581                          PerlIO_vprintf
582                          PerlIO_write
583                          )];
584     }
585 }
586
587 for my $syms (@syms) {
588     open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
589     while (<GLOBAL>) {
590         next if (!/^[A-Za-z]/);
591         # Functions have a Perl_ prefix
592         # Variables have a PL_ prefix
593         chomp($_);
594         my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
595         $symbol .= $_;
596         emit_symbol($symbol) unless exists $skip{$symbol};
597     }
598     close(GLOBAL);
599 }
600
601 # variables
602
603 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
604     for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
605         my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
606         emit_symbols $glob;
607     }
608     # XXX AIX seems to want the perlvars.h symbols, for some reason
609     if ($PLATFORM eq 'aix') {
610         my $glob = readvar($perlvars_h);
611         emit_symbols $glob;
612     }
613 }
614 else {
615     unless ($define{'PERL_GLOBAL_STRUCT'}) {
616         my $glob = readvar($perlvars_h);
617         emit_symbols $glob;
618     } 
619     unless ($define{'MULTIPLICITY'}) {
620         my $glob = readvar($intrpvar_h);
621         emit_symbols $glob;
622     } 
623     unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
624         my $glob = readvar($thrdvar_h);
625         emit_symbols $glob;
626     } 
627 }
628
629 sub try_symbol {
630     my $symbol = shift;
631
632     return if $symbol !~ /^[A-Za-z]/;
633     return if $symbol =~ /^\#/;
634     $symbol =~s/\r//g;
635     chomp($symbol);
636     return if exists $skip{$symbol};
637     emit_symbol($symbol);
638 }
639
640 while (<DATA>) {
641     try_symbol($_);
642 }
643
644 if ($PLATFORM eq 'win32') {
645     foreach my $symbol (qw(
646                             setuid
647                             setgid
648                             boot_DynaLoader
649                             Perl_init_os_extras
650                             Perl_thread_create
651                             Perl_win32_init
652                             RunPerl
653                             win32_errno
654                             win32_environ
655                             win32_abort
656                             win32_fstat
657                             win32_stat
658                             win32_pipe
659                             win32_popen
660                             win32_pclose
661                             win32_rename
662                             win32_setmode
663                             win32_lseek
664                             win32_tell
665                             win32_dup
666                             win32_dup2
667                             win32_open
668                             win32_close
669                             win32_eof
670                             win32_read
671                             win32_write
672                             win32_spawnvp
673                             win32_mkdir
674                             win32_rmdir
675                             win32_chdir
676                             win32_flock
677                             win32_execv
678                             win32_execvp
679                             win32_htons
680                             win32_ntohs
681                             win32_htonl
682                             win32_ntohl
683                             win32_inet_addr
684                             win32_inet_ntoa
685                             win32_socket
686                             win32_bind
687                             win32_listen
688                             win32_accept
689                             win32_connect
690                             win32_send
691                             win32_sendto
692                             win32_recv
693                             win32_recvfrom
694                             win32_shutdown
695                             win32_closesocket
696                             win32_ioctlsocket
697                             win32_setsockopt
698                             win32_getsockopt
699                             win32_getpeername
700                             win32_getsockname
701                             win32_gethostname
702                             win32_gethostbyname
703                             win32_gethostbyaddr
704                             win32_getprotobyname
705                             win32_getprotobynumber
706                             win32_getservbyname
707                             win32_getservbyport
708                             win32_select
709                             win32_endhostent
710                             win32_endnetent
711                             win32_endprotoent
712                             win32_endservent
713                             win32_getnetent
714                             win32_getnetbyname
715                             win32_getnetbyaddr
716                             win32_getprotoent
717                             win32_getservent
718                             win32_sethostent
719                             win32_setnetent
720                             win32_setprotoent
721                             win32_setservent
722                             win32_getenv
723                             win32_putenv
724                             win32_perror
725                             win32_malloc
726                             win32_calloc
727                             win32_realloc
728                             win32_free
729                             win32_sleep
730                             win32_times
731                             win32_access
732                             win32_alarm
733                             win32_chmod
734                             win32_open_osfhandle
735                             win32_get_osfhandle
736                             win32_ioctl
737                             win32_link
738                             win32_unlink
739                             win32_utime
740                             win32_uname
741                             win32_wait
742                             win32_waitpid
743                             win32_kill
744                             win32_str_os_error
745                             win32_opendir
746                             win32_readdir
747                             win32_telldir
748                             win32_seekdir
749                             win32_rewinddir
750                             win32_closedir
751                             win32_longpath
752                             win32_os_id
753                             win32_getpid
754                             win32_crypt
755                             win32_dynaload
756
757                             win32_stdin
758                             win32_stdout
759                             win32_stderr
760                             win32_ferror
761                             win32_feof
762                             win32_strerror
763                             win32_fprintf
764                             win32_printf
765                             win32_vfprintf
766                             win32_vprintf
767                             win32_fread
768                             win32_fwrite
769                             win32_fopen
770                             win32_fdopen
771                             win32_freopen
772                             win32_fclose
773                             win32_fputs
774                             win32_fputc
775                             win32_ungetc
776                             win32_getc
777                             win32_fileno
778                             win32_clearerr
779                             win32_fflush
780                             win32_ftell
781                             win32_fseek
782                             win32_fgetpos
783                             win32_fsetpos
784                             win32_rewind
785                             win32_tmpfile
786                             win32_setbuf
787                             win32_setvbuf
788                             win32_flushall
789                             win32_fcloseall
790                             win32_fgets
791                             win32_gets
792                             win32_fgetc
793                             win32_putc
794                             win32_puts
795                             win32_getchar
796                             win32_putchar
797                            ))
798     {
799         try_symbol($symbol);
800     }
801 }
802 elsif ($PLATFORM eq 'os2') {
803     open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
804     /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
805     close MAP or die 'Cannot close miniperl.map';
806
807     @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
808                     keys %export;
809     delete $export{$_} foreach @missing;
810 }
811 elsif ($PLATFORM eq 'MacOS') {
812     open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
813
814     while (<MACSYMS>) {
815         try_symbol($_);
816     }
817
818     close MACSYMS;
819 }
820
821 # Now all symbols should be defined because
822 # next we are going to output them.
823
824 foreach my $symbol (sort keys %export) {
825     output_symbol($symbol);
826 }
827
828 sub emit_symbol {
829     my $symbol = shift;
830     chomp($symbol); 
831     $export{$symbol} = 1;
832 }
833
834 sub output_symbol {
835     my $symbol = shift;
836     $symbol = $bincompat5005{$symbol}
837         if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
838     if ($PLATFORM eq 'win32') {
839         $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
840         print "\t$symbol\n";
841 # XXX: binary compatibility between compilers is an exercise
842 # in frustration :-(
843 #        if ($CCTYPE eq "BORLAND") {
844 #           # workaround Borland quirk by exporting both the straight
845 #           # name and a name with leading underscore.  Note the
846 #           # alias *must* come after the symbol itself, if both
847 #           # are to be exported. (Linker bug?)
848 #           print "\t_$symbol\n";
849 #           print "\t$symbol = _$symbol\n";
850 #       }
851 #       elsif ($CCTYPE eq 'GCC') {
852 #           # Symbols have leading _ whole process is $%@"% slow
853 #           # so skip aliases for now
854 #           nprint "\t$symbol\n";
855 #       }
856 #       else {
857 #           # for binary coexistence, export both the symbol and
858 #           # alias with leading underscore
859 #           print "\t$symbol\n";
860 #           print "\t_$symbol = $symbol\n";
861 #       }
862     }
863     elsif ($PLATFORM eq 'os2') {
864         print qq(    "$symbol"\n);
865     }
866     elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
867         print "$symbol\n";
868     }
869 }
870
871 1;
872 __DATA__
873 # extra globals not included above.
874 perl_alloc
875 perl_alloc_using
876 perl_clone
877 perl_clone_using
878 perl_construct
879 perl_destruct
880 perl_free
881 perl_parse
882 perl_run
883 PerlIO_define_layer
884 PerlIOBuf_set_ptrcnt
885 PerlIOBuf_get_cnt
886 PerlIOBuf_get_ptr
887 PerlIOBuf_bufsiz
888 PerlIOBuf_setlinebuf
889 PerlIOBase_clearerr
890 PerlIOBase_error
891 PerlIOBase_eof
892 PerlIOBuf_tell
893 PerlIOBuf_seek
894 PerlIOBuf_write
895 PerlIOBuf_unread
896 PerlIOBuf_read
897 PerlIOBuf_reopen
898 PerlIOBuf_open
899 PerlIOBuf_fdopen
900 PerlIOBase_fileno
901 PerlIOBuf_pushed
902 PerlIOBuf_fill
903 PerlIOBuf_flush
904 PerlIOBase_close
905 PerlIO_define_layer
906 PerlIO_pending
907 PerlIO_unread
908 PerlIO_push
909 PerlIO_apply_layers
910 perlsio_binmode
911 PerlIO_binmode
912 PerlIO_init
913 PerlIO_tmpfile
914 PerlIO_setpos
915 PerlIO_getpos
916 PerlIO_vsprintf
917 PerlIO_sprintf