1#!/usr/local/bin/perl 2 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 7require 5; 8use strict; 9use Config; 10use File::Basename qw(&basename &dirname); 11use Cwd; 12 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 17# $startperl 18# to ensure Configure will look for $Config{startperl}. 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. 22 23my $origdir = cwd; 24chdir dirname($0); 25my $file = basename($0, '.PL'); 26my $file_shortname = $file; # should be like "perldoc", maybe "perlsyn", etc. 27warn "How odd, I'm going to generate $file_shortname?!" 28 unless $file_shortname =~ m/^\w+$/; 29 30$file .= '.com' if $^O eq 'VMS'; 31 32open OUT, ">", $file or die "Can't create $file: $!"; 33 34print "Extracting \"$file\" (with variable substitutions)\n"; 35 36# In this section, perl variables will be expanded during extraction. 37# You can use $Config{...} to use Configure variables. 38 39print OUT <<"!GROK!THIS!"; 40$Config{startperl} 41 eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' 42 if 0; 43 44# This "$file" file was generated by "$0" 45 46require 5; 47BEGIN { 48 \$^W = 1 if \$ENV{'PERLDOCDEBUG'}; 49 pop \@INC if \$INC[-1] eq '.'; 50} 51use Pod::Perldoc; 52exit( Pod::Perldoc->run() ); 53 54!GROK!THIS! 55 56 57close OUT or die "Can't close $file: $!"; 58chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; 59exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; 60chdir $origdir; 61 62