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