tweak RefHash to make intent clearer (suggested by John Dlugosz)
[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
4f63d024 82main
83Perl_ErrorNo
84Perl_GetVars
a6c40364 85Perl_do_exec3
0a753a76 86Perl_do_ipcctl
87Perl_do_ipcget
88Perl_do_msgrcv
89Perl_do_msgsnd
90Perl_do_semop
91Perl_do_shmio
0a753a76 92Perl_dump_fds
d55594ae 93Perl_init_thread_intern
0a753a76 94Perl_my_bzero
95Perl_my_htonl
96Perl_my_ntohl
97Perl_my_swap
98Perl_my_chsize
0a753a76 99Perl_same_dirent
68dc0745 100Perl_setenv_getix
0a753a76 101Perl_unlnk
0a753a76 102Perl_watch
0a753a76 103Perl_safexcalloc
104Perl_safexmalloc
105Perl_safexfree
106Perl_safexrealloc
68dc0745 107Perl_my_memcmp
8b10511d 108Perl_my_memset
db15561c 109PL_cshlen
110PL_cshname
111PL_opsave
22239a37 112)];
0a753a76 113
c69f112c 114
bbc8f9de 115if ($define{'MYMALLOC'})
116 {
22239a37 117 emit_symbols [qw(
9423c6fc 118 Perl_dump_mstats
22239a37 119 Perl_malloc
f2517201 120 Perl_mfree
22239a37 121 Perl_realloc
122 Perl_calloc)];
bbc8f9de 123 }
32fcaa0b 124else
125 {
126 skip_symbols [qw(
df31f264 127 Perl_dump_mstats
4f63d024 128 Perl_malloc
129 Perl_mfree
130 Perl_realloc
131 Perl_calloc
32fcaa0b 132 Perl_malloced_size)];
133 }
bbc8f9de 134
d55594ae 135unless ($define{'USE_THREADS'})
136 {
22239a37 137 skip_symbols [qw(
db15561c 138PL_thr_key
139PL_sv_mutex
46124e9e 140PL_strtab_mutex
db15561c 141PL_svref_mutex
142PL_malloc_mutex
5ff3f7a4 143PL_cred_mutex
db15561c 144PL_eval_mutex
145PL_eval_cond
146PL_eval_owner
147PL_threads_mutex
148PL_nthreads
149PL_nthreads_cond
150PL_threadnum
151PL_threadsv_names
152PL_thrsv
22c35a8c 153PL_vtbl_mutex
eb480a0b 154Perl_getTHR
155Perl_setTHR
d55594ae 156Perl_condpair_magic
32f822de 157Perl_new_struct_thread
32f822de 158Perl_per_thread_magicals
d4cce5f1 159Perl_thread_create
160Perl_find_threadsv
d55594ae 161Perl_unlock_condpair
d55594ae 162Perl_magic_mutexfree
95906810 163)];
910dfcc8 164 }
4f63d024 165unless ($define{'USE_THREADS'} or $define{'PERL_IMPLICIT_CONTEXT'})
166 {
167 skip_symbols [qw(
168 Perl_croak_nocontext
169 Perl_die_nocontext
170 Perl_form_nocontext
171 Perl_warn_nocontext
172 Perl_newSVpvf_nocontext
173 Perl_sv_catpvf_nocontext
174 Perl_sv_setpvf_nocontext
175 Perl_sv_catpvf_mg_nocontext
176 Perl_sv_setpvf_mg_nocontext
177 )];
178 }
d4cce5f1 179
910dfcc8 180unless ($define{'FAKE_THREADS'})
181 {
db15561c 182 skip_symbols [qw(PL_curthr)];
d55594ae 183 }
184
22239a37 185sub readvar
186{
187 my $file = shift;
188 open(VARS,$file) || die "Cannot open $file:$!";
189 my @syms;
190 while (<VARS>)
191 {
192 # All symbols have a Perl_ prefix because that's what embed.h
193 # sticks in front of them.
db15561c 194 push(@syms,"PL_".$1) if (/\bPERLVARI?C?\([IGT](\w+)/);
22239a37 195 }
196 close(VARS);
197 return \@syms;
198}
199
d4cce5f1 200if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 201 {
22239a37 202 my $thrd = readvar("../thrdvar.h");
203 skip_symbols $thrd;
d55594ae 204 }
205
d4cce5f1 206if ($define{'MULTIPLICITY'})
d55594ae 207 {
22239a37 208 my $interp = readvar("../intrpvar.h");
209 skip_symbols $interp;
210 }
211
212if ($define{'PERL_GLOBAL_STRUCT'})
213 {
214 my $global = readvar("../perlvars.h");
215 skip_symbols $global;
852c2e52 216 emit_symbols [qw(Perl_GetVars)];
db15561c 217 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
d4cce5f1 218 }
d55594ae 219
36c15d3f 220unless ($define{'DEBUGGING'})
221 {
22239a37 222 skip_symbols [qw(
fea7140c 223 Perl_deb
224 Perl_deb_growlevel
225 Perl_debop
226 Perl_debprofdump
227 Perl_debstack
228 Perl_debstackptrs
22239a37 229 Perl_runops_debug
230 Perl_sv_peek
3836fe67 231 PL_block_type
22c35a8c 232 PL_watchaddr
233 PL_watchok)];
36c15d3f 234 }
235
26618a56 236if ($define{'HAVE_DES_FCRYPT'})
237 {
238 emit_symbols [qw(win32_crypt)];
239 }
240
22c35a8c 241# functions from *.sym files
242
243for my $syms ('../global.sym','../pp.sym', '../globvar.sym')
22239a37 244 {
22c35a8c 245 open (GLOBAL, "<$syms") || die "failed to open $syms" . $!;
246 while (<GLOBAL>)
247 {
248 next if (!/^[A-Za-z]/);
249 # Functions have a Perl_ prefix
250 # Variables have a PL_ prefix
251 chomp($_);
4f63d024 252 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
22c35a8c 253 $symbol .= $_;
254 emit_symbol($symbol) unless exists $skip{$symbol};
255 }
256 close(GLOBAL);
22239a37 257 }
0a753a76 258
22c35a8c 259# variables
0a753a76 260
852c2e52 261unless ($define{'PERL_GLOBAL_STRUCT'})
22239a37 262 {
263 my $glob = readvar("../perlvars.h");
264 emit_symbols $glob;
265 }
266
267unless ($define{'MULTIPLICITY'})
268 {
269 my $glob = readvar("../intrpvar.h");
270 emit_symbols $glob;
271 }
0a753a76 272
22239a37 273unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'})
274 {
275 my $glob = readvar("../thrdvar.h");
276 emit_symbols $glob;
277 }
0a753a76 278
279while (<DATA>) {
280 my $symbol;
281 next if (!/^[A-Za-z]/);
282 next if (/^#/);
a868473f 283 s/\r//g;
22239a37 284 chomp($_);
0a753a76 285 $symbol = $_;
22239a37 286 next if exists $skip{$symbol};
3e3baf6d 287 emit_symbol($symbol);
288}
289
22239a37 290foreach my $symbol (sort keys %export)
291 {
ac4c12e7 292 output_symbol($symbol);
22239a37 293 }
294
295sub emit_symbol {
296 my $symbol = shift;
297 chomp($symbol);
298 $export{$symbol} = 1;
3e3baf6d 299}
0a753a76 300
ac4c12e7 301sub output_symbol {
302 my $symbol = shift;
303 if ($CCTYPE eq "BORLAND") {
304 # workaround Borland quirk by exporting both the straight
305 # name and a name with leading underscore. Note the
306 # alias *must* come after the symbol itself, if both
307 # are to be exported. (Linker bug?)
308 print "\t_$symbol\n";
309 print "\t$symbol = _$symbol\n";
310 }
311 elsif ($CCTYPE eq 'GCC') {
312 # Symbols have leading _ whole process is $%£"% slow
313 # so skip aliases for now
314 print "\t$symbol\n";
315 }
316 else {
317 # for binary coexistence, export both the symbol and
318 # alias with leading underscore
319 print "\t$symbol\n";
320 print "\t_$symbol = $symbol\n";
321 }
322}
323
0a753a76 3241;
325__DATA__
326# extra globals not included above.
0a753a76 327perl_alloc
328perl_construct
329perl_destruct
330perl_free
331perl_parse
332perl_run
d28b3ca3 333boot_DynaLoader
d55594ae 334Perl_thread_create
68dc0745 335win32_errno
96e4d5b1 336win32_environ
68dc0745 337win32_stdin
338win32_stdout
96e4d5b1 339win32_stderr
68dc0745 340win32_ferror
341win32_feof
342win32_strerror
343win32_fprintf
344win32_printf
345win32_vfprintf
96e4d5b1 346win32_vprintf
68dc0745 347win32_fread
348win32_fwrite
349win32_fopen
350win32_fdopen
351win32_freopen
352win32_fclose
353win32_fputs
354win32_fputc
355win32_ungetc
356win32_getc
357win32_fileno
358win32_clearerr
359win32_fflush
360win32_ftell
361win32_fseek
362win32_fgetpos
363win32_fsetpos
364win32_rewind
365win32_tmpfile
366win32_abort
367win32_fstat
96e4d5b1 368win32_stat
68dc0745 369win32_pipe
370win32_popen
371win32_pclose
e24c7c18 372win32_rename
68dc0745 373win32_setmode
96e4d5b1 374win32_lseek
375win32_tell
68dc0745 376win32_dup
377win32_dup2
96e4d5b1 378win32_open
379win32_close
380win32_eof
68dc0745 381win32_read
382win32_write
3e3baf6d 383win32_spawnvp
5aabfad6 384win32_mkdir
385win32_rmdir
386win32_chdir
c90c0ff4 387win32_flock
eb62e965 388win32_execv
6890e559 389win32_execvp
54310121 390win32_htons
391win32_ntohs
392win32_htonl
393win32_ntohl
394win32_inet_addr
395win32_inet_ntoa
396win32_socket
397win32_bind
398win32_listen
399win32_accept
400win32_connect
401win32_send
402win32_sendto
403win32_recv
404win32_recvfrom
405win32_shutdown
3a25acb4 406win32_closesocket
54310121 407win32_ioctlsocket
408win32_setsockopt
409win32_getsockopt
410win32_getpeername
411win32_getsockname
412win32_gethostname
413win32_gethostbyname
414win32_gethostbyaddr
415win32_getprotobyname
416win32_getprotobynumber
417win32_getservbyname
418win32_getservbyport
419win32_select
420win32_endhostent
421win32_endnetent
422win32_endprotoent
423win32_endservent
424win32_getnetent
425win32_getnetbyname
426win32_getnetbyaddr
427win32_getprotoent
428win32_getservent
429win32_sethostent
430win32_setnetent
431win32_setprotoent
432win32_setservent
ad2e33dc 433win32_getenv
ac5c734f 434win32_putenv
84902520 435win32_perror
436win32_setbuf
437win32_setvbuf
438win32_flushall
439win32_fcloseall
440win32_fgets
441win32_gets
442win32_fgetc
443win32_putc
444win32_puts
445win32_getchar
446win32_putchar
447win32_malloc
448win32_calloc
449win32_realloc
450win32_free
f3986ebb 451win32_sleep
452win32_times
453win32_alarm
65e48ea9 454win32_open_osfhandle
455win32_get_osfhandle
f998180f 456win32_ioctl
ad0751ec 457win32_utime
b2af26b1 458win32_uname
22fae026 459win32_wait
f55ee38a 460win32_waitpid
461win32_kill
22fae026 462win32_str_os_error
ce2e26e5 463win32_opendir
464win32_readdir
465win32_telldir
466win32_seekdir
467win32_rewinddir
468win32_closedir
8ac9c18d 469win32_longpath
ad2e33dc 470Perl_win32_init
f3986ebb 471Perl_init_os_extras
9811a7d7 472Perl_getTHR
0fefa03b 473Perl_setTHR
84902520 474RunPerl
22239a37 475