4 use File::Basename qw(&basename &dirname);
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
12 # to ensure Configure will look for $Config{startperl}.
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.
19 $file = basename($0, '.PL');
20 $file .= '.com' if $^O eq 'VMS';
22 open OUT,">$file" or die "Can't create $file: $!";
24 print "Extracting $file (with variable substitutions)\n";
26 # In this section, perl variables will be expanded during extraction.
27 # You can use $Config{...} to use Configure variables.
29 print OUT <<"!GROK!THIS!";
31 eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
32 if \$running_under_some_shell;
35 # In the following, perl variables are not expanded during extraction.
37 print OUT <<'!NO!SUBS!';
47 foreach my $infile (@ARGV)
49 if ($infile =~ /\.p[ml]$/)
51 my $outfile = $infile . "c";
53 open(OUT,"> $outfile") || die "Can't open $outfile: $!";
55 if ($infile =~ /\.pl$/)
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";
62 print OUT "use ByteLoader $ByteLoader::VERSION;\n";
66 print "$^X -MO=Bytecode $infile >> $outfile\n";
68 system("$^X -MO=Bytecode $infile >> $outfile");
72 warn "Don't know how to byte compile $infile";
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 ':';