This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Adapt perlivp to the ext/ reorganisation for Compress modules
[perl5.git] / utils / perldoc.PL
CommitLineData
4633a7c4
LW
1#!/usr/local/bin/perl
2
1a67fee7
HS
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;
4633a7c4
LW
9use Config;
10use File::Basename qw(&basename &dirname);
8a5546a1 11use 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
LW
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
HS
22
23my $origdir = cwd;
44a8e56a 24chdir dirname($0);
1a67fee7
HS
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
774d564b 30$file .= '.com' if $^O eq 'VMS';
4633a7c4
LW
31
32open OUT,">$file" or die "Can't create $file: $!";
33
1a67fee7 34print "Extracting \"$file\" (with variable substitutions)\n";
4633a7c4
LW
35
36# In this section, perl variables will be expanded during extraction.
37# You can use $Config{...} to use Configure variables.
38
85880f03 39print 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 46require 5;
1a67fee7 47BEGIN { \$^W = 1 if \$ENV{'PERLDOCDEBUG'} }
537c2f98 48use Pod::Perldoc;
1a67fee7 49exit( Pod::Perldoc->run() );
8167b455 50
4633a7c4
LW
51!GROK!THIS!
52
4633a7c4
LW
53
54close OUT or die "Can't close $file: $!";
55chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
56exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
8a5546a1 57chdir $origdir;
1a67fee7 58