Commit | Line | Data |
b295d113 |
1 | #!/usr/local/bin/perl |
2 | |
3 | use Config; |
4 | use File::Basename qw(&basename &dirname); |
5 | use Cwd; |
6 | |
7 | # List explicitly here the variables you want Configure to |
8 | # generate. Metaconfig only looks for shell variables, so you |
9 | # have to mention them as if they were shell variables, not |
10 | # %Config entries. Thus you write |
11 | # $startperl |
12 | # to ensure Configure will look for $Config{startperl}. |
13 | # Wanted: $archlibexp |
14 | |
15 | # This forces PL files to create target in same directory as PL file. |
16 | # This is so that make depend always knows where to find PL derivatives. |
17 | $origdir = cwd; |
18 | chdir dirname($0); |
19 | $file = basename($0, '.PL'); |
20 | $file .= '.com' if $^O eq 'VMS'; |
21 | |
22 | open OUT,">$file" or die "Can't create $file: $!"; |
23 | |
24 | print "Extracting $file (with variable substitutions)\n"; |
25 | |
26 | # In this section, perl variables will be expanded during extraction. |
27 | # You can use $Config{...} to use Configure variables. |
28 | |
29 | print OUT <<"!GROK!THIS!"; |
30 | $Config{startperl} |
31 | eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' |
32 | if \$running_under_some_shell; |
33 | !GROK!THIS! |
34 | |
35 | # In the following, perl variables are not expanded during extraction. |
36 | |
37 | print OUT <<'!NO!SUBS!'; |
38 | |
39 | use strict; |
40 | use warning; |
41 | no warning qw(once); |
42 | |
43 | use Config; |
44 | |
45 | require ByteLoader; |
46 | |
47 | foreach my $infile (@ARGV) |
48 | { |
49 | if ($infile =~ /\.p[ml]$/) |
50 | { |
51 | my $outfile = $infile . "c"; |
52 | |
53 | open(OUT,"> $outfile") || die "Can't open $outfile: $!"; |
54 | |
55 | if ($infile =~ /\.pl$/) |
56 | { |
57 | print OUT "$Config{startperl}\n"; |
58 | print OUT " eval 'exec $Config{perlpath} -S \$0 \${1+\"\$@\"}'\n"; |
59 | print OUT " if \$running_under_some_shell;\n\n"; |
60 | } |
61 | |
62 | print OUT "use ByteLoader $ByteLoader::VERSION;\n"; |
63 | |
64 | close(OUT); |
65 | |
66 | print "$^X -MO=Bytecode $infile >> $outfile\n"; |
67 | |
68 | system("$^X -MO=Bytecode $infile >> $outfile"); |
69 | } |
70 | else |
71 | { |
72 | warn "Don't know how to byte compile $infile"; |
73 | } |
74 | } |
75 | !NO!SUBS! |
76 | |
77 | close OUT or die "Can't close $file: $!"; |
78 | chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; |
79 | exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; |
80 | chdir $origdir; |