1 | # minimod.PL writes the contents of miniperlmain.c into the module
|
---|
2 | # ExtUtils::Miniperl for later perusal (when the perl source is
|
---|
3 | # deleted)
|
---|
4 | #
|
---|
5 | # It also writes the subroutine writemain(), which takes as its
|
---|
6 | # arguments module names that shall be statically linked into perl.
|
---|
7 | #
|
---|
8 | # Authors: Andreas Koenig <k@franz.ww.TU-Berlin.DE>, Tim Bunce
|
---|
9 | # <Tim.Bunce@ig.co.uk>
|
---|
10 | #
|
---|
11 | # Version 1.0, Feb 2nd 1995 by Andreas Koenig
|
---|
12 |
|
---|
13 | print <<'END';
|
---|
14 | # This File keeps the contents of miniperlmain.c.
|
---|
15 | #
|
---|
16 | # It was generated automatically by minimod.PL from the contents
|
---|
17 | # of miniperlmain.c. Don't edit this file!
|
---|
18 | #
|
---|
19 | # ANY CHANGES MADE HERE WILL BE LOST!
|
---|
20 | #
|
---|
21 |
|
---|
22 |
|
---|
23 | package ExtUtils::Miniperl;
|
---|
24 | require Exporter;
|
---|
25 | @ISA = qw(Exporter);
|
---|
26 | @EXPORT = qw(&writemain);
|
---|
27 |
|
---|
28 | $head= <<'EOF!HEAD';
|
---|
29 | END
|
---|
30 |
|
---|
31 | open MINI, "miniperlmain.c";
|
---|
32 | while (<MINI>) {
|
---|
33 | last if /Do not delete this line--writemain depends on it/;
|
---|
34 | print;
|
---|
35 | }
|
---|
36 |
|
---|
37 | print <<'END';
|
---|
38 | EOF!HEAD
|
---|
39 | $tail=<<'EOF!TAIL';
|
---|
40 | END
|
---|
41 |
|
---|
42 | while (<MINI>) {
|
---|
43 | print unless /dXSUB_SYS/;
|
---|
44 | }
|
---|
45 | close MINI;
|
---|
46 |
|
---|
47 | print <<'END';
|
---|
48 | EOF!TAIL
|
---|
49 |
|
---|
50 | sub writemain{
|
---|
51 | my(@exts) = @_;
|
---|
52 |
|
---|
53 | my($pname);
|
---|
54 | my($dl) = canon('/','DynaLoader');
|
---|
55 | print $head;
|
---|
56 |
|
---|
57 | foreach $_ (@exts){
|
---|
58 | my($pname) = canon('/', $_);
|
---|
59 | my($mname, $cname);
|
---|
60 | ($mname = $pname) =~ s!/!::!g;
|
---|
61 | ($cname = $pname) =~ s!/!__!g;
|
---|
62 | print "EXTERN_C void boot_${cname} (pTHX_ CV* cv);\n";
|
---|
63 | }
|
---|
64 |
|
---|
65 | my ($tail1,$tail2) = ( $tail =~ /\A(.*\n)(\s*\}.*)\Z/s );
|
---|
66 | print $tail1;
|
---|
67 |
|
---|
68 | print "\tconst char file[] = __FILE__;\n";
|
---|
69 | print "\tdXSUB_SYS;\n" if $] > 5.002;
|
---|
70 |
|
---|
71 | foreach $_ (@exts){
|
---|
72 | my($pname) = canon('/', $_);
|
---|
73 | my($mname, $cname, $ccode);
|
---|
74 | ($mname = $pname) =~ s!/!::!g;
|
---|
75 | ($cname = $pname) =~ s!/!__!g;
|
---|
76 | print "\t{\n";
|
---|
77 | if ($pname eq $dl){
|
---|
78 | # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
|
---|
79 | # boot_DynaLoader is called directly in DynaLoader.pm
|
---|
80 | $ccode = "\t/* DynaLoader is a special case */\n
|
---|
81 | \tnewXS(\"${mname}::boot_${cname}\", boot_${cname}, file);\n";
|
---|
82 | print $ccode unless $SEEN{$ccode}++;
|
---|
83 | } else {
|
---|
84 | $ccode = "\tnewXS(\"${mname}::bootstrap\", boot_${cname}, file);\n";
|
---|
85 | print $ccode unless $SEEN{$ccode}++;
|
---|
86 | }
|
---|
87 | print "\t}\n";
|
---|
88 | }
|
---|
89 | print $tail2;
|
---|
90 | }
|
---|
91 |
|
---|
92 | sub canon{
|
---|
93 | my($as, @ext) = @_;
|
---|
94 | foreach(@ext){
|
---|
95 | # might be X::Y or lib/auto/X/Y/Y.a
|
---|
96 | next if s!::!/!g;
|
---|
97 | s:^(lib|ext)/(auto/)?::;
|
---|
98 | s:/\w+\.\w+$::;
|
---|
99 | }
|
---|
100 | grep(s:/:$as:, @ext) if ($as ne '/');
|
---|
101 | @ext;
|
---|
102 | }
|
---|
103 |
|
---|
104 | 1;
|
---|
105 | __END__
|
---|
106 |
|
---|
107 | =head1 NAME
|
---|
108 |
|
---|
109 | ExtUtils::Miniperl, writemain - write the C code for perlmain.c
|
---|
110 |
|
---|
111 | =head1 SYNOPSIS
|
---|
112 |
|
---|
113 | C<use ExtUtils::Miniperl;>
|
---|
114 |
|
---|
115 | C<writemain(@directories);>
|
---|
116 |
|
---|
117 | =head1 DESCRIPTION
|
---|
118 |
|
---|
119 | This whole module is written when perl itself is built from a script
|
---|
120 | called minimod.PL. In case you want to patch it, please patch
|
---|
121 | minimod.PL in the perl distribution instead.
|
---|
122 |
|
---|
123 | writemain() takes an argument list of directories containing archive
|
---|
124 | libraries that relate to perl modules and should be linked into a new
|
---|
125 | perl binary. It writes to STDOUT a corresponding perlmain.c file that
|
---|
126 | is a plain C file containing all the bootstrap code to make the
|
---|
127 | modules associated with the libraries available from within perl.
|
---|
128 |
|
---|
129 | The typical usage is from within a Makefile generated by
|
---|
130 | ExtUtils::MakeMaker. So under normal circumstances you won't have to
|
---|
131 | deal with this module directly.
|
---|
132 |
|
---|
133 | =head1 SEE ALSO
|
---|
134 |
|
---|
135 | L<ExtUtils::MakeMaker>
|
---|
136 |
|
---|
137 | =cut
|
---|
138 |
|
---|
139 | END
|
---|