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.
10 use File::Basename qw(&basename &dirname);
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
18 # to ensure Configure will look for $Config{startperl}.
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.
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+$/;
30 $file .= '.com' if $^O eq 'VMS';
32 open OUT,">$file" or die "Can't create $file: $!";
34 print "Extracting \"$file\" (with variable substitutions)\n";
36 # In this section, perl variables will be expanded during extraction.
37 # You can use $Config{...} to use Configure variables.
39 print OUT <<"!GROK!THIS!";
41 eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
44 # This "$file" file was generated by "$0"
48 BEGIN { \$^W = 1 if \$ENV{'PERLDOCDEBUG'} }
49 exit( Pod::Perldoc->run() );
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 ':';