fix fs.t for VMS
[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 # and by MacOS Classic.
7 #
8 # reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
9 # On OS/2 reads miniperl.map as well
10
11 my $PLATFORM;
12 my $CCTYPE;
13
14 my %bincompat5005 =
15       (
16        Perl_call_atexit         =>      "perl_atexit",
17        Perl_eval_sv             =>      "perl_eval_sv",
18        Perl_eval_pv             =>      "perl_eval_pv",
19        Perl_call_argv           =>      "perl_call_argv",
20        Perl_call_method         =>      "perl_call_method",
21        Perl_call_pv             =>      "perl_call_pv",
22        Perl_call_sv             =>      "perl_call_sv",
23        Perl_get_av              =>      "perl_get_av",
24        Perl_get_cv              =>      "perl_get_cv",
25        Perl_get_hv              =>      "perl_get_hv",
26        Perl_get_sv              =>      "perl_get_sv",
27        Perl_init_i18nl10n       =>      "perl_init_i18nl10n",
28        Perl_init_i18nl14n       =>      "perl_init_i18nl14n",
29        Perl_new_collate         =>      "perl_new_collate",
30        Perl_new_ctype           =>      "perl_new_ctype",
31        Perl_new_numeric         =>      "perl_new_numeric",
32        Perl_require_pv          =>      "perl_require_pv",
33        Perl_safesyscalloc       =>      "Perl_safecalloc",
34        Perl_safesysfree         =>      "Perl_safefree",
35        Perl_safesysmalloc       =>      "Perl_safemalloc",
36        Perl_safesysrealloc      =>      "Perl_saferealloc",
37        Perl_set_numeric_local   =>      "perl_set_numeric_local",
38        Perl_set_numeric_standard  =>    "perl_set_numeric_standard",
39        Perl_malloc              =>      "malloc",
40        Perl_mfree               =>      "free",
41        Perl_realloc             =>      "realloc",
42        Perl_calloc              =>      "calloc",
43       );
44
45 my $bincompat5005 = join("|", keys %bincompat5005);
46
47 while (@ARGV) {
48     my $flag = shift;
49     $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
50     $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
51     $CCTYPE   = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
52     $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
53         if ($PLATFORM eq 'netware') {
54                 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
55         }
56 }
57
58 my @PLATFORM = qw(aix win32 os2 MacOS netware);
59 my %PLATFORM;
60 @PLATFORM{@PLATFORM} = ();
61
62 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
63 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
64
65 my $config_sh   = "config.sh";
66 my $config_h    = "config.h";
67 my $thrdvar_h   = "thrdvar.h";
68 my $intrpvar_h  = "intrpvar.h";
69 my $perlvars_h  = "perlvars.h";
70 my $global_sym  = "global.sym";
71 my $pp_sym      = "pp.sym";
72 my $globvar_sym = "globvar.sym";
73 my $perlio_sym  = "perlio.sym";
74
75 if ($PLATFORM eq 'aix') {
76     # Nothing for now.
77 }
78 elsif ($PLATFORM eq 'win32' || $PLATFORM eq 'netware') {
79     $CCTYPE = "MSVC" unless defined $CCTYPE;
80     foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
81                 $pp_sym, $globvar_sym, $perlio_sym) {
82         s!^!..\\!;
83     }
84 }
85 elsif ($PLATFORM eq 'MacOS') {
86     foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
87                 $pp_sym, $globvar_sym, $perlio_sym) {
88         s!^!::!;
89     }
90 }
91
92 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
93     open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
94     while (<CFG>) {
95         if (/^(?:ccflags|optimize)='(.+)'$/) {
96             $_ = $1;
97             $define{$1} = 1 while /-D(\w+)/g;
98         }
99         if ($PLATFORM eq 'os2') {
100             $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
101             $ARCHNAME =    $1 if /^(?:archname)='(.+)'$/;
102         }
103     }
104     close(CFG);
105 }
106
107 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
108 while (<CFG>) {
109     $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
110     $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
111     $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
112     $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
113 }
114 close(CFG);
115
116 # perl.h logic duplication begins
117
118 if ($define{USE_ITHREADS}) {
119     if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
120         $define{MULTIPLICITY} = 1;
121     }
122 }
123
124 $define{PERL_IMPLICIT_CONTEXT} ||=
125     $define{USE_ITHREADS} ||
126     $define{USE_5005THREADS}  ||
127     $define{MULTIPLICITY} ;
128
129 if ($define{PERL_CAPI}) {
130     delete $define{PERL_OBJECT};
131     $define{MULTIPLICITY} = 1;
132     $define{PERL_IMPLICIT_CONTEXT} = 1;
133     $define{PERL_IMPLICIT_SYS}     = 1;
134 }
135
136 if ($define{PERL_OBJECT}) {
137     $define{PERL_IMPLICIT_CONTEXT} = 1;
138     $define{PERL_IMPLICIT_SYS}     = 1;
139 }
140
141 # perl.h logic duplication ends
142
143 if ($PLATFORM eq 'win32') {
144     warn join(' ',keys %define)."\n";
145     print "LIBRARY Perl57\n";
146     print "DESCRIPTION 'Perl interpreter'\n";
147     print "EXPORTS\n";
148     if ($define{PERL_IMPLICIT_SYS}) {
149         output_symbol("perl_get_host_info");
150         output_symbol("perl_alloc_override");
151     output_symbol("perl_clone_host");
152     }
153 }
154 elsif ($PLATFORM eq 'os2') {
155     ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
156     $v .= '-thread' if $ARCHNAME =~ /-thread/;
157     ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
158     $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
159     $d = substr($d, 0, 249) . "...'" if length $d > 253;
160     print <<"---EOP---";
161 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
162 $d
163 STACKSIZE 32768
164 CODE LOADONCALL
165 DATA LOADONCALL NONSHARED MULTIPLE
166 EXPORTS
167 ---EOP---
168 }
169 elsif ($PLATFORM eq 'aix') {
170     $OSVER = `uname -v`;
171     chop $OSVER;
172     $OSREL = `uname -r`;
173     chop $OSREL;
174     if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
175         print "#! ..\n";
176     } else {
177         print "#!\n";
178     }
179 }
180 elsif ($PLATFORM eq 'netware') {
181         if ($FILETYPE eq 'def') {
182         print "LIBRARY Perl57\n";
183         print "DESCRIPTION 'Perl interpreter for NetWare'\n";
184         print "EXPORTS\n";
185         }
186         if ($define{PERL_IMPLICIT_SYS}) {
187         output_symbol("perl_get_host_info");
188         output_symbol("perl_alloc_override");
189     output_symbol("perl_clone_host");
190         }
191 }
192
193 my %skip;
194 my %export;
195
196 sub skip_symbols {
197     my $list = shift;
198     foreach my $symbol (@$list) {
199         $skip{$symbol} = 1;
200     }
201 }
202
203 sub emit_symbols {
204     my $list = shift;
205     foreach my $symbol (@$list) {
206         my $skipsym = $symbol;
207         # XXX hack
208         if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
209             $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
210         }
211         emit_symbol($symbol) unless exists $skip{$skipsym};
212     }
213 }
214
215 if ($PLATFORM eq 'win32') {
216     skip_symbols [qw(
217                      PL_statusvalue_vms
218                      PL_archpat_auto
219                      PL_cryptseen
220                      PL_DBcv
221                      PL_generation
222                      PL_lastgotoprobe
223                      PL_linestart
224                      PL_modcount
225                      PL_pending_ident
226                      PL_sortcxix
227                      PL_sublex_info
228                      PL_timesbuf
229                      main
230                      Perl_ErrorNo
231                      Perl_GetVars
232                      Perl_do_exec3
233                      Perl_do_ipcctl
234                      Perl_do_ipcget
235                      Perl_do_msgrcv
236                      Perl_do_msgsnd
237                      Perl_do_semop
238                      Perl_do_shmio
239                      Perl_dump_fds
240                      Perl_init_thread_intern
241                      Perl_my_bzero
242                      Perl_my_bcopy
243                      Perl_my_htonl
244                      Perl_my_ntohl
245                      Perl_my_swap
246                      Perl_my_chsize
247                      Perl_same_dirent
248                      Perl_setenv_getix
249                      Perl_unlnk
250                      Perl_watch
251                      Perl_safexcalloc
252                      Perl_safexmalloc
253                      Perl_safexfree
254                      Perl_safexrealloc
255                      Perl_my_memcmp
256                      Perl_my_memset
257                      PL_cshlen
258                      PL_cshname
259                      PL_opsave
260                      Perl_do_exec
261                      Perl_getenv_len
262                      Perl_my_pclose
263                      Perl_my_popen
264                      )];
265 }
266 elsif ($PLATFORM eq 'aix') {
267     skip_symbols([qw(
268                      Perl_dump_fds
269                      Perl_ErrorNo
270                      Perl_GetVars
271                      Perl_my_bcopy
272                      Perl_my_bzero
273                      Perl_my_chsize
274                      Perl_my_htonl
275                      Perl_my_memcmp
276                      Perl_my_memset
277                      Perl_my_ntohl
278                      Perl_my_swap
279                      Perl_safexcalloc
280                      Perl_safexfree
281                      Perl_safexmalloc
282                      Perl_safexrealloc
283                      Perl_same_dirent
284                      Perl_unlnk
285                      Perl_sys_intern_clear
286                      Perl_sys_intern_dup
287                      Perl_sys_intern_init
288                      PL_cryptseen
289                      PL_opsave
290                      PL_statusvalue_vms
291                      PL_sys_intern
292                      )]);
293 }
294 elsif ($PLATFORM eq 'os2') {
295     emit_symbols([qw(
296                     ctermid
297                     get_sysinfo
298                     Perl_OS2_init
299                     Perl_OS2_init3
300                     Perl_OS2_term
301                     OS2_Perl_data
302                     dlopen
303                     dlsym
304                     dlerror
305                     dlclose
306                     my_tmpfile
307                     my_tmpnam
308                     my_flock
309                     my_rmdir
310                     my_mkdir
311                     my_getpwuid
312                     my_getpwnam
313                     my_getpwent
314                     my_setpwent
315                     my_endpwent
316                     setgrent
317                     endgrent
318                     getgrent
319                     malloc_mutex
320                     threads_mutex
321                     nthreads
322                     nthreads_cond
323                     os2_cond_wait
324                     os2_stat
325                     pthread_join
326                     pthread_create
327                     pthread_detach
328                     XS_Cwd_change_drive
329                     XS_Cwd_current_drive
330                     XS_Cwd_extLibpath
331                     XS_Cwd_extLibpath_set
332                     XS_Cwd_sys_abspath
333                     XS_Cwd_sys_chdir
334                     XS_Cwd_sys_cwd
335                     XS_Cwd_sys_is_absolute
336                     XS_Cwd_sys_is_relative
337                     XS_Cwd_sys_is_rooted
338                     XS_DynaLoader_mod2fname
339                     XS_File__Copy_syscopy
340                     Perl_Register_MQ
341                     Perl_Deregister_MQ
342                     Perl_Serve_Messages
343                     Perl_Process_Messages
344                     init_PMWIN_entries
345                     PMWIN_entries
346                     Perl_hab_GET
347                     loadByOrdinal
348                     pExtFCN
349                     )]);
350 }
351 elsif ($PLATFORM eq 'MacOS') {
352     skip_symbols [qw(
353                     Perl_GetVars
354                     PL_cryptseen
355                     PL_cshlen
356                     PL_cshname
357                     PL_statusvalue_vms
358                     PL_sys_intern
359                     PL_opsave
360                     PL_timesbuf
361                     Perl_dump_fds
362                     Perl_my_bcopy
363                     Perl_my_bzero
364                     Perl_my_chsize
365                     Perl_my_htonl
366                     Perl_my_memcmp
367                     Perl_my_memset
368                     Perl_my_ntohl
369                     Perl_my_swap
370                     Perl_safexcalloc
371                     Perl_safexfree
372                     Perl_safexmalloc
373                     Perl_safexrealloc
374                     Perl_unlnk
375                     Perl_sys_intern_clear
376                     Perl_sys_intern_init
377                     )];
378 }
379 elsif ($PLATFORM eq 'netware') {
380         skip_symbols [qw(
381                         PL_statusvalue_vms
382                         PL_archpat_auto
383                         PL_cryptseen
384                         PL_DBcv
385                         PL_generation
386                         PL_lastgotoprobe
387                         PL_linestart
388                         PL_modcount
389                         PL_pending_ident
390                         PL_sortcxix
391                         PL_sublex_info
392                         PL_timesbuf
393                         main
394                         Perl_ErrorNo
395                         Perl_GetVars
396                         Perl_do_exec3
397                         Perl_do_ipcctl
398                         Perl_do_ipcget
399                         Perl_do_msgrcv
400                         Perl_do_msgsnd
401                         Perl_do_semop
402                         Perl_do_shmio
403                         Perl_dump_fds
404                         Perl_init_thread_intern
405                         Perl_my_bzero
406                         Perl_my_htonl
407                         Perl_my_ntohl
408                         Perl_my_swap
409                         Perl_my_chsize
410                         Perl_same_dirent
411                         Perl_setenv_getix
412                         Perl_unlnk
413                         Perl_watch
414                         Perl_safexcalloc
415                         Perl_safexmalloc
416                         Perl_safexfree
417                         Perl_safexrealloc
418                         Perl_my_memcmp
419                         Perl_my_memset
420                         PL_cshlen
421                         PL_cshname
422                         PL_opsave
423                         Perl_do_exec
424                         Perl_getenv_len
425                         Perl_my_pclose
426                         Perl_my_popen
427                         )];
428 }
429
430 unless ($define{'DEBUGGING'}) {
431     skip_symbols [qw(
432                     Perl_deb_growlevel
433                     Perl_debop
434                     Perl_debprofdump
435                     Perl_debstack
436                     Perl_debstackptrs
437                     Perl_runops_debug
438                     Perl_sv_peek
439                     PL_block_type
440                     PL_watchaddr
441                     PL_watchok
442                     )];
443 }
444
445 if ($define{'PERL_IMPLICIT_SYS'}) {
446     skip_symbols [qw(
447                     Perl_getenv_len
448                     Perl_my_popen
449                     Perl_my_pclose
450                     )];
451 }
452 else {
453     skip_symbols [qw(
454                     PL_Mem
455                     PL_MemShared
456                     PL_MemParse
457                     PL_Env
458                     PL_StdIO
459                     PL_LIO
460                     PL_Dir
461                     PL_Sock
462                     PL_Proc
463                     )];
464 }
465
466 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
467     skip_symbols [qw(
468                     PL_protect
469                     Perl_default_protect
470                     Perl_vdefault_protect
471                     )];
472 }
473
474 unless ($define{'USE_REENTRANT_API'}) {
475     skip_symbols [qw(
476                     PL_reentrant_buffer
477                     )];
478 }
479
480 if ($define{'MYMALLOC'}) {
481     emit_symbols [qw(
482                     Perl_dump_mstats
483                     Perl_get_mstats
484                     Perl_strdup
485                     Perl_putenv
486                     )];
487     if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
488         emit_symbols [qw(
489                         PL_malloc_mutex
490                         )];
491     }
492     else {
493         skip_symbols [qw(
494                         PL_malloc_mutex
495                         )];
496     }
497 }
498 else {
499     skip_symbols [qw(
500                     PL_malloc_mutex
501                     Perl_dump_mstats
502                     Perl_get_mstats
503                     Perl_malloced_size
504                     )];
505 }
506
507 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
508     skip_symbols [qw(
509                     PL_thr_key
510                     )];
511 }
512
513 unless ($define{'USE_5005THREADS'}) {
514     skip_symbols [qw(
515                     PL_sv_mutex
516                     PL_strtab_mutex
517                     PL_svref_mutex
518                     PL_cred_mutex
519                     PL_eval_mutex
520                     PL_fdpid_mutex
521                     PL_sv_lock_mutex
522                     PL_eval_cond
523                     PL_eval_owner
524                     PL_threads_mutex
525                     PL_nthreads
526                     PL_nthreads_cond
527                     PL_threadnum
528                     PL_threadsv_names
529                     PL_thrsv
530                     PL_vtbl_mutex
531                     Perl_condpair_magic
532                     Perl_new_struct_thread
533                     Perl_per_thread_magicals
534                     Perl_thread_create
535                     Perl_find_threadsv
536                     Perl_unlock_condpair
537                     Perl_magic_mutexfree
538                     Perl_sv_lock
539                     )];
540 }
541
542 unless ($define{'USE_ITHREADS'}) {
543     skip_symbols [qw(
544                     PL_ptr_table
545                     PL_op_mutex
546                     PL_regex_pad
547                     PL_regex_padav
548                     Perl_dirp_dup
549                     Perl_cx_dup
550                     Perl_si_dup
551                     Perl_any_dup
552                     Perl_ss_dup
553                     Perl_fp_dup
554                     Perl_gp_dup
555                     Perl_he_dup
556                     Perl_mg_dup
557                     Perl_re_dup
558                     Perl_sv_dup
559                     Perl_sys_intern_dup
560                     Perl_ptr_table_clear
561                     Perl_ptr_table_fetch
562                     Perl_ptr_table_free
563                     Perl_ptr_table_new
564                     Perl_ptr_table_clear
565                     Perl_ptr_table_free
566                     Perl_ptr_table_split
567                     Perl_ptr_table_store
568                     perl_clone
569                     perl_clone_using
570                     )];
571 }
572
573 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
574     skip_symbols [qw(
575                     Perl_croak_nocontext
576                     Perl_die_nocontext
577                     Perl_deb_nocontext
578                     Perl_form_nocontext
579                     Perl_load_module_nocontext
580                     Perl_mess_nocontext
581                     Perl_warn_nocontext
582                     Perl_warner_nocontext
583                     Perl_newSVpvf_nocontext
584                     Perl_sv_catpvf_nocontext
585                     Perl_sv_setpvf_nocontext
586                     Perl_sv_catpvf_mg_nocontext
587                     Perl_sv_setpvf_mg_nocontext
588                     )];
589 }
590
591 unless ($define{'PERL_IMPLICIT_SYS'}) {
592     skip_symbols [qw(
593                     perl_alloc_using
594                     perl_clone_using
595                     )];
596 }
597
598 unless ($define{'FAKE_THREADS'}) {
599     skip_symbols [qw(PL_curthr)];
600 }
601
602 sub readvar {
603     my $file = shift;
604     my $proc = shift || sub { "PL_$_[2]" };
605     open(VARS,$file) || die "Cannot open $file: $!\n";
606     my @syms;
607     while (<VARS>) {
608         # All symbols have a Perl_ prefix because that's what embed.h
609         # sticks in front of them.
610         push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
611     }
612     close(VARS);
613     return \@syms;
614 }
615
616 if ($define{'USE_5005THREADS'}) {
617     my $thrd = readvar($thrdvar_h);
618     skip_symbols $thrd;
619 }
620
621 if ($define{'PERL_GLOBAL_STRUCT'}) {
622     my $global = readvar($perlvars_h);
623     skip_symbols $global;
624     emit_symbol('Perl_GetVars');
625     emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
626 }
627
628 # functions from *.sym files
629
630 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
631
632 my @layer_syms = qw(
633                          PerlIOBase_clearerr
634                          PerlIOBase_close
635                          PerlIOBase_eof
636                          PerlIOBase_error
637                          PerlIOBase_fileno
638                          PerlIOBase_setlinebuf
639                          PerlIOBase_pushed
640                          PerlIOBase_read
641                          PerlIOBase_unread
642                          PerlIOBuf_bufsiz
643                          PerlIOBuf_fill
644                          PerlIOBuf_flush
645                          PerlIOBuf_get_cnt
646                          PerlIOBuf_get_ptr
647                          PerlIOBuf_open
648                          PerlIOBuf_pushed
649                          PerlIOBuf_read
650                          PerlIOBuf_seek
651                          PerlIOBuf_set_ptrcnt
652                          PerlIOBuf_tell
653                          PerlIOBuf_unread
654                          PerlIOBuf_write
655                          PerlIO_define_layer
656                          PerlIO_arg_fetch
657                          PerlIO_pending
658                          PerlIO_allocate
659                          PerlIO_push
660                          PerlIO_unread
661 );
662
663 if ($define{'USE_PERLIO'}) {
664     push @syms, $perlio_sym;
665     if ($define{'USE_SFIO'}) {
666         skip_symbols \@layer_syms;
667         # SFIO defines most of the PerlIO routines as macros
668         skip_symbols [qw(
669                          PerlIO_canset_cnt
670                          PerlIO_clearerr
671                          PerlIO_close
672                          PerlIO_eof
673                          PerlIO_error
674                          PerlIO_exportFILE
675                          PerlIO_fast_gets
676                          PerlIO_fdopen
677                          PerlIO_fileno
678                          PerlIO_findFILE
679                          PerlIO_flush
680                          PerlIO_get_base
681                          PerlIO_get_bufsiz
682                          PerlIO_get_cnt
683                          PerlIO_get_ptr
684                          PerlIO_getc
685                          PerlIO_getname
686                          PerlIO_has_base
687                          PerlIO_has_cntptr
688                          PerlIO_importFILE
689                          PerlIO_open
690                          PerlIO_printf
691                          PerlIO_putc
692                          PerlIO_puts
693                          PerlIO_read
694                          PerlIO_releaseFILE
695                          PerlIO_reopen
696                          PerlIO_rewind
697                          PerlIO_seek
698                          PerlIO_set_cnt
699                          PerlIO_set_ptrcnt
700                          PerlIO_setlinebuf
701                          PerlIO_sprintf
702                          PerlIO_stderr
703                          PerlIO_stdin
704                          PerlIO_stdout
705                          PerlIO_stdoutf
706                          PerlIO_tell
707                          PerlIO_ungetc
708                          PerlIO_vprintf
709                          PerlIO_write
710                          )];
711     }
712 } else {
713         # Skip the PerlIO New Generation symbols.
714         skip_symbols \@layer_syms;
715 }
716
717 for my $syms (@syms) {
718     open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
719     while (<GLOBAL>) {
720         next if (!/^[A-Za-z]/);
721         # Functions have a Perl_ prefix
722         # Variables have a PL_ prefix
723         chomp($_);
724         my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
725         $symbol .= $_;
726         emit_symbol($symbol) unless exists $skip{$symbol};
727     }
728     close(GLOBAL);
729 }
730
731 # variables
732
733 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
734     for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
735         my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
736         emit_symbols $glob;
737     }
738     # XXX AIX seems to want the perlvars.h symbols, for some reason
739     if ($PLATFORM eq 'aix') {
740         my $glob = readvar($perlvars_h);
741         emit_symbols $glob;
742     }
743 }
744 else {
745     unless ($define{'PERL_GLOBAL_STRUCT'}) {
746         my $glob = readvar($perlvars_h);
747         emit_symbols $glob;
748     }
749     unless ($define{'MULTIPLICITY'}) {
750         my $glob = readvar($intrpvar_h);
751         emit_symbols $glob;
752     }
753     unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
754         my $glob = readvar($thrdvar_h);
755         emit_symbols $glob;
756     }
757 }
758
759 sub try_symbol {
760     my $symbol = shift;
761
762     return if $symbol !~ /^[A-Za-z_]/;
763     return if $symbol =~ /^\#/;
764     $symbol =~s/\r//g;
765     chomp($symbol);
766     return if exists $skip{$symbol};
767     emit_symbol($symbol);
768 }
769
770 while (<DATA>) {
771     try_symbol($_);
772 }
773
774 if ($PLATFORM eq 'win32') {
775     foreach my $symbol (qw(
776                             setuid
777                             setgid
778                             boot_DynaLoader
779                             Perl_init_os_extras
780                             Perl_thread_create
781                             Perl_win32_init
782                             RunPerl
783                             win32_errno
784                             win32_environ
785                             win32_abort
786                             win32_fstat
787                             win32_stat
788                             win32_pipe
789                             win32_popen
790                             win32_pclose
791                             win32_rename
792                             win32_setmode
793                             win32_lseek
794                             win32_tell
795                             win32_dup
796                             win32_dup2
797                             win32_open
798                             win32_close
799                             win32_eof
800                             win32_read
801                             win32_write
802                             win32_spawnvp
803                             win32_mkdir
804                             win32_rmdir
805                             win32_chdir
806                             win32_flock
807                             win32_execv
808                             win32_execvp
809                             win32_htons
810                             win32_ntohs
811                             win32_htonl
812                             win32_ntohl
813                             win32_inet_addr
814                             win32_inet_ntoa
815                             win32_socket
816                             win32_bind
817                             win32_listen
818                             win32_accept
819                             win32_connect
820                             win32_send
821                             win32_sendto
822                             win32_recv
823                             win32_recvfrom
824                             win32_shutdown
825                             win32_closesocket
826                             win32_ioctlsocket
827                             win32_setsockopt
828                             win32_getsockopt
829                             win32_getpeername
830                             win32_getsockname
831                             win32_gethostname
832                             win32_gethostbyname
833                             win32_gethostbyaddr
834                             win32_getprotobyname
835                             win32_getprotobynumber
836                             win32_getservbyname
837                             win32_getservbyport
838                             win32_select
839                             win32_endhostent
840                             win32_endnetent
841                             win32_endprotoent
842                             win32_endservent
843                             win32_getnetent
844                             win32_getnetbyname
845                             win32_getnetbyaddr
846                             win32_getprotoent
847                             win32_getservent
848                             win32_sethostent
849                             win32_setnetent
850                             win32_setprotoent
851                             win32_setservent
852                             win32_getenv
853                             win32_putenv
854                             win32_perror
855                             win32_malloc
856                             win32_calloc
857                             win32_realloc
858                             win32_free
859                             win32_sleep
860                             win32_times
861                             win32_access
862                             win32_alarm
863                             win32_chmod
864                             win32_open_osfhandle
865                             win32_get_osfhandle
866                             win32_ioctl
867                             win32_link
868                             win32_unlink
869                             win32_utime
870                             win32_uname
871                             win32_wait
872                             win32_waitpid
873                             win32_kill
874                             win32_str_os_error
875                             win32_opendir
876                             win32_readdir
877                             win32_telldir
878                             win32_seekdir
879                             win32_rewinddir
880                             win32_closedir
881                             win32_longpath
882                             win32_os_id
883                             win32_getpid
884                             win32_crypt
885                             win32_dynaload
886
887                             win32_stdin
888                             win32_stdout
889                             win32_stderr
890                             win32_ferror
891                             win32_feof
892                             win32_strerror
893                             win32_fprintf
894                             win32_printf
895                             win32_vfprintf
896                             win32_vprintf
897                             win32_fread
898                             win32_fwrite
899                             win32_fopen
900                             win32_fdopen
901                             win32_freopen
902                             win32_fclose
903                             win32_fputs
904                             win32_fputc
905                             win32_ungetc
906                             win32_getc
907                             win32_fileno
908                             win32_clearerr
909                             win32_fflush
910                             win32_ftell
911                             win32_fseek
912                             win32_fgetpos
913                             win32_fsetpos
914                             win32_rewind
915                             win32_tmpfile
916                             win32_setbuf
917                             win32_setvbuf
918                             win32_flushall
919                             win32_fcloseall
920                             win32_fgets
921                             win32_gets
922                             win32_fgetc
923                             win32_putc
924                             win32_puts
925                             win32_getchar
926                             win32_putchar
927                            ))
928     {
929         try_symbol($symbol);
930     }
931 }
932 elsif ($PLATFORM eq 'os2') {
933     open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
934     /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
935     close MAP or die 'Cannot close miniperl.map';
936
937     @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
938                     keys %export;
939     delete $export{$_} foreach @missing;
940 }
941 elsif ($PLATFORM eq 'MacOS') {
942     open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
943
944     while (<MACSYMS>) {
945         try_symbol($_);
946     }
947
948     close MACSYMS;
949 }
950 elsif ($PLATFORM eq 'netware') {
951 foreach my $symbol (qw(
952                         boot_DynaLoader
953                         Perl_init_os_extras
954                         Perl_thread_create
955                         Perl_nw5_init
956                         RunPerl
957                         AllocStdPerl
958                         FreeStdPerl
959                         do_spawn2
960                         do_aspawn
961                         nw_uname
962                         nw_stdin
963                         nw_stdout
964                         nw_stderr
965                         nw_feof
966                         nw_ferror
967                         nw_fopen
968                         nw_fclose
969                         nw_clearerr
970                         nw_getc
971                         nw_fgets
972                         nw_fputc
973                         nw_fputs
974                         nw_fflush
975                         nw_ungetc
976                         nw_fileno
977                         nw_fdopen
978                         nw_freopen
979                         nw_fread
980                         nw_fwrite
981                         nw_setbuf
982                         nw_setvbuf
983                         nw_vfprintf
984                         nw_ftell
985                         nw_fseek
986                         nw_rewind
987                         nw_tmpfile
988                         nw_fgetpos
989                         nw_fsetpos
990                         nw_dup
991                         nw_access
992                         nw_chmod
993                         nw_chsize
994                         nw_close
995                         nw_dup2
996                         nw_flock
997                         nw_isatty
998                         nw_link
999                         nw_lseek
1000                         nw_stat
1001                         nw_mktemp
1002                         nw_open
1003                         nw_read
1004                         nw_rename
1005                         nw_setmode
1006                         nw_unlink
1007                         nw_utime
1008                         nw_write
1009                         nw_chdir
1010                         nw_rmdir
1011                         nw_closedir
1012                         nw_opendir
1013                         nw_readdir
1014                         nw_rewinddir
1015                         nw_seekdir
1016                         nw_telldir
1017                         nw_htonl
1018                         nw_htons
1019                         nw_ntohl
1020                         nw_ntohs
1021                         nw_accept
1022                         nw_bind
1023                         nw_connect
1024                         nw_endhostent
1025                         nw_endnetent
1026                         nw_endprotoent
1027                         nw_endservent
1028                         nw_gethostbyaddr
1029                         nw_gethostbyname
1030                         nw_gethostent
1031                         nw_gethostname
1032                         nw_getnetbyaddr
1033                         nw_getnetbyname
1034                         nw_getnetent
1035                         nw_getpeername
1036                         nw_getprotobyname
1037                         nw_getprotobynumber
1038                         nw_getprotoent
1039                         nw_getservbyname
1040                         nw_getservbyport
1041                         nw_getservent
1042                         nw_getsockname
1043                         nw_getsockopt
1044                         nw_inet_addr
1045                         nw_listen
1046                         nw_socket
1047                         nw_recv
1048                         nw_recvfrom
1049                         nw_select
1050                         nw_send
1051                         nw_sendto
1052                         nw_sethostent
1053                         nw_setnetent
1054                         nw_setprotoent
1055                         nw_setservent
1056                         nw_shutdown
1057                         nw_crypt
1058                         nw_execvp
1059                         nw_kill
1060                         nw_Popen
1061                         nw_Pclose
1062                         nw_Pipe
1063                         nw_times
1064                         nw_waitpid
1065                         nw_getpid
1066                         nw_spawnvp
1067                         nw_os_id
1068                         nw_open_osfhandle
1069                         nw_get_osfhandle
1070                         nw_abort
1071                         nw_sleep
1072                         nw_wait
1073                         nw_dynaload
1074                         nw_strerror
1075                         fnFpSetMode
1076                         fnInsertHashListAddrs
1077                         fnGetHashListAddrs
1078                         Perl_deb
1079                            ))
1080     {
1081         try_symbol($symbol);
1082     }
1083 }
1084
1085 # Now all symbols should be defined because
1086 # next we are going to output them.
1087
1088 foreach my $symbol (sort keys %export) {
1089     output_symbol($symbol);
1090 }
1091
1092 if ($PLATFORM eq 'netware') {
1093         # This may not be the right way to do.  This is to make sure
1094         # that the last symbol will not contain a comma else
1095         # Watcom linker cribs
1096         print "\tdummy\n";
1097 }
1098
1099 sub emit_symbol {
1100     my $symbol = shift;
1101     chomp($symbol);
1102     $export{$symbol} = 1;
1103 }
1104
1105 my $sym_ord = 0;
1106
1107 sub output_symbol {
1108     my $symbol = shift;
1109     $symbol = $bincompat5005{$symbol}
1110         if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
1111     if ($PLATFORM eq 'win32') {
1112         $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1113         print "\t$symbol\n";
1114 # XXX: binary compatibility between compilers is an exercise
1115 # in frustration :-(
1116 #        if ($CCTYPE eq "BORLAND") {
1117 #           # workaround Borland quirk by exporting both the straight
1118 #           # name and a name with leading underscore.  Note the
1119 #           # alias *must* come after the symbol itself, if both
1120 #           # are to be exported. (Linker bug?)
1121 #           print "\t_$symbol\n";
1122 #           print "\t$symbol = _$symbol\n";
1123 #       }
1124 #       elsif ($CCTYPE eq 'GCC') {
1125 #           # Symbols have leading _ whole process is $%@"% slow
1126 #           # so skip aliases for now
1127 #           nprint "\t$symbol\n";
1128 #       }
1129 #       else {
1130 #           # for binary coexistence, export both the symbol and
1131 #           # alias with leading underscore
1132 #           print "\t$symbol\n";
1133 #           print "\t_$symbol = $symbol\n";
1134 #       }
1135     }
1136     elsif ($PLATFORM eq 'os2') {
1137         printf qq(    %-31s \@%s\n), qq("$symbol"), ++$sym_ord;
1138     }
1139     elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1140         print "$symbol\n";
1141     }
1142         elsif ($PLATFORM eq 'netware') {
1143         print "\t$symbol,\n";
1144         }
1145 }
1146
1147 1;
1148 __DATA__
1149 # extra globals not included above.
1150 perl_alloc
1151 perl_alloc_using
1152 perl_clone
1153 perl_clone_using
1154 perl_construct
1155 perl_destruct
1156 perl_free
1157 perl_parse
1158 perl_run
1159 PerlIO_define_layer
1160 PerlIOBuf_set_ptrcnt
1161 PerlIOBuf_get_cnt
1162 PerlIOBuf_get_ptr
1163 PerlIOBuf_bufsiz
1164 PerlIOBase_clearerr
1165 PerlIOBase_setlinebuf
1166 PerlIOBase_pushed
1167 PerlIOBase_read
1168 PerlIOBase_unread
1169 PerlIOBase_error
1170 PerlIOBase_eof
1171 PerlIOBuf_tell
1172 PerlIOBuf_seek
1173 PerlIOBuf_write
1174 PerlIOBuf_unread
1175 PerlIOBuf_read
1176 PerlIOBuf_open
1177 PerlIOBase_fileno
1178 PerlIOBuf_pushed
1179 PerlIOBuf_fill
1180 PerlIOBuf_flush
1181 PerlIOBase_close
1182 PerlIO_define_layer
1183 PerlIO_pending
1184 PerlIO_unread
1185 PerlIO_push
1186 PerlIO_allocate
1187 PerlIO_arg_fetch
1188 PerlIO_apply_layers
1189 perlsio_binmode
1190 PerlIO_binmode
1191 PerlIO_init
1192 PerlIO_tmpfile
1193 PerlIO_setpos
1194 PerlIO_getpos
1195 PerlIO_vsprintf
1196 PerlIO_sprintf