1*0Sstevel@tonic-gate#!/usr/local/bin/perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateuse Config; 4*0Sstevel@tonic-gateuse File::Basename qw(&basename &dirname); 5*0Sstevel@tonic-gateuse Cwd; 6*0Sstevel@tonic-gate 7*0Sstevel@tonic-gate# List explicitly here the variables you want Configure to 8*0Sstevel@tonic-gate# generate. Metaconfig only looks for shell variables, so you 9*0Sstevel@tonic-gate# have to mention them as if they were shell variables, not 10*0Sstevel@tonic-gate# %Config entries. Thus you write 11*0Sstevel@tonic-gate# $startperl 12*0Sstevel@tonic-gate# to ensure Configure will look for $Config{startperl}. 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gate# This forces PL files to create target in same directory as PL file. 15*0Sstevel@tonic-gate# This is so that make depend always knows where to find PL derivatives. 16*0Sstevel@tonic-gate$origdir = cwd; 17*0Sstevel@tonic-gatechdir(dirname($0)); 18*0Sstevel@tonic-gate$file = basename($0, '.PL'); 19*0Sstevel@tonic-gate$file .= '.com' if $^O eq 'VMS'; 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gateopen OUT,">$file" or die "Can't create $file: $!"; 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gateprint "Extracting $file (with variable substitutions)\n"; 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate# In this section, perl variables will be expanded during extraction. 26*0Sstevel@tonic-gate# You can use $Config{...} to use Configure variables. 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gateprint OUT <<"!GROK!THIS!"; 29*0Sstevel@tonic-gate$Config{'startperl'} 30*0Sstevel@tonic-gate eval 'exec perl -S \$0 "\$@"' 31*0Sstevel@tonic-gate if 0; 32*0Sstevel@tonic-gate!GROK!THIS! 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate# In the following, perl variables are not expanded during extraction. 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gateprint OUT <<'!NO!SUBS!'; 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate############################################################################# 39*0Sstevel@tonic-gate# pod2usage -- command to print usage messages from embedded pod docs 40*0Sstevel@tonic-gate# 41*0Sstevel@tonic-gate# Copyright (c) 1996-2000 by Bradford Appleton. All rights reserved. 42*0Sstevel@tonic-gate# This file is part of "PodParser". PodParser is free software; 43*0Sstevel@tonic-gate# you can redistribute it and/or modify it under the same terms 44*0Sstevel@tonic-gate# as Perl itself. 45*0Sstevel@tonic-gate############################################################################# 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gateuse strict; 48*0Sstevel@tonic-gateuse diagnostics; 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate=head1 NAME 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gatepod2usage - print usage messages from embedded pod docs in files 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate=head1 SYNOPSIS 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate=over 12 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate=item B<pod2usage> 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate[B<-help>] 61*0Sstevel@tonic-gate[B<-man>] 62*0Sstevel@tonic-gate[B<-exit>S< >I<exitval>] 63*0Sstevel@tonic-gate[B<-output>S< >I<outfile>] 64*0Sstevel@tonic-gate[B<-verbose> I<level>] 65*0Sstevel@tonic-gate[B<-pathlist> I<dirlist>] 66*0Sstevel@tonic-gateI<file> 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate=back 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate=head1 OPTIONS AND ARGUMENTS 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate=over 8 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate=item B<-help> 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gatePrint a brief help message and exit. 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate=item B<-man> 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gatePrint this command's manual page and exit. 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate=item B<-exit> I<exitval> 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gateThe exit status value to return. 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate=item B<-output> I<outfile> 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gateThe output file to print to. If the special names "-" or ">&1" or ">&STDOUT" 89*0Sstevel@tonic-gateare used then standard output is used. If ">&2" or ">&STDERR" is used then 90*0Sstevel@tonic-gatestandard error is used. 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate=item B<-verbose> I<level> 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gateThe desired level of verbosity to use: 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate 1 : print SYNOPSIS only 97*0Sstevel@tonic-gate 2 : print SYNOPSIS sections and any OPTIONS/ARGUMENTS sections 98*0Sstevel@tonic-gate 3 : print the entire manpage (similar to running pod2text) 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate=item B<-pathlist> I<dirlist> 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gateSpecifies one or more directories to search for the input file if it 103*0Sstevel@tonic-gatewas not supplied with an absolute path. Each directory path in the given 104*0Sstevel@tonic-gatelist should be separated by a ':' on Unix (';' on MSWin32 and DOS). 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate=item I<file> 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gateThe pathname of a file containing pod documentation to be output in 109*0Sstevel@tonic-gateusage mesage format (defaults to standard input). 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate=back 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate=head1 DESCRIPTION 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gateB<pod2usage> will read the given input file looking for pod 116*0Sstevel@tonic-gatedocumentation and will print the corresponding usage message. 117*0Sstevel@tonic-gateIf no input file is specifed than standard input is read. 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gateB<pod2usage> invokes the B<pod2usage()> function in the B<Pod::Usage> 120*0Sstevel@tonic-gatemodule. Please see L<Pod::Usage/pod2usage()>. 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate=head1 SEE ALSO 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gateL<Pod::Usage>, L<pod2text(1)> 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate=head1 AUTHOR 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gatePlease report bugs using L<http://rt.cpan.org>. 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gateBrad Appleton E<lt>bradapp@enteract.comE<gt> 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gateBased on code for B<pod2text(1)> written by 133*0Sstevel@tonic-gateTom Christiansen E<lt>tchrist@mox.perl.comE<gt> 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate=cut 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gateuse Pod::Usage; 138*0Sstevel@tonic-gateuse Getopt::Long; 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate## Define options 141*0Sstevel@tonic-gatemy %options = (); 142*0Sstevel@tonic-gatemy @opt_specs = ( 143*0Sstevel@tonic-gate "help", 144*0Sstevel@tonic-gate "man", 145*0Sstevel@tonic-gate "exit=i", 146*0Sstevel@tonic-gate "output=s", 147*0Sstevel@tonic-gate "pathlist=s", 148*0Sstevel@tonic-gate "verbose=i", 149*0Sstevel@tonic-gate); 150*0Sstevel@tonic-gate 151*0Sstevel@tonic-gate## Parse options 152*0Sstevel@tonic-gateGetOptions(\%options, @opt_specs) || pod2usage(2); 153*0Sstevel@tonic-gatepod2usage(1) if ($options{help}); 154*0Sstevel@tonic-gatepod2usage(VERBOSE => 2) if ($options{man}); 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate## Dont default to STDIN if connected to a terminal 157*0Sstevel@tonic-gatepod2usage(2) if ((@ARGV == 0) && (-t STDIN)); 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate@ARGV = ("-") unless (@ARGV > 0); 160*0Sstevel@tonic-gateif (@ARGV > 1) { 161*0Sstevel@tonic-gate print STDERR "pod2usage: Too many filenames given\n\n"; 162*0Sstevel@tonic-gate pod2usage(2); 163*0Sstevel@tonic-gate} 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gatemy %usage = (); 166*0Sstevel@tonic-gate$usage{-input} = shift(@ARGV); 167*0Sstevel@tonic-gate$usage{-exitval} = $options{"exit"} if (defined $options{"exit"}); 168*0Sstevel@tonic-gate$usage{-output} = $options{"output"} if (defined $options{"output"}); 169*0Sstevel@tonic-gate$usage{-verbose} = $options{"verbose"} if (defined $options{"verbose"}); 170*0Sstevel@tonic-gate$usage{-pathlist} = $options{"pathlist"} if (defined $options{"pathlist"}); 171*0Sstevel@tonic-gate 172*0Sstevel@tonic-gatepod2usage(\%usage); 173*0Sstevel@tonic-gate 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate!NO!SUBS! 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gateclose OUT or die "Can't close $file: $!"; 178*0Sstevel@tonic-gatechmod 0755, $file or die "Can't reset permissions for $file: $!\n"; 179*0Sstevel@tonic-gateexec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; 180*0Sstevel@tonic-gatechdir $origdir; 181