xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/utils/splain.PL (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/usr/local/bin/perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateuse Config;
4*0Sstevel@tonic-gateuse File::Basename qw(&basename &dirname);
5*0Sstevel@tonic-gateuse File::Spec;
6*0Sstevel@tonic-gateuse Cwd;
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gate# List explicitly here the variables you want Configure to
9*0Sstevel@tonic-gate# generate.  Metaconfig only looks for shell variables, so you
10*0Sstevel@tonic-gate# have to mention them as if they were shell variables, not
11*0Sstevel@tonic-gate# %Config entries:
12*0Sstevel@tonic-gate#  $startperl
13*0Sstevel@tonic-gate#  $perlpath
14*0Sstevel@tonic-gate#  $eunicefix
15*0Sstevel@tonic-gate
16*0Sstevel@tonic-gate# This forces PL files to create target in same directory as PL file.
17*0Sstevel@tonic-gate# This is so that make depend always knows where to find PL derivatives.
18*0Sstevel@tonic-gate$origdir = cwd;
19*0Sstevel@tonic-gatechdir dirname($0);
20*0Sstevel@tonic-gate$file = basename($0, '.PL');
21*0Sstevel@tonic-gate$file .= '.com' if $^O eq 'VMS';
22*0Sstevel@tonic-gate
23*0Sstevel@tonic-gate# Open input file before creating output file.
24*0Sstevel@tonic-gate$IN = File::Spec->catfile(File::Spec->updir, 'lib', 'diagnostics.pm');
25*0Sstevel@tonic-gateopen IN or die "Can't open $IN: $!\n";
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate# Create output file.
28*0Sstevel@tonic-gateopen OUT,">$file" or die "Can't create $file: $!";
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gateprint "Extracting $file (with variable substitutions)\n";
31*0Sstevel@tonic-gate
32*0Sstevel@tonic-gate# In this section, perl variables will be expanded during extraction.
33*0Sstevel@tonic-gate# You can use $Config{...} to use Configure variables.
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gateprint OUT <<"!GROK!THIS!";
36*0Sstevel@tonic-gate$Config{startperl}
37*0Sstevel@tonic-gate    eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
38*0Sstevel@tonic-gate	if \$running_under_some_shell;
39*0Sstevel@tonic-gate!GROK!THIS!
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gatewhile (<IN>) {
42*0Sstevel@tonic-gate    print OUT unless /^package diagnostics/;
43*0Sstevel@tonic-gate}
44*0Sstevel@tonic-gate
45*0Sstevel@tonic-gateclose IN;
46*0Sstevel@tonic-gate
47*0Sstevel@tonic-gateclose OUT or die "Can't close $file: $!";
48*0Sstevel@tonic-gatechmod 0755, $file or die "Can't reset permissions for $file: $!\n";
49*0Sstevel@tonic-gateexec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
50*0Sstevel@tonic-gatechdir $origdir;
51