win32 tweaks
[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
219PL_svref_mutex
220PL_malloc_mutex
221PL_eval_mutex
222PL_eval_cond
223PL_eval_owner
224PL_threads_mutex
225PL_nthreads
226PL_nthreads_cond
227PL_threadnum
228PL_threadsv_names
229PL_thrsv
230Perl_vtbl_mutex
eb480a0b 231Perl_getTHR
232Perl_setTHR
d55594ae 233Perl_condpair_magic
32f822de 234Perl_new_struct_thread
32f822de 235Perl_per_thread_magicals
d4cce5f1 236Perl_thread_create
237Perl_find_threadsv
d55594ae 238Perl_unlock_condpair
d55594ae 239Perl_magic_mutexfree
240Perl_sv_iv
241Perl_sv_nv
242Perl_sv_true
243Perl_sv_uv
244Perl_sv_pvn
95906810 245)];
910dfcc8 246 }
d4cce5f1 247
910dfcc8 248unless ($define{'FAKE_THREADS'})
249 {
db15561c 250 skip_symbols [qw(PL_curthr)];
d55594ae 251 }
252
22239a37 253sub readvar
254{
255 my $file = shift;
256 open(VARS,$file) || die "Cannot open $file:$!";
257 my @syms;
258 while (<VARS>)
259 {
260 # All symbols have a Perl_ prefix because that's what embed.h
261 # sticks in front of them.
db15561c 262 push(@syms,"PL_".$1) if (/\bPERLVARI?C?\([IGT](\w+)/);
22239a37 263 }
264 close(VARS);
265 return \@syms;
266}
267
d4cce5f1 268if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 269 {
22239a37 270 my $thrd = readvar("../thrdvar.h");
271 skip_symbols $thrd;
d55594ae 272 }
273
d4cce5f1 274if ($define{'MULTIPLICITY'})
d55594ae 275 {
22239a37 276 my $interp = readvar("../intrpvar.h");
277 skip_symbols $interp;
278 }
279
280if ($define{'PERL_GLOBAL_STRUCT'})
281 {
282 my $global = readvar("../perlvars.h");
283 skip_symbols $global;
852c2e52 284 emit_symbols [qw(Perl_GetVars)];
db15561c 285 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
d4cce5f1 286 }
d55594ae 287
36c15d3f 288unless ($define{'DEBUGGING'})
289 {
22239a37 290 skip_symbols [qw(
fea7140c 291 Perl_deb
292 Perl_deb_growlevel
293 Perl_debop
294 Perl_debprofdump
295 Perl_debstack
296 Perl_debstackptrs
22239a37 297 Perl_runops_debug
298 Perl_sv_peek
299 Perl_watchaddr
300 Perl_watchok)];
36c15d3f 301 }
302
26618a56 303if ($define{'HAVE_DES_FCRYPT'})
304 {
305 emit_symbols [qw(win32_crypt)];
306 }
307
0a753a76 308open (GLOBAL, "<../global.sym") || die "failed to open global.sym" . $!;
22239a37 309while (<GLOBAL>)
310 {
311 next if (!/^[A-Za-z]/);
312 next if (/_amg[ \t]*$/);
313 # All symbols have a Perl_ prefix because that's what embed.h
314 # sticks in front of them.
315 chomp($_);
316 my $symbol = "Perl_$_";
317 emit_symbol($symbol) unless exists $skip{$symbol};
318 }
0a753a76 319close(GLOBAL);
320
321# also add symbols from interp.sym
322# They are only needed if -DMULTIPLICITY is not set but it
323# doesn't hurt to include them anyway.
324# these don't have Perl prefix
325
852c2e52 326unless ($define{'PERL_GLOBAL_STRUCT'})
22239a37 327 {
328 my $glob = readvar("../perlvars.h");
329 emit_symbols $glob;
330 }
331
332unless ($define{'MULTIPLICITY'})
333 {
334 my $glob = readvar("../intrpvar.h");
335 emit_symbols $glob;
336 }
0a753a76 337
22239a37 338unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'})
339 {
340 my $glob = readvar("../thrdvar.h");
341 emit_symbols $glob;
342 }
0a753a76 343
344while (<DATA>) {
345 my $symbol;
346 next if (!/^[A-Za-z]/);
347 next if (/^#/);
a868473f 348 s/\r//g;
22239a37 349 chomp($_);
0a753a76 350 $symbol = $_;
22239a37 351 next if exists $skip{$symbol};
3e3baf6d 352 emit_symbol($symbol);
353}
354
22239a37 355foreach my $symbol (sort keys %export)
356 {
ac4c12e7 357 output_symbol($symbol);
22239a37 358 }
359
360sub emit_symbol {
361 my $symbol = shift;
362 chomp($symbol);
363 $export{$symbol} = 1;
3e3baf6d 364}
0a753a76 365
ac4c12e7 366sub output_symbol {
367 my $symbol = shift;
368 if ($CCTYPE eq "BORLAND") {
369 # workaround Borland quirk by exporting both the straight
370 # name and a name with leading underscore. Note the
371 # alias *must* come after the symbol itself, if both
372 # are to be exported. (Linker bug?)
373 print "\t_$symbol\n";
374 print "\t$symbol = _$symbol\n";
375 }
376 elsif ($CCTYPE eq 'GCC') {
377 # Symbols have leading _ whole process is $%£"% slow
378 # so skip aliases for now
379 print "\t$symbol\n";
380 }
381 else {
382 # for binary coexistence, export both the symbol and
383 # alias with leading underscore
384 print "\t$symbol\n";
385 print "\t_$symbol = $symbol\n";
386 }
387}
388
0a753a76 3891;
390__DATA__
391# extra globals not included above.
392perl_init_i18nl10n
393perl_init_ext
394perl_alloc
4b556e6c 395perl_atexit
0a753a76 396perl_construct
397perl_destruct
398perl_free
399perl_parse
400perl_run
401perl_get_sv
402perl_get_av
403perl_get_hv
404perl_get_cv
405perl_call_argv
406perl_call_pv
407perl_call_method
408perl_call_sv
10dd38fc 409perl_require_pv
410perl_eval_pv
411perl_eval_sv
6dead956 412perl_new_ctype
413perl_new_collate
414perl_new_numeric
415perl_set_numeric_standard
416perl_set_numeric_local
d28b3ca3 417boot_DynaLoader
d55594ae 418Perl_thread_create
68dc0745 419win32_errno
96e4d5b1 420win32_environ
68dc0745 421win32_stdin
422win32_stdout
96e4d5b1 423win32_stderr
68dc0745 424win32_ferror
425win32_feof
426win32_strerror
427win32_fprintf
428win32_printf
429win32_vfprintf
96e4d5b1 430win32_vprintf
68dc0745 431win32_fread
432win32_fwrite
433win32_fopen
434win32_fdopen
435win32_freopen
436win32_fclose
437win32_fputs
438win32_fputc
439win32_ungetc
440win32_getc
441win32_fileno
442win32_clearerr
443win32_fflush
444win32_ftell
445win32_fseek
446win32_fgetpos
447win32_fsetpos
448win32_rewind
449win32_tmpfile
450win32_abort
451win32_fstat
96e4d5b1 452win32_stat
68dc0745 453win32_pipe
454win32_popen
455win32_pclose
e24c7c18 456win32_rename
68dc0745 457win32_setmode
96e4d5b1 458win32_lseek
459win32_tell
68dc0745 460win32_dup
461win32_dup2
96e4d5b1 462win32_open
463win32_close
464win32_eof
68dc0745 465win32_read
466win32_write
3e3baf6d 467win32_spawnvp
5aabfad6 468win32_mkdir
469win32_rmdir
470win32_chdir
c90c0ff4 471win32_flock
eb62e965 472win32_execv
6890e559 473win32_execvp
54310121 474win32_htons
475win32_ntohs
476win32_htonl
477win32_ntohl
478win32_inet_addr
479win32_inet_ntoa
480win32_socket
481win32_bind
482win32_listen
483win32_accept
484win32_connect
485win32_send
486win32_sendto
487win32_recv
488win32_recvfrom
489win32_shutdown
3a25acb4 490win32_closesocket
54310121 491win32_ioctlsocket
492win32_setsockopt
493win32_getsockopt
494win32_getpeername
495win32_getsockname
496win32_gethostname
497win32_gethostbyname
498win32_gethostbyaddr
499win32_getprotobyname
500win32_getprotobynumber
501win32_getservbyname
502win32_getservbyport
503win32_select
504win32_endhostent
505win32_endnetent
506win32_endprotoent
507win32_endservent
508win32_getnetent
509win32_getnetbyname
510win32_getnetbyaddr
511win32_getprotoent
512win32_getservent
513win32_sethostent
514win32_setnetent
515win32_setprotoent
516win32_setservent
ad2e33dc 517win32_getenv
84902520 518win32_perror
519win32_setbuf
520win32_setvbuf
521win32_flushall
522win32_fcloseall
523win32_fgets
524win32_gets
525win32_fgetc
526win32_putc
527win32_puts
528win32_getchar
529win32_putchar
530win32_malloc
531win32_calloc
532win32_realloc
533win32_free
f3986ebb 534win32_sleep
535win32_times
536win32_alarm
65e48ea9 537win32_open_osfhandle
538win32_get_osfhandle
f998180f 539win32_ioctl
ad0751ec 540win32_utime
22fae026 541win32_wait
f55ee38a 542win32_waitpid
543win32_kill
22fae026 544win32_str_os_error
ce2e26e5 545win32_opendir
546win32_readdir
547win32_telldir
548win32_seekdir
549win32_rewinddir
550win32_closedir
ad2e33dc 551Perl_win32_init
f3986ebb 552Perl_init_os_extras
9811a7d7 553Perl_getTHR
0fefa03b 554Perl_setTHR
84902520 555RunPerl
22239a37 556