Commit | Line | Data |
360aca43 |
1 | #!/usr/local/bin/perl |
2 | |
3 | use Config; |
4 | use File::Basename qw(&basename &dirname); |
5 | |
6 | # List explicitly here the variables you want Configure to |
7 | # generate. Metaconfig only looks for shell variables, so you |
8 | # have to mention them as if they were shell variables, not |
9 | # %Config entries. Thus you write |
10 | # $startperl |
11 | # to ensure Configure will look for $Config{startperl}. |
12 | |
b233458b |
13 | $file = basename($0); |
14 | $file =~ s/\.PL$//i; |
15 | $file .= '.com' if $^O eq 'VMS'; |
360aca43 |
16 | |
b233458b |
17 | chdir("pod") or die "Can't chdir to pod: $!"; |
360aca43 |
18 | open OUT,">$file" or die "Can't create $file: $!"; |
19 | |
20 | print "Extracting $file (with variable substitutions)\n"; |
21 | |
22 | # In this section, perl variables will be expanded during extraction. |
23 | # You can use $Config{...} to use Configure variables. |
24 | |
25 | print OUT <<"!GROK!THIS!"; |
26 | $Config{'startperl'} |
27 | eval 'exec perl -S \$0 "\$@"' |
28 | if 0; |
29 | !GROK!THIS! |
30 | |
31 | # In the following, perl variables are not expanded during extraction. |
32 | |
33 | print OUT <<'!NO!SUBS!'; |
34 | |
35 | ############################################################################# |
36 | # pod2usage -- command to print usage messages from embedded pod docs |
37 | # |
38 | # Derived from Tom Christiansen's pod2text script. |
39 | # (with extensive modifications) |
40 | # |
41 | # Copyright (c) 1996 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 | I<file> |
67 | |
68 | =back |
69 | |
70 | =head1 OPTIONS AND ARGUMENTS |
71 | |
72 | =over 8 |
73 | |
74 | =item B<-help> |
75 | |
76 | Print a brief help message and exit. |
77 | |
78 | =item B<-man> |
79 | |
80 | Print this command's manual page and exit. |
81 | |
82 | =item B<-exit> I<exitval> |
83 | |
84 | The exit status value to return. |
85 | |
86 | =item B<-output> I<outfile> |
87 | |
88 | The output file to print to. If the special names "-" or ">&1" or ">&STDOUT" |
89 | are used then standard output is used. If ">&2" or ">&STDERR" is used then |
90 | standard error is used. |
91 | |
92 | =item B<-verbose> I<level> |
93 | |
94 | The desired level of verbosity to use: |
95 | |
96 | 1 : print SYNOPSIS only |
97 | 2 : print SYNOPSIS sections and any OPTIONS/ARGUMENTS sections |
98 | 3 : print the entire manpage (similar to running pod2text) |
99 | |
100 | =item B<-pathlist> I<dirlist> |
101 | |
102 | Specifies one or more directories to search for the input file if it |
103 | was not supplied with an absolute path. Each directory path in the given |
104 | list should be separated by a ':' on Unix (';' on MSWin32 and DOS). |
105 | |
106 | =item I<file> |
107 | |
108 | The pathname of a file containing pod documentation to be output in |
109 | usage mesage format (defaults to standard input). |
110 | |
111 | =back |
112 | |
113 | =head1 DESCRIPTION |
114 | |
115 | B<pod2usage> will read the given input file looking for pod |
116 | documentation and will print the corresponding usage message. |
117 | If no input file is specifed than standard input is read. |
118 | |
119 | B<pod2usage> invokes the B<pod2usage()> function in the B<Pod::Usage> |
120 | module. Please see L<Pod::Usage/pod2usage()>. |
121 | |
122 | =head1 SEE ALSO |
123 | |
124 | L<Pod::Usage>, L<pod2text(1)> |
125 | |
126 | =head1 AUTHOR |
127 | |
128 | Brad Appleton E<lt>bradapp@enteract.comE<gt> |
129 | |
130 | Based on code for B<pod2text(1)> written by |
131 | Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> |
132 | |
133 | =cut |
134 | |
135 | use Pod::Usage; |
136 | use Getopt::Long; |
137 | |
138 | ## Define options |
139 | my %options = (); |
140 | my @opt_specs = ( |
141 | "help", |
142 | "man", |
143 | "exit=i", |
144 | "output=s", |
145 | "pathlist=s", |
146 | "verbose=i", |
147 | ); |
148 | |
149 | ## Parse options |
150 | GetOptions(\%options, @opt_specs) || pod2usage(2); |
151 | pod2usage(1) if ($options{help}); |
152 | pod2usage(VERBOSE => 2) if ($options{man}); |
153 | |
154 | ## Dont default to STDIN if connected to a terminal |
155 | pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); |
156 | |
157 | @ARGV = ("-") unless (@ARGV > 0); |
158 | if (@ARGV > 1) { |
159 | print STDERR "pod2usage: Too many filenames given\n\n"; |
160 | pod2usage(2); |
161 | } |
162 | |
163 | my %usage = (); |
164 | $usage{-input} = shift(@ARGV); |
165 | $usage{-exitval} = $options{"exit"} if (defined $options{"exit"}); |
166 | $usage{-output} = $options{"output"} if (defined $options{"output"}); |
167 | $usage{-verbose} = $options{"verbose"} if (defined $options{"verbose"}); |
168 | $usage{-pathlist} = $options{"pathlist"} if (defined $options{"pathlist"}); |
169 | |
170 | pod2usage(\%usage); |
171 | |
172 | |
173 | !NO!SUBS! |
174 | |
175 | close OUT or die "Can't close $file: $!"; |
176 | chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; |
177 | exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; |