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