This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix a few places that said 'int', but meant 'STRLEN'
[perl5.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
GS
7my $CCTYPE = "MSVC"; # default
8
9while (@ARGV)
d55594ae
GS
10 {
11 my $flag = shift;
12 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
910dfcc8 13 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
d55594ae
GS
14 }
15
bbc8f9de
NIS
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
NIS
22 }
23close(CFG);
24
d55594ae
GS
25warn join(' ',keys %define)."\n";
26
ac4c12e7
GS
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
NIS
35if ($CCTYPE ne 'GCC')
36 {
37 print "LIBRARY Perl\n";
38 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
04dc04aa 39 }
22239a37
NIS
40else
41 {
42 $define{'PERL_GLOBAL_STRUCT'} = 1;
43 $define{'MULTIPLICITY'} = 1;
44 }
45
bbc8f9de
NIS
46print "EXPORTS\n";
47
22239a37
NIS
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
GS
70PL_statusvalue_vms
71PL_archpat_auto
72PL_cryptseen
73PL_DBcv
74PL_generation
db15561c
GS
75PL_lastgotoprobe
76PL_linestart
77PL_modcount
78PL_pending_ident
79PL_sortcxix
80PL_sublex_info
81PL_timesbuf
0a753a76 82Perl_do_ipcctl
83Perl_do_ipcget
84Perl_do_msgrcv
85Perl_do_msgsnd
86Perl_do_semop
87Perl_do_shmio
0a753a76 88Perl_dump_fds
0a753a76 89Perl_dump_mstats
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
GS
106PL_cshlen
107PL_cshname
108PL_opsave
22239a37 109)];
0a753a76 110
c69f112c 111
bbc8f9de
NIS
112if ($define{'MYMALLOC'})
113 {
22239a37
NIS
114 emit_symbols [qw(
115 Perl_malloc
f2517201 116 Perl_mfree
22239a37
NIS
117 Perl_realloc
118 Perl_calloc)];
bbc8f9de 119 }
32fcaa0b
GS
120else
121 {
122 skip_symbols [qw(
123 Perl_malloced_size)];
124 }
bbc8f9de 125
d55594ae
GS
126unless ($define{'USE_THREADS'})
127 {
22239a37 128 skip_symbols [qw(
db15561c
GS
129PL_thr_key
130PL_sv_mutex
46124e9e 131PL_strtab_mutex
db15561c
GS
132PL_svref_mutex
133PL_malloc_mutex
5ff3f7a4 134PL_cred_mutex
db15561c
GS
135PL_eval_mutex
136PL_eval_cond
137PL_eval_owner
138PL_threads_mutex
139PL_nthreads
140PL_nthreads_cond
141PL_threadnum
142PL_threadsv_names
143PL_thrsv
22c35a8c 144PL_vtbl_mutex
eb480a0b
GS
145Perl_getTHR
146Perl_setTHR
d55594ae 147Perl_condpair_magic
32f822de 148Perl_new_struct_thread
32f822de 149Perl_per_thread_magicals
d4cce5f1
NIS
150Perl_thread_create
151Perl_find_threadsv
d55594ae 152Perl_unlock_condpair
d55594ae 153Perl_magic_mutexfree
95906810 154)];
910dfcc8 155 }
d4cce5f1 156
910dfcc8
GS
157unless ($define{'FAKE_THREADS'})
158 {
db15561c 159 skip_symbols [qw(PL_curthr)];
d55594ae
GS
160 }
161
22239a37
NIS
162sub readvar
163{
164 my $file = shift;
165 open(VARS,$file) || die "Cannot open $file:$!";
166 my @syms;
167 while (<VARS>)
168 {
169 # All symbols have a Perl_ prefix because that's what embed.h
170 # sticks in front of them.
db15561c 171 push(@syms,"PL_".$1) if (/\bPERLVARI?C?\([IGT](\w+)/);
22239a37
NIS
172 }
173 close(VARS);
174 return \@syms;
175}
176
d4cce5f1 177if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 178 {
22239a37
NIS
179 my $thrd = readvar("../thrdvar.h");
180 skip_symbols $thrd;
d55594ae
GS
181 }
182
d4cce5f1 183if ($define{'MULTIPLICITY'})
d55594ae 184 {
22239a37
NIS
185 my $interp = readvar("../intrpvar.h");
186 skip_symbols $interp;
187 }
188
189if ($define{'PERL_GLOBAL_STRUCT'})
190 {
191 my $global = readvar("../perlvars.h");
192 skip_symbols $global;
852c2e52 193 emit_symbols [qw(Perl_GetVars)];
db15561c 194 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
d4cce5f1 195 }
d55594ae 196
36c15d3f
NIS
197unless ($define{'DEBUGGING'})
198 {
22239a37 199 skip_symbols [qw(
fea7140c
GS
200 Perl_deb
201 Perl_deb_growlevel
202 Perl_debop
203 Perl_debprofdump
204 Perl_debstack
205 Perl_debstackptrs
22239a37
NIS
206 Perl_runops_debug
207 Perl_sv_peek
3836fe67 208 PL_block_type
22c35a8c
GS
209 PL_watchaddr
210 PL_watchok)];
36c15d3f
NIS
211 }
212
26618a56
GS
213if ($define{'HAVE_DES_FCRYPT'})
214 {
215 emit_symbols [qw(win32_crypt)];
216 }
217
22c35a8c
GS
218# functions from *.sym files
219
220for my $syms ('../global.sym','../pp.sym', '../globvar.sym')
22239a37 221 {
22c35a8c
GS
222 open (GLOBAL, "<$syms") || die "failed to open $syms" . $!;
223 while (<GLOBAL>)
224 {
225 next if (!/^[A-Za-z]/);
226 # Functions have a Perl_ prefix
227 # Variables have a PL_ prefix
228 chomp($_);
229 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "Perl_");
230 $symbol .= $_;
231 emit_symbol($symbol) unless exists $skip{$symbol};
232 }
233 close(GLOBAL);
22239a37 234 }
0a753a76 235
22c35a8c 236# variables
0a753a76 237
852c2e52 238unless ($define{'PERL_GLOBAL_STRUCT'})
22239a37
NIS
239 {
240 my $glob = readvar("../perlvars.h");
241 emit_symbols $glob;
242 }
243
244unless ($define{'MULTIPLICITY'})
245 {
246 my $glob = readvar("../intrpvar.h");
247 emit_symbols $glob;
248 }
0a753a76 249
22239a37
NIS
250unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'})
251 {
252 my $glob = readvar("../thrdvar.h");
253 emit_symbols $glob;
254 }
0a753a76 255
256while (<DATA>) {
257 my $symbol;
258 next if (!/^[A-Za-z]/);
259 next if (/^#/);
a868473f 260 s/\r//g;
22239a37 261 chomp($_);
0a753a76 262 $symbol = $_;
22239a37 263 next if exists $skip{$symbol};
3e3baf6d
TB
264 emit_symbol($symbol);
265}
266
22239a37
NIS
267foreach my $symbol (sort keys %export)
268 {
ac4c12e7 269 output_symbol($symbol);
22239a37
NIS
270 }
271
272sub emit_symbol {
273 my $symbol = shift;
274 chomp($symbol);
275 $export{$symbol} = 1;
3e3baf6d 276}
0a753a76 277
ac4c12e7
GS
278sub output_symbol {
279 my $symbol = shift;
280 if ($CCTYPE eq "BORLAND") {
281 # workaround Borland quirk by exporting both the straight
282 # name and a name with leading underscore. Note the
283 # alias *must* come after the symbol itself, if both
284 # are to be exported. (Linker bug?)
285 print "\t_$symbol\n";
286 print "\t$symbol = _$symbol\n";
287 }
288 elsif ($CCTYPE eq 'GCC') {
289 # Symbols have leading _ whole process is $%£"% slow
290 # so skip aliases for now
291 print "\t$symbol\n";
292 }
293 else {
294 # for binary coexistence, export both the symbol and
295 # alias with leading underscore
296 print "\t$symbol\n";
297 print "\t_$symbol = $symbol\n";
298 }
299}
300
0a753a76 3011;
302__DATA__
303# extra globals not included above.
304perl_init_i18nl10n
305perl_init_ext
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
GS
321perl_require_pv
322perl_eval_pv
323perl_eval_sv
6dead956
GS
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
TB
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
GS
447win32_sleep
448win32_times
449win32_alarm
65e48ea9
GS
450win32_open_osfhandle
451win32_get_osfhandle
f998180f 452win32_ioctl
ad0751ec 453win32_utime
b2af26b1 454win32_uname
22fae026 455win32_wait
f55ee38a
GS
456win32_waitpid
457win32_kill
22fae026 458win32_str_os_error
ce2e26e5
GS
459win32_opendir
460win32_readdir
461win32_telldir
462win32_seekdir
463win32_rewinddir
464win32_closedir
ad2e33dc 465Perl_win32_init
f3986ebb 466Perl_init_os_extras
9811a7d7 467Perl_getTHR
0fefa03b 468Perl_setTHR
84902520 469RunPerl
22239a37 470