Commit | Line | Data |
4633a7c4 |
1 | #!/usr/local/bin/perl |
2 | |
1a67fee7 |
3 | # This is for generating the perldoc executable. |
4 | # It may eventually be expanded to generate many executables, as |
5 | # explained in the preface of /Programming Perl/ 3e. |
6 | |
7 | require 5; |
8 | use strict; |
4633a7c4 |
9 | use Config; |
10 | use File::Basename qw(&basename &dirname); |
8a5546a1 |
11 | use Cwd; |
4633a7c4 |
12 | |
85880f03 |
13 | # List explicitly here the variables you want Configure to |
14 | # generate. Metaconfig only looks for shell variables, so you |
15 | # have to mention them as if they were shell variables, not |
16 | # %Config entries. Thus you write |
4633a7c4 |
17 | # $startperl |
85880f03 |
18 | # to ensure Configure will look for $Config{startperl}. |
4633a7c4 |
19 | |
20 | # This forces PL files to create target in same directory as PL file. |
21 | # This is so that make depend always knows where to find PL derivatives. |
1a67fee7 |
22 | |
23 | my $origdir = cwd; |
44a8e56a |
24 | chdir dirname($0); |
1a67fee7 |
25 | my $file = basename($0, '.PL'); |
26 | my $file_shortname = $file; # should be like "perldoc", maybe "perlsyn", etc. |
27 | warn "How odd, I'm going to generate $file_shortname?!" |
28 | unless $file_shortname =~ m/^\w+$/; |
29 | |
774d564b |
30 | $file .= '.com' if $^O eq 'VMS'; |
4633a7c4 |
31 | |
32 | open OUT,">$file" or die "Can't create $file: $!"; |
33 | |
1a67fee7 |
34 | print "Extracting \"$file\" (with variable substitutions)\n"; |
4633a7c4 |
35 | |
36 | # In this section, perl variables will be expanded during extraction. |
37 | # You can use $Config{...} to use Configure variables. |
38 | |
85880f03 |
39 | print OUT <<"!GROK!THIS!"; |
5f05dabc |
40 | $Config{startperl} |
41 | eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' |
c5ae3962 |
42 | if 0; |
55497cff |
43 | |
1a67fee7 |
44 | # This "$file" file was generated by "$0" |
ed6d8ea1 |
45 | |
1a67fee7 |
46 | require 5; |
1a67fee7 |
47 | BEGIN { \$^W = 1 if \$ENV{'PERLDOCDEBUG'} } |
537c2f98 |
48 | use Pod::Perldoc; |
1a67fee7 |
49 | exit( Pod::Perldoc->run() ); |
8167b455 |
50 | |
4633a7c4 |
51 | !GROK!THIS! |
52 | |
4633a7c4 |
53 | |
54 | close OUT or die "Can't close $file: $!"; |
55 | chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; |
56 | exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; |
8a5546a1 |
57 | chdir $origdir; |
1a67fee7 |
58 | |