big Configure update from Jarkko: sync metaconfig units; d_statblks fix
[p5sagit/p5-mst-13.2.git] / win32 / makedef.pl
CommitLineData
0a753a76 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 17my $CCTYPE = "MSVC"; # default
18
19while (@ARGV)
d55594ae 20 {
21 my $flag = shift;
22 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
910dfcc8 23 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
d55594ae 24 }
25
bbc8f9de 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 31 }
32close(CFG);
33
d55594ae 34warn join(' ',keys %define)."\n";
35
ac4c12e7 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 44if ($CCTYPE ne 'GCC')
45 {
46 print "LIBRARY Perl\n";
47 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
04dc04aa 48 }
22239a37 49else
50 {
51 $define{'PERL_GLOBAL_STRUCT'} = 1;
52 $define{'MULTIPLICITY'} = 1;
53 }
54
bbc8f9de 55print "EXPORTS\n";
56
22239a37 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(
db15561c 79PL_statusvalue_vms
80PL_archpat_auto
81PL_cryptseen
82PL_DBcv
83PL_generation
84PL_in_clean_all
85PL_in_clean_objs
86PL_lastgotoprobe
87PL_linestart
88PL_modcount
89PL_pending_ident
90PL_sortcxix
91PL_sublex_info
92PL_timesbuf
0a753a76 93Perl_block_type
0a753a76 94Perl_additem
95Perl_cast_ulong
96Perl_check_uni
97Perl_checkcomma
98Perl_chsize
99Perl_ck_aelem
0a753a76 100Perl_cx_dump
0a753a76 101Perl_do_ipcctl
102Perl_do_ipcget
103Perl_do_msgrcv
104Perl_do_msgsnd
105Perl_do_semop
106Perl_do_shmio
107Perl_doeval
108Perl_dofindlabel
109Perl_dopoptoeval
110Perl_dump_eval
111Perl_dump_fds
112Perl_dump_form
113Perl_dump_gv
114Perl_dump_mstats
115Perl_dump_op
116Perl_dump_packsubs
117Perl_dump_pm
118Perl_dump_sub
119Perl_expectterm
120Perl_fetch_gv
121Perl_fetch_io
122Perl_force_ident
123Perl_force_next
124Perl_force_word
125Perl_hv_stashpv
126Perl_intuit_more
d55594ae 127Perl_init_thread_intern
0a753a76 128Perl_know_next
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
141Perl_pp_cswitch
142Perl_pp_entersubr
143Perl_pp_evalonce
144Perl_pp_interp
145Perl_pp_map
146Perl_pp_nswitch
147Perl_q
148Perl_reall_srchlen
0a753a76 149Perl_same_dirent
150Perl_saw_return
151Perl_scan_const
152Perl_scan_formline
153Perl_scan_heredoc
154Perl_scan_ident
155Perl_scan_inputsymbol
156Perl_scan_pat
157Perl_scan_prefix
158Perl_scan_str
159Perl_scan_subst
160Perl_scan_trans
161Perl_scan_word
68dc0745 162Perl_setenv_getix
0a753a76 163Perl_skipspace
76e3520e 164Perl_sort_mutex
0a753a76 165Perl_sublex_done
166Perl_sublex_start
0a753a76 167Perl_sv_ref
168Perl_sv_setptrobj
0a753a76 169Perl_too_few_arguments
170Perl_too_many_arguments
171Perl_unlnk
0a753a76 172Perl_watch
173Perl_yyname
174Perl_yyrule
175allgvs
176curblock
0a753a76 177curcsv
0a753a76 178lastretstr
179mystack_mark
180perl_init_ext
181perl_requirepv
0a753a76 182stack
0a753a76 183Perl_safexcalloc
184Perl_safexmalloc
185Perl_safexfree
186Perl_safexrealloc
68dc0745 187Perl_my_memcmp
8b10511d 188Perl_my_memset
db15561c 189PL_cshlen
190PL_cshname
191PL_opsave
22239a37 192)];
0a753a76 193
c69f112c 194
bbc8f9de 195if ($define{'MYMALLOC'})
196 {
22239a37 197 skip_symbols [qw(
198 Perl_safefree
199 Perl_safemalloc
200 Perl_saferealloc
201 Perl_safecalloc)];
202 emit_symbols [qw(
203 Perl_malloc
204 Perl_free
205 Perl_realloc
206 Perl_calloc)];
bbc8f9de 207 }
32fcaa0b 208else
209 {
210 skip_symbols [qw(
211 Perl_malloced_size)];
212 }
bbc8f9de 213
d55594ae 214unless ($define{'USE_THREADS'})
215 {
22239a37 216 skip_symbols [qw(
db15561c 217PL_thr_key
218PL_sv_mutex
46124e9e 219PL_strtab_mutex
db15561c 220PL_svref_mutex
221PL_malloc_mutex
5ff3f7a4 222PL_cred_mutex
db15561c 223PL_eval_mutex
224PL_eval_cond
225PL_eval_owner
226PL_threads_mutex
227PL_nthreads
228PL_nthreads_cond
229PL_threadnum
230PL_threadsv_names
231PL_thrsv
232Perl_vtbl_mutex
eb480a0b 233Perl_getTHR
234Perl_setTHR
d55594ae 235Perl_condpair_magic
32f822de 236Perl_new_struct_thread
32f822de 237Perl_per_thread_magicals
d4cce5f1 238Perl_thread_create
239Perl_find_threadsv
d55594ae 240Perl_unlock_condpair
d55594ae 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 250unless ($define{'FAKE_THREADS'})
251 {
db15561c 252 skip_symbols [qw(PL_curthr)];
d55594ae 253 }
254
22239a37 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.
db15561c 264 push(@syms,"PL_".$1) if (/\bPERLVARI?C?\([IGT](\w+)/);
22239a37 265 }
266 close(VARS);
267 return \@syms;
268}
269
d4cce5f1 270if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 271 {
22239a37 272 my $thrd = readvar("../thrdvar.h");
273 skip_symbols $thrd;
d55594ae 274 }
275
d4cce5f1 276if ($define{'MULTIPLICITY'})
d55594ae 277 {
22239a37 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 286 emit_symbols [qw(Perl_GetVars)];
db15561c 287 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
d4cce5f1 288 }
d55594ae 289
36c15d3f 290unless ($define{'DEBUGGING'})
291 {
22239a37 292 skip_symbols [qw(
fea7140c 293 Perl_deb
294 Perl_deb_growlevel
295 Perl_debop
296 Perl_debprofdump
297 Perl_debstack
298 Perl_debstackptrs
22239a37 299 Perl_runops_debug
300 Perl_sv_peek
301 Perl_watchaddr
302 Perl_watchok)];
36c15d3f 303 }
304
26618a56 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 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 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 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 340unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'})
341 {
342 my $glob = readvar("../thrdvar.h");
343 emit_symbols $glob;
344 }
0a753a76 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 354 emit_symbol($symbol);
355}
356
22239a37 357foreach my $symbol (sort keys %export)
358 {
ac4c12e7 359 output_symbol($symbol);
22239a37 360 }
361
362sub emit_symbol {
363 my $symbol = shift;
364 chomp($symbol);
365 $export{$symbol} = 1;
3e3baf6d 366}
0a753a76 367
ac4c12e7 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 3911;
392__DATA__
393# extra globals not included above.
394perl_init_i18nl10n
395perl_init_ext
396perl_alloc
4b556e6c 397perl_atexit
0a753a76 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 411perl_require_pv
412perl_eval_pv
413perl_eval_sv
6dead956 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 423win32_stdin
424win32_stdout
96e4d5b1 425win32_stderr
68dc0745 426win32_ferror
427win32_feof
428win32_strerror
429win32_fprintf
430win32_printf
431win32_vfprintf
96e4d5b1 432win32_vprintf
68dc0745 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 455win32_pipe
456win32_popen
457win32_pclose
e24c7c18 458win32_rename
68dc0745 459win32_setmode
96e4d5b1 460win32_lseek
461win32_tell
68dc0745 462win32_dup
463win32_dup2
96e4d5b1 464win32_open
465win32_close
466win32_eof
68dc0745 467win32_read
468win32_write
3e3baf6d 469win32_spawnvp
5aabfad6 470win32_mkdir
471win32_rmdir
472win32_chdir
c90c0ff4 473win32_flock
eb62e965 474win32_execv
6890e559 475win32_execvp
54310121 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 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 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 536win32_sleep
537win32_times
538win32_alarm
65e48ea9 539win32_open_osfhandle
540win32_get_osfhandle
f998180f 541win32_ioctl
ad0751ec 542win32_utime
22fae026 543win32_wait
f55ee38a 544win32_waitpid
545win32_kill
22fae026 546win32_str_os_error
ce2e26e5 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