Sarathy's patch
[p5sagit/p5-mst-13.2.git] / win32 / makedef.pl
CommitLineData
0a753a76 1#!../miniperl
2
3# Written: 10 April 1996 Gary Ng (71564.1743@compuserve.com)
4
5# Create the export list for perl.
6# Needed by WIN32 for creating perl.dll
7# based on perl_exp.SH in the main perl distribution directory
8
9# This simple program relys on 'global.sym' being up to date
10# with all of the global symbols that a dynamicly link library
11# might want to access.
12
13# There is some symbol defined in global.sym and interp.sym
14# that does not present in the WIN32 port but there is no easy
84902520 15# way to find them so I just put a exception list here
0a753a76 16
d55594ae 17while (@ARGV && $ARGV[0] =~ /^-/)
18 {
19 my $flag = shift;
20 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
21 }
22
bbc8f9de 23open(CFG,'config.h') || die "Cannot open config.h:$!";
24while (<CFG>)
25 {
26 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
27 }
28close(CFG);
29
d55594ae 30warn join(' ',keys %define)."\n";
31
3e3baf6d 32my $CCTYPE = shift || "MSVC";
33
04dc04aa 34if ($CCTYPE ne 'GCC')
35 {
36 print "LIBRARY Perl\n";
37 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
38 print "CODE LOADONCALL\n";
39 print "DATA LOADONCALL NONSHARED MULTIPLE\n";
40 }
22239a37 41else
42 {
43 $define{'PERL_GLOBAL_STRUCT'} = 1;
44 $define{'MULTIPLICITY'} = 1;
45 }
46
bbc8f9de 47print "EXPORTS\n";
48
22239a37 49my %skip;
50my %export;
51
52sub skip_symbols
53{
54 my $list = shift;
55 foreach my $symbol (@$list)
56 {
57 $skip{$symbol} = 1;
58 }
59}
60
61sub emit_symbols
62{
63 my $list = shift;
64 foreach my $symbol (@$list)
65 {
66 emit_symbol($symbol) unless exists $skip{$symbol};
67 }
68}
69
70skip_symbols [qw(
71Perl_statusvalue_vms
0a753a76 72Perl_block_type
0a753a76 73Perl_additem
74Perl_cast_ulong
75Perl_check_uni
76Perl_checkcomma
77Perl_chsize
78Perl_ck_aelem
79Perl_cryptseen
80Perl_cx_dump
81Perl_deb
82Perl_deb_growlevel
83Perl_debop
84Perl_debprofdump
85Perl_debstack
86Perl_debstackptrs
87Perl_do_ipcctl
88Perl_do_ipcget
89Perl_do_msgrcv
90Perl_do_msgsnd
91Perl_do_semop
92Perl_do_shmio
93Perl_doeval
94Perl_dofindlabel
95Perl_dopoptoeval
96Perl_dump_eval
97Perl_dump_fds
98Perl_dump_form
99Perl_dump_gv
100Perl_dump_mstats
101Perl_dump_op
102Perl_dump_packsubs
103Perl_dump_pm
104Perl_dump_sub
105Perl_expectterm
106Perl_fetch_gv
107Perl_fetch_io
108Perl_force_ident
109Perl_force_next
110Perl_force_word
111Perl_hv_stashpv
112Perl_intuit_more
d55594ae 113Perl_init_thread_intern
0a753a76 114Perl_know_next
115Perl_modkids
116Perl_mstats
117Perl_my_bzero
118Perl_my_htonl
119Perl_my_ntohl
120Perl_my_swap
121Perl_my_chsize
122Perl_newXSUB
123Perl_no_fh_allowed
124Perl_no_op
125Perl_nointrp
126Perl_nomem
127Perl_pp_cswitch
128Perl_pp_entersubr
129Perl_pp_evalonce
130Perl_pp_interp
131Perl_pp_map
132Perl_pp_nswitch
133Perl_q
d55594ae 134Perl_rcsid
0a753a76 135Perl_reall_srchlen
136Perl_regdump
137Perl_regfold
138Perl_regmyendp
139Perl_regmyp_size
140Perl_regmystartp
141Perl_regnarrate
142Perl_regprop
143Perl_same_dirent
144Perl_saw_return
145Perl_scan_const
146Perl_scan_formline
147Perl_scan_heredoc
148Perl_scan_ident
149Perl_scan_inputsymbol
150Perl_scan_pat
151Perl_scan_prefix
152Perl_scan_str
153Perl_scan_subst
154Perl_scan_trans
155Perl_scan_word
68dc0745 156Perl_setenv_getix
0a753a76 157Perl_skipspace
158Perl_sublex_done
159Perl_sublex_start
0a753a76 160Perl_sv_ref
161Perl_sv_setptrobj
162Perl_timesbuf
163Perl_too_few_arguments
164Perl_too_many_arguments
165Perl_unlnk
166Perl_wait4pid
167Perl_watch
168Perl_yyname
169Perl_yyrule
31fb1209 170Perl_Yes
171Perl_No
172Perl_hexdigit
173Perl_patleave
174Perl_vert
0a753a76 175allgvs
176curblock
0a753a76 177curcsv
0a753a76 178lastretstr
179mystack_mark
180perl_init_ext
181perl_requirepv
0a753a76 182stack
ff0cee69 183statusvalue_vms
0a753a76 184Perl_safexcalloc
185Perl_safexmalloc
186Perl_safexfree
187Perl_safexrealloc
68dc0745 188Perl_my_memcmp
8b10511d 189Perl_my_memset
68dc0745 190Perl_cshlen
191Perl_cshname
0da3735a 192Perl_opsave
22239a37 193)];
0a753a76 194
c69f112c 195
bbc8f9de 196if ($define{'MYMALLOC'})
197 {
22239a37 198 skip_symbols [qw(
199 Perl_safefree
200 Perl_safemalloc
201 Perl_saferealloc
202 Perl_safecalloc)];
203 emit_symbols [qw(
204 Perl_malloc
205 Perl_free
206 Perl_realloc
207 Perl_calloc)];
bbc8f9de 208 }
209
d55594ae 210unless ($define{'USE_THREADS'})
211 {
22239a37 212 skip_symbols [qw(
d55594ae 213Perl_condpair_magic
214Perl_thr_key
215Perl_sv_mutex
216Perl_malloc_mutex
217Perl_eval_mutex
218Perl_eval_cond
219Perl_eval_owner
220Perl_threads_mutex
32f822de 221Perl_new_struct_thread
222Perl_nthreads
d55594ae 223Perl_nthreads_cond
32f822de 224Perl_per_thread_magicals
d4cce5f1 225Perl_thread_create
226Perl_find_threadsv
227Perl_threadsv_names
32f822de 228Perl_thrsv
d55594ae 229Perl_unlock_condpair
230Perl_vtbl_mutex
231Perl_magic_mutexfree
232Perl_sv_iv
233Perl_sv_nv
234Perl_sv_true
235Perl_sv_uv
236Perl_sv_pvn
22239a37 237Perl_newRV_noinc)];
d4cce5f1 238
d55594ae 239 }
240
22239a37 241sub readvar
242{
243 my $file = shift;
244 open(VARS,$file) || die "Cannot open $file:$!";
245 my @syms;
246 while (<VARS>)
247 {
248 # All symbols have a Perl_ prefix because that's what embed.h
249 # sticks in front of them.
250 push(@syms,"Perl_".$1) if (/\bPERLVARI?\([IGT](\w+)/);
251 }
252 close(VARS);
253 return \@syms;
254}
255
d4cce5f1 256if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 257 {
22239a37 258 my $thrd = readvar("../thrdvar.h");
259 skip_symbols $thrd;
d55594ae 260 }
261
d4cce5f1 262if ($define{'MULTIPLICITY'})
d55594ae 263 {
22239a37 264 my $interp = readvar("../intrpvar.h");
265 skip_symbols $interp;
266 }
267
268if ($define{'PERL_GLOBAL_STRUCT'})
269 {
270 my $global = readvar("../perlvars.h");
271 skip_symbols $global;
d4cce5f1 272 }
d55594ae 273
36c15d3f 274unless ($define{'DEBUGGING'})
275 {
22239a37 276 skip_symbols [qw(
277 Perl_runops_debug
278 Perl_sv_peek
279 Perl_watchaddr
280 Perl_watchok)];
36c15d3f 281 }
282
0a753a76 283open (GLOBAL, "<../global.sym") || die "failed to open global.sym" . $!;
22239a37 284while (<GLOBAL>)
285 {
286 next if (!/^[A-Za-z]/);
287 next if (/_amg[ \t]*$/);
288 # All symbols have a Perl_ prefix because that's what embed.h
289 # sticks in front of them.
290 chomp($_);
291 my $symbol = "Perl_$_";
292 emit_symbol($symbol) unless exists $skip{$symbol};
293 }
0a753a76 294close(GLOBAL);
295
296# also add symbols from interp.sym
297# They are only needed if -DMULTIPLICITY is not set but it
298# doesn't hurt to include them anyway.
299# these don't have Perl prefix
300
22239a37 301if ($define{'PERL_GLOBAL_STRUCT'})
302 {
303 emit_symbol( ($CCTYPE eq 'GCC') ? 'Perl_GetVars' : 'Perl_VarsPtr')
304 }
305else
306 {
307 my $glob = readvar("../perlvars.h");
308 emit_symbols $glob;
309 }
310
311unless ($define{'MULTIPLICITY'})
312 {
313 my $glob = readvar("../intrpvar.h");
314 emit_symbols $glob;
315 }
0a753a76 316
22239a37 317unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'})
318 {
319 my $glob = readvar("../thrdvar.h");
320 emit_symbols $glob;
321 }
0a753a76 322
323while (<DATA>) {
324 my $symbol;
325 next if (!/^[A-Za-z]/);
326 next if (/^#/);
a868473f 327 s/\r//g;
22239a37 328 chomp($_);
0a753a76 329 $symbol = $_;
22239a37 330 next if exists $skip{$symbol};
3e3baf6d 331 emit_symbol($symbol);
332}
333
22239a37 334foreach my $symbol (sort keys %export)
335 {
3e3baf6d 336 if ($CCTYPE eq "BORLAND") {
337 # workaround Borland quirk by exporting both the straight
84902520 338 # name and a name with leading underscore. Note the
339 # alias *must* come after the symbol itself, if both
340 # are to be exported. (Linker bug?)
3e3baf6d 341 print "\t_$symbol\n";
84902520 342 print "\t$symbol = _$symbol\n";
3e3baf6d 343 }
22239a37 344 elsif ($CCTYPE eq 'GCC') {
345 # Symbols have leading _ whole process is $%£"% slow
346 # so skip aliases for now
347 print "\t$symbol\n";
348 }
3e3baf6d 349 else {
84902520 350 # for binary coexistence, export both the symbol and
351 # alias with leading underscore
3e3baf6d 352 print "\t$symbol\n";
84902520 353 print "\t_$symbol = $symbol\n";
3e3baf6d 354 }
22239a37 355 }
356
357sub emit_symbol {
358 my $symbol = shift;
359 chomp($symbol);
360 $export{$symbol} = 1;
3e3baf6d 361}
0a753a76 362
3631;
364__DATA__
365# extra globals not included above.
366perl_init_i18nl10n
367perl_init_ext
368perl_alloc
369perl_construct
370perl_destruct
371perl_free
372perl_parse
373perl_run
374perl_get_sv
375perl_get_av
376perl_get_hv
377perl_get_cv
378perl_call_argv
379perl_call_pv
380perl_call_method
381perl_call_sv
10dd38fc 382perl_require_pv
383perl_eval_pv
384perl_eval_sv
d28b3ca3 385boot_DynaLoader
d55594ae 386Perl_thread_create
68dc0745 387win32_errno
96e4d5b1 388win32_environ
68dc0745 389win32_stdin
390win32_stdout
96e4d5b1 391win32_stderr
68dc0745 392win32_ferror
393win32_feof
394win32_strerror
395win32_fprintf
396win32_printf
397win32_vfprintf
96e4d5b1 398win32_vprintf
68dc0745 399win32_fread
400win32_fwrite
401win32_fopen
402win32_fdopen
403win32_freopen
404win32_fclose
405win32_fputs
406win32_fputc
407win32_ungetc
408win32_getc
409win32_fileno
410win32_clearerr
411win32_fflush
412win32_ftell
413win32_fseek
414win32_fgetpos
415win32_fsetpos
416win32_rewind
417win32_tmpfile
418win32_abort
419win32_fstat
96e4d5b1 420win32_stat
68dc0745 421win32_pipe
422win32_popen
423win32_pclose
424win32_setmode
96e4d5b1 425win32_lseek
426win32_tell
68dc0745 427win32_dup
428win32_dup2
96e4d5b1 429win32_open
430win32_close
431win32_eof
68dc0745 432win32_read
433win32_write
3e3baf6d 434win32_spawnvp
5aabfad6 435win32_mkdir
436win32_rmdir
437win32_chdir
c90c0ff4 438win32_flock
6890e559 439win32_execvp
54310121 440win32_htons
441win32_ntohs
442win32_htonl
443win32_ntohl
444win32_inet_addr
445win32_inet_ntoa
446win32_socket
447win32_bind
448win32_listen
449win32_accept
450win32_connect
451win32_send
452win32_sendto
453win32_recv
454win32_recvfrom
455win32_shutdown
3a25acb4 456win32_closesocket
54310121 457win32_ioctlsocket
458win32_setsockopt
459win32_getsockopt
460win32_getpeername
461win32_getsockname
462win32_gethostname
463win32_gethostbyname
464win32_gethostbyaddr
465win32_getprotobyname
466win32_getprotobynumber
467win32_getservbyname
468win32_getservbyport
469win32_select
470win32_endhostent
471win32_endnetent
472win32_endprotoent
473win32_endservent
474win32_getnetent
475win32_getnetbyname
476win32_getnetbyaddr
477win32_getprotoent
478win32_getservent
479win32_sethostent
480win32_setnetent
481win32_setprotoent
482win32_setservent
ad2e33dc 483win32_getenv
84902520 484win32_perror
485win32_setbuf
486win32_setvbuf
487win32_flushall
488win32_fcloseall
489win32_fgets
490win32_gets
491win32_fgetc
492win32_putc
493win32_puts
494win32_getchar
495win32_putchar
496win32_malloc
497win32_calloc
498win32_realloc
499win32_free
f3986ebb 500win32_sleep
501win32_times
502win32_alarm
65e48ea9 503win32_open_osfhandle
504win32_get_osfhandle
ad2e33dc 505Perl_win32_init
f3986ebb 506Perl_init_os_extras
9811a7d7 507Perl_getTHR
0fefa03b 508Perl_setTHR
84902520 509RunPerl
22239a37 510