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