Perl 5.001
[p5sagit/p5-mst-13.2.git] / vms / writemain.pl
1 #!./miniperl
2 #
3 # Create perlmain.c from miniperlmain.c, adding code to boot the
4 # extensions listed on the command line.  In addition, create a
5 # linker options file which causes the bootstrap routines for
6 # these extension to be universal symbols in PerlShr.Exe.
7 #
8 # Last modified 29-Nov-1994 by Charles Bailey  bailey@genetics.upenn.edu
9 #
10
11 if (-f 'miniperlmain.c') { $dir = ''; }
12 elsif (-f '../miniperlmain.c') { $dir = '../'; }
13 else { die "$0: Can't find miniperlmain.c\n"; }
14
15 open (IN,"${dir}miniperlmain.c")
16   || die "$0: Can't open ${dir}miniperlmain.c: $!\n";
17 open (OUT,">${dir}perlmain.c")
18   || die "$0: Can't open ${dir}perlmain.c: $!\n";
19
20 while (<IN>) {
21   s/INTERN\.h/EXTERN\.h/;
22   print OUT;
23   last if /Do not delete this line--writemain depends on it/;
24 }
25 $ok = !eof(IN);
26 close IN;
27
28 if (!$ok) {
29   close OUT;
30   unlink "${dir}perlmain.c";
31   die "$0: Can't find marker line in ${dir}miniperlmain.c - aborting\n";
32 }
33
34
35 if (@ARGV) {
36   # Allow for multiple names in one quoted group
37   @exts = split(/\s+/, join(' ',@ARGV));
38 }
39
40 if (@exts) {
41   print OUT "    char *file = __FILE__;\n";
42   foreach $ext (@exts) {
43     my($subname) = $ext;
44     $subname =~ s/::/__/g;
45     print OUT "extern void      boot_${subname} _((CV* cv));\n"
46   }
47   foreach $ext (@exts) {
48     my($subname) = $ext;
49     $subname =~ s/::/__/g;
50     print "Adding $ext . . .\n";
51     if ($ext eq 'DynaLoader') {
52       # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
53       # boot_DynaLoader is called directly in DynaLoader.pm
54       print OUT "    newXS(\"${ext}::boot_${ext}\", boot_${subname}, file);\n"
55     }
56     else {
57       print OUT "    newXS(\"${ext}::bootstrap\", boot_${subname}, file);\n"
58     }
59   }
60 }
61
62 print OUT "}\n";
63 close OUT;