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