This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
require.t needs binmode() to work on windows
[perl5.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);
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, $pp_sym, $globvar_sym) {
77         s!^!..\\!;
78     }
79 }
80
81 unless ($PLATFORM eq 'win32') {
82     open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
83     while (<CFG>) {
84         if (/^(?:ccflags|optimize)='(.+)'$/) {
85             $_ = $1;
86             $define{$1} = 1 while /-D(\w+)/g;
87         }
88         if ($PLATFORM eq 'os2') {
89             $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
90             $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
91         }
92     }
93     close(CFG);
94 }
95
96 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
97 while (<CFG>) {
98     $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
99     $define{$1} = 1 if /^\s*#\s*define\s+(USE_5005THREADS)\b/;
100     $define{$1} = 1 if /^\s*#\s*define\s+(USE_ITHREADS)\b/;
101     $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
102     $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
103     $define{$1} = 1 if /^\s*#\s*define\s+(PERL_IMPLICIT_SYS)\b/;
104     $define{$1} = 1 if /^\s*#\s*define\s+(PERL_BINCOMPAT_5005)\b/;
105 }
106 close(CFG);
107
108 # perl.h logic duplication begins
109
110 if ($define{USE_ITHREADS}) {
111     if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
112         $define{MULTIPLICITY} = 1;
113     }
114 }
115
116 $define{PERL_IMPLICIT_CONTEXT} ||=
117     $define{USE_ITHREADS} ||
118     $define{USE_5005THREADS}  ||
119     $define{MULTIPLICITY} ;
120
121 if ($define{PERL_CAPI}) {
122     delete $define{PERL_OBJECT};
123     $define{MULTIPLICITY} = 1; 
124     $define{PERL_IMPLICIT_CONTEXT} = 1;
125     $define{PERL_IMPLICIT_SYS}     = 1;
126 }
127
128 if ($define{PERL_OBJECT}) {
129     $define{PERL_IMPLICIT_CONTEXT} = 1;
130     $define{PERL_IMPLICIT_SYS}     = 1;
131 }
132
133 # perl.h logic duplication ends
134
135 if ($PLATFORM eq 'win32') {
136     warn join(' ',keys %define)."\n";
137     print "LIBRARY Perl56\n";
138     print "DESCRIPTION 'Perl interpreter'\n";
139     print "EXPORTS\n";
140     if ($define{PERL_IMPLICIT_SYS}) {
141         output_symbol("perl_get_host_info");
142         output_symbol("perl_alloc_override");
143     }
144 }
145 elsif ($PLATFORM eq 'os2') {
146     ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
147     $v .= '-thread' if $ARCHNAME =~ /-thread/;
148     #$sum = 0;
149     #for (split //, $v) {
150     #   $sum = ($sum * 33) + ord;
151     #   $sum &= 0xffffff;
152     #}
153     #$sum += $sum >> 5;
154     #$sum &= 0xffff;
155     #$sum = printf '%X', $sum;
156     ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
157     # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
158     print <<"---EOP---";
159 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
160 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter'
161 STACKSIZE 32768
162 CODE LOADONCALL
163 DATA LOADONCALL NONSHARED MULTIPLE
164 EXPORTS
165 ---EOP---
166 }
167 elsif ($PLATFORM eq 'aix') {
168     print "#!\n";
169 }
170
171 my %skip;
172 my %export;
173
174 sub skip_symbols {
175     my $list = shift;
176     foreach my $symbol (@$list) {
177         $skip{$symbol} = 1;
178     }
179 }
180
181 sub emit_symbols {
182     my $list = shift;
183     foreach my $symbol (@$list) {
184         my $skipsym = $symbol;
185         # XXX hack
186         if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
187             $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
188         }
189         emit_symbol($symbol) unless exists $skip{$skipsym};
190     }
191 }
192
193 if ($PLATFORM eq 'win32') {
194     skip_symbols [qw(
195                      PL_statusvalue_vms
196                      PL_archpat_auto
197                      PL_cryptseen
198                      PL_DBcv
199                      PL_generation
200                      PL_lastgotoprobe
201                      PL_linestart
202                      PL_modcount
203                      PL_pending_ident
204                      PL_sortcxix
205                      PL_sublex_info
206                      PL_timesbuf
207                      main
208                      Perl_ErrorNo
209                      Perl_GetVars
210                      Perl_do_exec3
211                      Perl_do_ipcctl
212                      Perl_do_ipcget
213                      Perl_do_msgrcv
214                      Perl_do_msgsnd
215                      Perl_do_semop
216                      Perl_do_shmio
217                      Perl_dump_fds
218                      Perl_init_thread_intern
219                      Perl_my_bzero
220                      Perl_my_htonl
221                      Perl_my_ntohl
222                      Perl_my_swap
223                      Perl_my_chsize
224                      Perl_same_dirent
225                      Perl_setenv_getix
226                      Perl_unlnk
227                      Perl_watch
228                      Perl_safexcalloc
229                      Perl_safexmalloc
230                      Perl_safexfree
231                      Perl_safexrealloc
232                      Perl_my_memcmp
233                      Perl_my_memset
234                      PL_cshlen
235                      PL_cshname
236                      PL_opsave
237                      Perl_do_exec
238                      Perl_getenv_len
239                      Perl_my_pclose
240                      Perl_my_popen
241                      )];
242 }
243 elsif ($PLATFORM eq 'aix') {
244     skip_symbols([qw(
245                      Perl_dump_fds
246                      Perl_ErrorNo
247                      Perl_GetVars
248                      Perl_my_bcopy
249                      Perl_my_bzero
250                      Perl_my_chsize
251                      Perl_my_htonl
252                      Perl_my_memcmp
253                      Perl_my_memset
254                      Perl_my_ntohl
255                      Perl_my_swap
256                      Perl_safexcalloc
257                      Perl_safexfree
258                      Perl_safexmalloc
259                      Perl_safexrealloc
260                      Perl_same_dirent
261                      Perl_unlnk
262                      Perl_sys_intern_clear
263                      Perl_sys_intern_dup
264                      Perl_sys_intern_init
265                      PL_cryptseen
266                      PL_opsave
267                      PL_statusvalue_vms
268                      PL_sys_intern
269                      )]);
270 }
271 elsif ($PLATFORM eq 'os2') {
272     emit_symbols([qw(
273                     ctermid
274                     get_sysinfo
275                     Perl_OS2_init
276                     OS2_Perl_data
277                     dlopen
278                     dlsym
279                     dlerror
280                     dlclose
281                     my_tmpfile
282                     my_tmpnam
283                     my_flock
284                     malloc_mutex
285                     threads_mutex
286                     nthreads
287                     nthreads_cond
288                     os2_cond_wait
289                     os2_stat
290                     pthread_join
291                     pthread_create
292                     pthread_detach
293                     XS_Cwd_change_drive
294                     XS_Cwd_current_drive
295                     XS_Cwd_extLibpath
296                     XS_Cwd_extLibpath_set
297                     XS_Cwd_sys_abspath
298                     XS_Cwd_sys_chdir
299                     XS_Cwd_sys_cwd
300                     XS_Cwd_sys_is_absolute
301                     XS_Cwd_sys_is_relative
302                     XS_Cwd_sys_is_rooted
303                     XS_DynaLoader_mod2fname
304                     XS_File__Copy_syscopy
305                     Perl_Register_MQ
306                     Perl_Deregister_MQ
307                     Perl_Serve_Messages
308                     Perl_Process_Messages
309                     init_PMWIN_entries
310                     PMWIN_entries
311                     Perl_hab_GET
312                     )]);
313 }
314
315 unless ($define{'DEBUGGING'}) {
316     skip_symbols [qw(
317                     Perl_deb
318                     Perl_deb_growlevel
319                     Perl_debop
320                     Perl_debprofdump
321                     Perl_debstack
322                     Perl_debstackptrs
323                     Perl_runops_debug
324                     Perl_sv_peek
325                     PL_block_type
326                     PL_watchaddr
327                     PL_watchok
328                     )];
329 }
330
331 if ($define{'PERL_IMPLICIT_SYS'}) {
332     skip_symbols [qw(
333                     Perl_getenv_len
334                     Perl_my_popen
335                     Perl_my_pclose
336                     )];
337 }
338 else {
339     skip_symbols [qw(
340                     PL_Mem
341                     PL_MemShared
342                     PL_MemParse
343                     PL_Env
344                     PL_StdIO
345                     PL_LIO
346                     PL_Dir
347                     PL_Sock
348                     PL_Proc
349                     )];
350 }
351
352 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
353     skip_symbols [qw(
354                     PL_protect
355                     Perl_default_protect
356                     Perl_vdefault_protect
357                     )];
358 }
359
360 if ($define{'MYMALLOC'}) {
361     emit_symbols [qw(
362                     Perl_dump_mstats
363                     Perl_get_mstats
364                     Perl_malloc
365                     Perl_mfree
366                     Perl_realloc
367                     Perl_calloc
368                     )];
369     if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
370         emit_symbols [qw(
371                         PL_malloc_mutex
372                         )];
373     }
374     else {
375         skip_symbols [qw(
376                         PL_malloc_mutex
377                         )];
378     }
379 }
380 else {
381     skip_symbols [qw(
382                     PL_malloc_mutex
383                     Perl_dump_mstats
384                     Perl_get_mstats
385                     Perl_malloc
386                     Perl_mfree
387                     Perl_realloc
388                     Perl_calloc
389                     Perl_malloced_size
390                     )];
391 }
392
393 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
394     skip_symbols [qw(
395                     PL_thr_key
396                     )];
397 }
398
399 unless ($define{'USE_5005THREADS'}) {
400     skip_symbols [qw(
401                     PL_sv_mutex
402                     PL_strtab_mutex
403                     PL_svref_mutex
404                     PL_cred_mutex
405                     PL_eval_mutex
406                     PL_fdpid_mutex
407                     PL_sv_lock_mutex
408                     PL_eval_cond
409                     PL_eval_owner
410                     PL_threads_mutex
411                     PL_nthreads
412                     PL_nthreads_cond
413                     PL_threadnum
414                     PL_threadsv_names
415                     PL_thrsv
416                     PL_vtbl_mutex
417                     Perl_condpair_magic
418                     Perl_new_struct_thread
419                     Perl_per_thread_magicals
420                     Perl_thread_create
421                     Perl_find_threadsv
422                     Perl_unlock_condpair
423                     Perl_magic_mutexfree
424                     Perl_sv_lock
425                     )];
426 }
427
428 unless ($define{'USE_ITHREADS'}) {
429     skip_symbols [qw(
430                     PL_ptr_table
431                     PL_op_mutex
432                     Perl_dirp_dup
433                     Perl_cx_dup
434                     Perl_si_dup
435                     Perl_any_dup
436                     Perl_ss_dup
437                     Perl_fp_dup
438                     Perl_gp_dup
439                     Perl_he_dup
440                     Perl_mg_dup
441                     Perl_re_dup
442                     Perl_sv_dup
443                     Perl_sys_intern_dup
444                     Perl_ptr_table_fetch
445                     Perl_ptr_table_new
446                     Perl_ptr_table_split
447                     Perl_ptr_table_store
448                     perl_clone
449                     perl_clone_using
450                     )];
451 }
452
453 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
454     skip_symbols [qw(
455                     Perl_croak_nocontext
456                     Perl_die_nocontext
457                     Perl_deb_nocontext
458                     Perl_form_nocontext
459                     Perl_load_module_nocontext
460                     Perl_mess_nocontext
461                     Perl_warn_nocontext
462                     Perl_warner_nocontext
463                     Perl_newSVpvf_nocontext
464                     Perl_sv_catpvf_nocontext
465                     Perl_sv_setpvf_nocontext
466                     Perl_sv_catpvf_mg_nocontext
467                     Perl_sv_setpvf_mg_nocontext
468                     )];
469 }
470
471 unless ($define{'PERL_IMPLICIT_SYS'}) {
472     skip_symbols [qw(
473                     perl_alloc_using
474                     perl_clone_using
475                     )];
476 }
477
478 unless ($define{'FAKE_THREADS'}) {
479     skip_symbols [qw(PL_curthr)];
480 }
481
482 sub readvar {
483     my $file = shift;
484     my $proc = shift || sub { "PL_$_[2]" };
485     open(VARS,$file) || die "Cannot open $file: $!\n";
486     my @syms;
487     while (<VARS>) {
488         # All symbols have a Perl_ prefix because that's what embed.h
489         # sticks in front of them.
490         push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
491     } 
492     close(VARS); 
493     return \@syms;
494 }
495
496 if ($define{'USE_5005THREADS'}) {
497     my $thrd = readvar($thrdvar_h);
498     skip_symbols $thrd;
499 }
500
501 if ($define{'PERL_GLOBAL_STRUCT'}) {
502     my $global = readvar($perlvars_h);
503     skip_symbols $global;
504     emit_symbol('Perl_GetVars');
505     emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
506 }
507
508 # functions from *.sym files
509
510 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
511
512 if ($define{'USE_PERLIO'}) {
513      push @syms, $perlio_sym;
514 }
515
516 for my $syms (@syms) {
517     open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
518     while (<GLOBAL>) {
519         next if (!/^[A-Za-z]/);
520         # Functions have a Perl_ prefix
521         # Variables have a PL_ prefix
522         chomp($_);
523         my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
524         $symbol .= $_;
525         emit_symbol($symbol) unless exists $skip{$symbol};
526     }
527     close(GLOBAL);
528 }
529
530 # variables
531
532 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
533     for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
534         my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
535         emit_symbols $glob;
536     }
537     # XXX AIX seems to want the perlvars.h symbols, for some reason
538     if ($PLATFORM eq 'aix') {
539         my $glob = readvar($perlvars_h);
540         emit_symbols $glob;
541     }
542 }
543 else {
544     unless ($define{'PERL_GLOBAL_STRUCT'}) {
545         my $glob = readvar($perlvars_h);
546         emit_symbols $glob;
547     } 
548     unless ($define{'MULTIPLICITY'}) {
549         my $glob = readvar($intrpvar_h);
550         emit_symbols $glob;
551     } 
552     unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
553         my $glob = readvar($thrdvar_h);
554         emit_symbols $glob;
555     } 
556 }
557
558 sub try_symbol {
559     my $symbol = shift;
560
561     return if $symbol !~ /^[A-Za-z]/;
562     return if $symbol =~ /^\#/;
563     $symbol =~s/\r//g;
564     chomp($symbol);
565     return if exists $skip{$symbol};
566     emit_symbol($symbol);
567 }
568
569 while (<DATA>) {
570     try_symbol($_);
571 }
572
573 if ($PLATFORM eq 'win32') {
574     foreach my $symbol (qw(
575                             boot_DynaLoader
576                             Perl_init_os_extras
577                             Perl_thread_create
578                             Perl_win32_init
579                             RunPerl
580                             win32_errno
581                             win32_environ
582                             win32_stdin
583                             win32_stdout
584                             win32_stderr
585                             win32_ferror
586                             win32_feof
587                             win32_strerror
588                             win32_fprintf
589                             win32_printf
590                             win32_vfprintf
591                             win32_vprintf
592                             win32_fread
593                             win32_fwrite
594                             win32_fopen
595                             win32_fdopen
596                             win32_freopen
597                             win32_fclose
598                             win32_fputs
599                             win32_fputc
600                             win32_ungetc
601                             win32_getc
602                             win32_fileno
603                             win32_clearerr
604                             win32_fflush
605                             win32_ftell
606                             win32_fseek
607                             win32_fgetpos
608                             win32_fsetpos
609                             win32_rewind
610                             win32_tmpfile
611                             win32_abort
612                             win32_fstat
613                             win32_stat
614                             win32_pipe
615                             win32_popen
616                             win32_pclose
617                             win32_rename
618                             win32_setmode
619                             win32_lseek
620                             win32_tell
621                             win32_dup
622                             win32_dup2
623                             win32_open
624                             win32_close
625                             win32_eof
626                             win32_read
627                             win32_write
628                             win32_spawnvp
629                             win32_mkdir
630                             win32_rmdir
631                             win32_chdir
632                             win32_flock
633                             win32_execv
634                             win32_execvp
635                             win32_htons
636                             win32_ntohs
637                             win32_htonl
638                             win32_ntohl
639                             win32_inet_addr
640                             win32_inet_ntoa
641                             win32_socket
642                             win32_bind
643                             win32_listen
644                             win32_accept
645                             win32_connect
646                             win32_send
647                             win32_sendto
648                             win32_recv
649                             win32_recvfrom
650                             win32_shutdown
651                             win32_closesocket
652                             win32_ioctlsocket
653                             win32_setsockopt
654                             win32_getsockopt
655                             win32_getpeername
656                             win32_getsockname
657                             win32_gethostname
658                             win32_gethostbyname
659                             win32_gethostbyaddr
660                             win32_getprotobyname
661                             win32_getprotobynumber
662                             win32_getservbyname
663                             win32_getservbyport
664                             win32_select
665                             win32_endhostent
666                             win32_endnetent
667                             win32_endprotoent
668                             win32_endservent
669                             win32_getnetent
670                             win32_getnetbyname
671                             win32_getnetbyaddr
672                             win32_getprotoent
673                             win32_getservent
674                             win32_sethostent
675                             win32_setnetent
676                             win32_setprotoent
677                             win32_setservent
678                             win32_getenv
679                             win32_putenv
680                             win32_perror
681                             win32_setbuf
682                             win32_setvbuf
683                             win32_flushall
684                             win32_fcloseall
685                             win32_fgets
686                             win32_gets
687                             win32_fgetc
688                             win32_putc
689                             win32_puts
690                             win32_getchar
691                             win32_putchar
692                             win32_malloc
693                             win32_calloc
694                             win32_realloc
695                             win32_free
696                             win32_sleep
697                             win32_times
698                             win32_access
699                             win32_alarm
700                             win32_chmod
701                             win32_open_osfhandle
702                             win32_get_osfhandle
703                             win32_ioctl
704                             win32_link
705                             win32_unlink
706                             win32_utime
707                             win32_uname
708                             win32_wait
709                             win32_waitpid
710                             win32_kill
711                             win32_str_os_error
712                             win32_opendir
713                             win32_readdir
714                             win32_telldir
715                             win32_seekdir
716                             win32_rewinddir
717                             win32_closedir
718                             win32_longpath
719                             win32_os_id
720                             win32_getpid
721                             win32_crypt
722                             win32_dynaload
723                            ))
724     {
725         try_symbol($symbol);
726     }
727 }
728 elsif ($PLATFORM eq 'os2') {
729     open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
730     /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
731     close MAP or die 'Cannot close miniperl.map';
732
733     @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
734                     keys %export;
735     delete $export{$_} foreach @missing;
736 }
737
738 # Now all symbols should be defined because
739 # next we are going to output them.
740
741 foreach my $symbol (sort keys %export) {
742     output_symbol($symbol);
743 }
744
745 sub emit_symbol {
746     my $symbol = shift;
747     chomp($symbol); 
748     $export{$symbol} = 1;
749 }
750
751 sub output_symbol {
752     my $symbol = shift;
753     $symbol = $bincompat5005{$symbol}
754         if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
755     if ($PLATFORM eq 'win32') {
756         $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
757         print "\t$symbol\n";
758 # XXX: binary compatibility between compilers is an exercise
759 # in frustration :-(
760 #        if ($CCTYPE eq "BORLAND") {
761 #           # workaround Borland quirk by exporting both the straight
762 #           # name and a name with leading underscore.  Note the
763 #           # alias *must* come after the symbol itself, if both
764 #           # are to be exported. (Linker bug?)
765 #           print "\t_$symbol\n";
766 #           print "\t$symbol = _$symbol\n";
767 #       }
768 #       elsif ($CCTYPE eq 'GCC') {
769 #           # Symbols have leading _ whole process is $%@"% slow
770 #           # so skip aliases for now
771 #           nprint "\t$symbol\n";
772 #       }
773 #       else {
774 #           # for binary coexistence, export both the symbol and
775 #           # alias with leading underscore
776 #           print "\t$symbol\n";
777 #           print "\t_$symbol = $symbol\n";
778 #       }
779     }
780     elsif ($PLATFORM eq 'os2') {
781         print qq(    "$symbol"\n);
782     }
783     elsif ($PLATFORM eq 'aix') {
784         print "$symbol\n";
785     }
786 }
787
788 1;
789 __DATA__
790 # extra globals not included above.
791 perl_alloc
792 perl_alloc_using
793 perl_clone
794 perl_clone_using
795 perl_construct
796 perl_destruct
797 perl_free
798 perl_parse
799 perl_run