Commit | Line | Data |
---|---|---|
5f05dabc | 1 | #!/usr/local/bin/perl |
2 | ||
ce957b55 N |
3 | use strict; |
4 | use warnings; | |
5 | ||
5f05dabc | 6 | use Config; |
7 | use File::Basename qw(&basename &dirname); | |
d5201bd2 | 8 | use File::Spec; |
8a5546a1 | 9 | use Cwd; |
5f05dabc | 10 | |
11 | # List explicitly here the variables you want Configure to | |
12 | # generate. Metaconfig only looks for shell variables, so you | |
13 | # have to mention them as if they were shell variables, not | |
14 | # %Config entries: | |
15 | # $startperl | |
16 | # $perlpath | |
17 | # $eunicefix | |
18 | ||
19 | # This forces PL files to create target in same directory as PL file. | |
20 | # This is so that make depend always knows where to find PL derivatives. | |
ce957b55 | 21 | my $origdir = cwd; |
44a8e56a | 22 | chdir dirname($0); |
ce957b55 | 23 | my $file = basename($0, '.PL'); |
774d564b | 24 | $file .= '.com' if $^O eq 'VMS'; |
5f05dabc | 25 | |
26 | # Open input file before creating output file. | |
ce957b55 | 27 | my $in = File::Spec->catfile(File::Spec->updir, 'lib', 'diagnostics.pm'); |
1ae6ead9 | 28 | open IN, '<', $in or die "Can't open $in: $!\n"; |
5f05dabc | 29 | |
30 | # Create output file. | |
1ae6ead9 | 31 | open OUT, '>', $file or die "Can't create $file: $!"; |
5f05dabc | 32 | |
33 | print "Extracting $file (with variable substitutions)\n"; | |
34 | ||
35 | # In this section, perl variables will be expanded during extraction. | |
36 | # You can use $Config{...} to use Configure variables. | |
37 | ||
38 | print OUT <<"!GROK!THIS!"; | |
39 | $Config{startperl} | |
40 | eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' | |
188e64dd | 41 | if 0; # ^ Run only under a shell |
5f05dabc | 42 | !GROK!THIS! |
43 | ||
2c25177b | 44 | print OUT <<'!NO!SUBS!'; |
cee96d52 TC |
45 | |
46 | BEGIN { pop @INC if $INC[-1] eq '.' } | |
47 | ||
48 | !NO!SUBS! | |
49 | ||
5f05dabc | 50 | while (<IN>) { |
51 | print OUT unless /^package diagnostics/; | |
52 | } | |
53 | ||
54 | close IN; | |
55 | ||
56 | close OUT or die "Can't close $file: $!"; | |
57 | chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; | |
58 | exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; | |
8a5546a1 | 59 | chdir $origdir; |