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