This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix bytecode.pl with moved var names
[perl5.git] / win32 / makedef.pl
CommitLineData
0a753a76
PP
1#!../miniperl
2
3# Written: 10 April 1996 Gary Ng (71564.1743@compuserve.com)
4
5# Create the export list for perl.
6# Needed by WIN32 for creating perl.dll
7# based on perl_exp.SH in the main perl distribution directory
8
9# This simple program relys on 'global.sym' being up to date
10# with all of the global symbols that a dynamicly link library
11# might want to access.
12
13# There is some symbol defined in global.sym and interp.sym
14# that does not present in the WIN32 port but there is no easy
84902520 15# way to find them so I just put a exception list here
0a753a76 16
910dfcc8
GS
17my $CCTYPE = "MSVC"; # default
18
19while (@ARGV)
d55594ae
GS
20 {
21 my $flag = shift;
22 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
910dfcc8 23 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
d55594ae
GS
24 }
25
bbc8f9de
NIS
26open(CFG,'config.h') || die "Cannot open config.h:$!";
27while (<CFG>)
28 {
29 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
924b3ec4 30 $define{$1} = 1 if /^\s*#\s*define\s+(USE_THREADS)\b/;
bbc8f9de
NIS
31 }
32close(CFG);
33
d55594ae
GS
34warn join(' ',keys %define)."\n";
35
ac4c12e7
GS
36if ($define{PERL_OBJECT}) {
37 print "LIBRARY PerlCore\n";
38 print "DESCRIPTION 'Perl interpreter'\n";
39 print "EXPORTS\n";
40 output_symbol("perl_alloc");
41 exit(0);
42}
43
04dc04aa
NIS
44if ($CCTYPE ne 'GCC')
45 {
46 print "LIBRARY Perl\n";
47 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
04dc04aa 48 }
22239a37
NIS
49else
50 {
51 $define{'PERL_GLOBAL_STRUCT'} = 1;
52 $define{'MULTIPLICITY'} = 1;
53 }
54
bbc8f9de
NIS
55print "EXPORTS\n";
56
22239a37
NIS
57my %skip;
58my %export;
59
60sub skip_symbols
61{
62 my $list = shift;
63 foreach my $symbol (@$list)
64 {
65 $skip{$symbol} = 1;
66 }
67}
68
69sub emit_symbols
70{
71 my $list = shift;
72 foreach my $symbol (@$list)
73 {
74 emit_symbol($symbol) unless exists $skip{$symbol};
75 }
76}
77
78skip_symbols [qw(
79Perl_statusvalue_vms
9d8a25dc 80Perl_archpat_auto
0a753a76 81Perl_block_type
0a753a76
PP
82Perl_additem
83Perl_cast_ulong
84Perl_check_uni
85Perl_checkcomma
86Perl_chsize
87Perl_ck_aelem
88Perl_cryptseen
89Perl_cx_dump
9d8a25dc 90Perl_DBcv
0a753a76
PP
91Perl_do_ipcctl
92Perl_do_ipcget
93Perl_do_msgrcv
94Perl_do_msgsnd
95Perl_do_semop
96Perl_do_shmio
97Perl_doeval
98Perl_dofindlabel
99Perl_dopoptoeval
100Perl_dump_eval
101Perl_dump_fds
102Perl_dump_form
103Perl_dump_gv
104Perl_dump_mstats
105Perl_dump_op
106Perl_dump_packsubs
107Perl_dump_pm
108Perl_dump_sub
109Perl_expectterm
110Perl_fetch_gv
111Perl_fetch_io
112Perl_force_ident
113Perl_force_next
114Perl_force_word
9d8a25dc 115Perl_generation
0a753a76 116Perl_hv_stashpv
9d8a25dc
DL
117Perl_in_clean_all
118Perl_in_clean_objs
0a753a76 119Perl_intuit_more
d55594ae 120Perl_init_thread_intern
0a753a76 121Perl_know_next
9d8a25dc
DL
122Perl_lastgotoprobe
123Perl_linestart
124Perl_modcount
0a753a76
PP
125Perl_modkids
126Perl_mstats
127Perl_my_bzero
128Perl_my_htonl
129Perl_my_ntohl
130Perl_my_swap
131Perl_my_chsize
132Perl_newXSUB
133Perl_no_fh_allowed
134Perl_no_op
135Perl_nointrp
136Perl_nomem
9d8a25dc 137Perl_pending_ident
0a753a76
PP
138Perl_pp_cswitch
139Perl_pp_entersubr
140Perl_pp_evalonce
141Perl_pp_interp
142Perl_pp_map
143Perl_pp_nswitch
144Perl_q
d55594ae 145Perl_rcsid
0a753a76 146Perl_reall_srchlen
0a753a76
PP
147Perl_same_dirent
148Perl_saw_return
149Perl_scan_const
150Perl_scan_formline
151Perl_scan_heredoc
152Perl_scan_ident
153Perl_scan_inputsymbol
154Perl_scan_pat
155Perl_scan_prefix
156Perl_scan_str
157Perl_scan_subst
158Perl_scan_trans
159Perl_scan_word
68dc0745 160Perl_setenv_getix
0a753a76 161Perl_skipspace
76e3520e 162Perl_sort_mutex
9d8a25dc 163Perl_sortcxix
0a753a76 164Perl_sublex_done
9d8a25dc 165Perl_sublex_info
0a753a76 166Perl_sublex_start
0a753a76
PP
167Perl_sv_ref
168Perl_sv_setptrobj
169Perl_timesbuf
170Perl_too_few_arguments
171Perl_too_many_arguments
172Perl_unlnk
0a753a76
PP
173Perl_watch
174Perl_yyname
175Perl_yyrule
176allgvs
177curblock
0a753a76 178curcsv
0a753a76
PP
179lastretstr
180mystack_mark
181perl_init_ext
182perl_requirepv
0a753a76 183stack
ff0cee69 184statusvalue_vms
0a753a76
PP
185Perl_safexcalloc
186Perl_safexmalloc
187Perl_safexfree
188Perl_safexrealloc
68dc0745 189Perl_my_memcmp
8b10511d 190Perl_my_memset
68dc0745
PP
191Perl_cshlen
192Perl_cshname
0da3735a 193Perl_opsave
22239a37 194)];
0a753a76 195
c69f112c 196
bbc8f9de
NIS
197if ($define{'MYMALLOC'})
198 {
22239a37
NIS
199 skip_symbols [qw(
200 Perl_safefree
201 Perl_safemalloc
202 Perl_saferealloc
203 Perl_safecalloc)];
204 emit_symbols [qw(
205 Perl_malloc
206 Perl_free
207 Perl_realloc
208 Perl_calloc)];
bbc8f9de 209 }
32fcaa0b
GS
210else
211 {
212 skip_symbols [qw(
213 Perl_malloced_size)];
214 }
bbc8f9de 215
d55594ae
GS
216unless ($define{'USE_THREADS'})
217 {
22239a37 218 skip_symbols [qw(
eb480a0b
GS
219Perl_getTHR
220Perl_setTHR
d55594ae
GS
221Perl_condpair_magic
222Perl_thr_key
223Perl_sv_mutex
319b3e9e 224Perl_svref_mutex
d55594ae
GS
225Perl_malloc_mutex
226Perl_eval_mutex
227Perl_eval_cond
228Perl_eval_owner
229Perl_threads_mutex
32f822de
GS
230Perl_new_struct_thread
231Perl_nthreads
d55594ae 232Perl_nthreads_cond
32f822de 233Perl_per_thread_magicals
d4cce5f1 234Perl_thread_create
93bce2dc 235Perl_threadnum
d4cce5f1
NIS
236Perl_find_threadsv
237Perl_threadsv_names
32f822de 238Perl_thrsv
d55594ae
GS
239Perl_unlock_condpair
240Perl_vtbl_mutex
241Perl_magic_mutexfree
242Perl_sv_iv
243Perl_sv_nv
244Perl_sv_true
245Perl_sv_uv
246Perl_sv_pvn
95906810 247)];
910dfcc8 248 }
d4cce5f1 249
910dfcc8
GS
250unless ($define{'FAKE_THREADS'})
251 {
252 skip_symbols [qw(Perl_curthr)];
d55594ae
GS
253 }
254
22239a37
NIS
255sub readvar
256{
257 my $file = shift;
258 open(VARS,$file) || die "Cannot open $file:$!";
259 my @syms;
260 while (<VARS>)
261 {
262 # All symbols have a Perl_ prefix because that's what embed.h
263 # sticks in front of them.
83921c94 264 push(@syms,"Perl_".$1) if (/\bPERLVARI?C?\([IGT](\w+)/);
22239a37
NIS
265 }
266 close(VARS);
267 return \@syms;
268}
269
d4cce5f1 270if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 271 {
22239a37
NIS
272 my $thrd = readvar("../thrdvar.h");
273 skip_symbols $thrd;
d55594ae
GS
274 }
275
d4cce5f1 276if ($define{'MULTIPLICITY'})
d55594ae 277 {
22239a37
NIS
278 my $interp = readvar("../intrpvar.h");
279 skip_symbols $interp;
280 }
281
282if ($define{'PERL_GLOBAL_STRUCT'})
283 {
284 my $global = readvar("../perlvars.h");
285 skip_symbols $global;
852c2e52
GS
286 emit_symbols [qw(Perl_GetVars)];
287 emit_symbols [qw(Perl_Vars Perl_VarsPtr)] unless $CCTYPE eq 'GCC';
d4cce5f1 288 }
d55594ae 289
36c15d3f
NIS
290unless ($define{'DEBUGGING'})
291 {
22239a37 292 skip_symbols [qw(
fea7140c
GS
293 Perl_deb
294 Perl_deb_growlevel
295 Perl_debop
296 Perl_debprofdump
297 Perl_debstack
298 Perl_debstackptrs
22239a37
NIS
299 Perl_runops_debug
300 Perl_sv_peek
301 Perl_watchaddr
302 Perl_watchok)];
36c15d3f
NIS
303 }
304
26618a56
GS
305if ($define{'HAVE_DES_FCRYPT'})
306 {
307 emit_symbols [qw(win32_crypt)];
308 }
309
0a753a76 310open (GLOBAL, "<../global.sym") || die "failed to open global.sym" . $!;
22239a37
NIS
311while (<GLOBAL>)
312 {
313 next if (!/^[A-Za-z]/);
314 next if (/_amg[ \t]*$/);
315 # All symbols have a Perl_ prefix because that's what embed.h
316 # sticks in front of them.
317 chomp($_);
318 my $symbol = "Perl_$_";
319 emit_symbol($symbol) unless exists $skip{$symbol};
320 }
0a753a76
PP
321close(GLOBAL);
322
323# also add symbols from interp.sym
324# They are only needed if -DMULTIPLICITY is not set but it
325# doesn't hurt to include them anyway.
326# these don't have Perl prefix
327
852c2e52 328unless ($define{'PERL_GLOBAL_STRUCT'})
22239a37
NIS
329 {
330 my $glob = readvar("../perlvars.h");
331 emit_symbols $glob;
332 }
333
334unless ($define{'MULTIPLICITY'})
335 {
336 my $glob = readvar("../intrpvar.h");
337 emit_symbols $glob;
338 }
0a753a76 339
22239a37
NIS
340unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'})
341 {
342 my $glob = readvar("../thrdvar.h");
343 emit_symbols $glob;
344 }
0a753a76
PP
345
346while (<DATA>) {
347 my $symbol;
348 next if (!/^[A-Za-z]/);
349 next if (/^#/);
a868473f 350 s/\r//g;
22239a37 351 chomp($_);
0a753a76 352 $symbol = $_;
22239a37 353 next if exists $skip{$symbol};
3e3baf6d
TB
354 emit_symbol($symbol);
355}
356
22239a37
NIS
357foreach my $symbol (sort keys %export)
358 {
ac4c12e7 359 output_symbol($symbol);
22239a37
NIS
360 }
361
362sub emit_symbol {
363 my $symbol = shift;
364 chomp($symbol);
365 $export{$symbol} = 1;
3e3baf6d 366}
0a753a76 367
ac4c12e7
GS
368sub output_symbol {
369 my $symbol = shift;
370 if ($CCTYPE eq "BORLAND") {
371 # workaround Borland quirk by exporting both the straight
372 # name and a name with leading underscore. Note the
373 # alias *must* come after the symbol itself, if both
374 # are to be exported. (Linker bug?)
375 print "\t_$symbol\n";
376 print "\t$symbol = _$symbol\n";
377 }
378 elsif ($CCTYPE eq 'GCC') {
379 # Symbols have leading _ whole process is $%£"% slow
380 # so skip aliases for now
381 print "\t$symbol\n";
382 }
383 else {
384 # for binary coexistence, export both the symbol and
385 # alias with leading underscore
386 print "\t$symbol\n";
387 print "\t_$symbol = $symbol\n";
388 }
389}
390
0a753a76
PP
3911;
392__DATA__
393# extra globals not included above.
394perl_init_i18nl10n
395perl_init_ext
396perl_alloc
4b556e6c 397perl_atexit
0a753a76
PP
398perl_construct
399perl_destruct
400perl_free
401perl_parse
402perl_run
403perl_get_sv
404perl_get_av
405perl_get_hv
406perl_get_cv
407perl_call_argv
408perl_call_pv
409perl_call_method
410perl_call_sv
10dd38fc
GS
411perl_require_pv
412perl_eval_pv
413perl_eval_sv
6dead956
GS
414perl_new_ctype
415perl_new_collate
416perl_new_numeric
417perl_set_numeric_standard
418perl_set_numeric_local
d28b3ca3 419boot_DynaLoader
d55594ae 420Perl_thread_create
68dc0745 421win32_errno
96e4d5b1 422win32_environ
68dc0745
PP
423win32_stdin
424win32_stdout
96e4d5b1 425win32_stderr
68dc0745
PP
426win32_ferror
427win32_feof
428win32_strerror
429win32_fprintf
430win32_printf
431win32_vfprintf
96e4d5b1 432win32_vprintf
68dc0745
PP
433win32_fread
434win32_fwrite
435win32_fopen
436win32_fdopen
437win32_freopen
438win32_fclose
439win32_fputs
440win32_fputc
441win32_ungetc
442win32_getc
443win32_fileno
444win32_clearerr
445win32_fflush
446win32_ftell
447win32_fseek
448win32_fgetpos
449win32_fsetpos
450win32_rewind
451win32_tmpfile
452win32_abort
453win32_fstat
96e4d5b1 454win32_stat
68dc0745
PP
455win32_pipe
456win32_popen
457win32_pclose
e24c7c18 458win32_rename
68dc0745 459win32_setmode
96e4d5b1
PP
460win32_lseek
461win32_tell
68dc0745
PP
462win32_dup
463win32_dup2
96e4d5b1
PP
464win32_open
465win32_close
466win32_eof
68dc0745
PP
467win32_read
468win32_write
3e3baf6d 469win32_spawnvp
5aabfad6
PP
470win32_mkdir
471win32_rmdir
472win32_chdir
c90c0ff4 473win32_flock
eb62e965 474win32_execv
6890e559 475win32_execvp
54310121
PP
476win32_htons
477win32_ntohs
478win32_htonl
479win32_ntohl
480win32_inet_addr
481win32_inet_ntoa
482win32_socket
483win32_bind
484win32_listen
485win32_accept
486win32_connect
487win32_send
488win32_sendto
489win32_recv
490win32_recvfrom
491win32_shutdown
3a25acb4 492win32_closesocket
54310121
PP
493win32_ioctlsocket
494win32_setsockopt
495win32_getsockopt
496win32_getpeername
497win32_getsockname
498win32_gethostname
499win32_gethostbyname
500win32_gethostbyaddr
501win32_getprotobyname
502win32_getprotobynumber
503win32_getservbyname
504win32_getservbyport
505win32_select
506win32_endhostent
507win32_endnetent
508win32_endprotoent
509win32_endservent
510win32_getnetent
511win32_getnetbyname
512win32_getnetbyaddr
513win32_getprotoent
514win32_getservent
515win32_sethostent
516win32_setnetent
517win32_setprotoent
518win32_setservent
ad2e33dc 519win32_getenv
84902520
TB
520win32_perror
521win32_setbuf
522win32_setvbuf
523win32_flushall
524win32_fcloseall
525win32_fgets
526win32_gets
527win32_fgetc
528win32_putc
529win32_puts
530win32_getchar
531win32_putchar
532win32_malloc
533win32_calloc
534win32_realloc
535win32_free
f3986ebb
GS
536win32_sleep
537win32_times
538win32_alarm
65e48ea9
GS
539win32_open_osfhandle
540win32_get_osfhandle
f998180f 541win32_ioctl
ad0751ec 542win32_utime
22fae026 543win32_wait
f55ee38a
GS
544win32_waitpid
545win32_kill
22fae026 546win32_str_os_error
ce2e26e5
GS
547win32_opendir
548win32_readdir
549win32_telldir
550win32_seekdir
551win32_rewinddir
552win32_closedir
ad2e33dc 553Perl_win32_init
f3986ebb 554Perl_init_os_extras
9811a7d7 555Perl_getTHR
0fefa03b 556Perl_setTHR
84902520 557RunPerl
22239a37 558