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