This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [ID 19990914.001] Perl_re_intuit_start() hangs in a loop
[perl5.git] / utils / perlbc.PL
CommitLineData
b295d113
TH
1#!/usr/local/bin/perl
2
3use Config;
4use File::Basename qw(&basename &dirname);
5use 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;
18chdir dirname($0);
19$file = basename($0, '.PL');
20$file .= '.com' if $^O eq 'VMS';
21
22open OUT,">$file" or die "Can't create $file: $!";
23
24print "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
29print 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
37print OUT <<'!NO!SUBS!';
38
39use strict;
40use warning;
41no warning qw(once);
42
43use Config;
44
45require ByteLoader;
46
47foreach 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
77close OUT or die "Can't close $file: $!";
78chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
79exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
80chdir $origdir;