Commit | Line | Data |
a0d0e21e |
1 | #!./miniperl |
2 | # |
3 | # Create perlmain.c from miniperlmain.c, adding code to boot the |
748a9306 |
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 | # |
bd3fa61c |
8 | # Last modified 29-Nov-1994 by Charles Bailey bailey@newman.upenn.edu |
a0d0e21e |
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>) { |
a0d0e21e |
21 | print OUT; |
22 | last if /Do not delete this line--writemain depends on it/; |
23 | } |
24 | $ok = !eof(IN); |
25 | close IN; |
26 | |
27 | if (!$ok) { |
28 | close OUT; |
29 | unlink "${dir}perlmain.c"; |
30 | die "$0: Can't find marker line in ${dir}miniperlmain.c - aborting\n"; |
31 | } |
32 | |
33 | |
e518068a |
34 | print OUT <<'EOH'; |
35 | |
36 | static void |
5c84aa53 |
37 | xs_init(pTHX) |
e518068a |
38 | { |
39 | EOH |
40 | |
748a9306 |
41 | if (@ARGV) { |
07f049cb |
42 | $names = join(' ',@ARGV); |
43 | $names =~ tr/"//d; # Plan9 doesn't remove "" on command line |
748a9306 |
44 | # Allow for multiple names in one quoted group |
07f049cb |
45 | @exts = split(/\s+/,$names); |
a0d0e21e |
46 | } |
47 | |
748a9306 |
48 | if (@exts) { |
49 | print OUT " char *file = __FILE__;\n"; |
50 | foreach $ext (@exts) { |
51 | my($subname) = $ext; |
52 | $subname =~ s/::/__/g; |
5c84aa53 |
53 | print OUT "extern void boot_${subname} (pTHX_ CV* cv);\n" |
a0d0e21e |
54 | } |
96e4d5b1 |
55 | # May not actually be a declaration, so put after other declarations |
56 | print OUT " dXSUB_SYS;\n"; |
748a9306 |
57 | foreach $ext (@exts) { |
58 | my($subname) = $ext; |
59 | $subname =~ s/::/__/g; |
60 | print "Adding $ext . . .\n"; |
61 | if ($ext eq 'DynaLoader') { |
62 | # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'! |
63 | # boot_DynaLoader is called directly in DynaLoader.pm |
64 | print OUT " newXS(\"${ext}::boot_${ext}\", boot_${subname}, file);\n" |
65 | } |
66 | else { |
67 | print OUT " newXS(\"${ext}::bootstrap\", boot_${subname}, file);\n" |
68 | } |
a0d0e21e |
69 | } |
70 | } |
71 | |
72 | print OUT "}\n"; |
73 | close OUT; |