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