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