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