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