ef7c457dda974d479397dfb1722a54bb751acfb0
[p5sagit/p5-mst-13.2.git] / utils / splain.PL
1 #!/usr/local/bin/perl
2
3 use Config;
4 use File::Basename qw(&basename &dirname);
5
6 # List explicitly here the variables you want Configure to
7 # generate.  Metaconfig only looks for shell variables, so you
8 # have to mention them as if they were shell variables, not
9 # %Config entries:
10 #  $startperl
11 #  $perlpath
12 #  $eunicefix
13
14 # This forces PL files to create target in same directory as PL file.
15 # This is so that make depend always knows where to find PL derivatives.
16 chdir dirname($0);
17 $file = basename($0, '.PL');
18
19 # Open input file before creating output file.
20 $IN = '../lib/diagnostics.pm';
21 open IN or die "Can't open $IN: $!\n";
22
23 # Create output file.
24 open OUT,">$file" or die "Can't create $file: $!";
25
26 print "Extracting $file (with variable substitutions)\n";
27
28 # In this section, perl variables will be expanded during extraction.
29 # You can use $Config{...} to use Configure variables.
30
31 print OUT <<"!GROK!THIS!";
32 $Config{startperl}
33     eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
34         if \$running_under_some_shell;
35 !GROK!THIS!
36
37 while (<IN>) {
38     print OUT unless /^package diagnostics/;
39 }
40
41 close IN;
42
43 close OUT or die "Can't close $file: $!";
44 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
45 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';