Commit | Line | Data |
4755096e |
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)) =~ s/\.PL$//; |
19 | $file =~ s/\.pl$// if ($^O eq 'os2' or $^O eq 'dos'); # "case-forgiving" |
20 | $file =~ s/\.pl$/.com/ if ($^O eq 'VMS'); # "case-forgiving" |
21 | |
22 | open OUT,">$file" or die "Can't create $file: $!"; |
23 | |
24 | print "Extracting $file (with variable substitutions)\n"; |
25 | |
26 | # In this section, perl variables will be expanded during extraction. |
27 | # You can use $Config{...} to use Configure variables. |
28 | |
29 | print OUT <<"!GROK!THIS!"; |
30 | $Config{'startperl'} |
31 | eval 'exec perl -S \$0 "\$@"' |
32 | if 0; |
33 | !GROK!THIS! |
34 | |
35 | # In the following, perl variables are not expanded during extraction. |
36 | |
37 | print OUT <<'!NO!SUBS!'; |
38 | |
39 | # |
40 | # buildtoc |
41 | # |
42 | # !!!!!!! DO NOT EDIT THIS FILE !!!!!!! |
43 | # This file is autogenerated by buildtoc.PL. |
44 | # Edit that file and run it to effect changes. |
45 | # |
46 | # Builds perltoc.pod and sanity checks the list of pods against all |
47 | # of the MANIFEST, perl.pod, and ourselves. |
48 | # |
49 | |
50 | use File::Find; |
51 | use Cwd; |
52 | use Text::Wrap; |
53 | |
54 | @PODS = glob("*.pod"); |
55 | |
56 | sub output ($); |
57 | |
58 | if (-d "pod") { |
59 | die "$0: failed to chdir('pod'): $!\n" unless chdir("pod"); |
60 | } |
61 | |
a83b6f46 |
62 | @ARCHPODS = qw( |
63 | perlaix |
64 | perlapollo |
65 | perlamiga |
66 | perlbeos |
67 | perlbs2000 |
a1f19229 |
68 | perlce |
a83b6f46 |
69 | perlcygwin |
70 | perldgux |
71 | perldos |
72 | perlepoc |
73 | perlhpux |
74 | perlhurd |
75 | perlmachten |
76 | perlmacos |
77 | perlmint |
78 | perlmpeix |
9038e305 |
79 | perlnetware |
a83b6f46 |
80 | perlos2 |
81 | perlos390 |
82 | perlqnx |
83 | perlplan9 |
84 | perlsolaris |
85 | perltru64 |
91144103 |
86 | perluts |
a83b6f46 |
87 | perlvmesa |
88 | perlvms |
89 | perlvos |
90 | perlwin32 |
91 | ); |
92 | |
93 | @pods = |
94 | ( |
95 | qw( |
96 | |
c2e66d9e |
97 | perl |
10151d09 |
98 | perlintro |
c2e66d9e |
99 | perlfaq |
100 | perltoc |
101 | perlbook |
102 | |
103 | perlsyn |
104 | perldata |
105 | perlop |
106 | perlsub |
107 | perlfunc |
108 | perlreftut |
109 | perldsc |
110 | perlrequick |
111 | perlpod |
8a93676d |
112 | perlpodspec |
c2e66d9e |
113 | perlstyle |
114 | perltrap |
115 | |
116 | perlrun |
117 | perldiag |
118 | perllexwarn |
10862624 |
119 | perldebtut |
c2e66d9e |
120 | perldebug |
121 | |
122 | perlvar |
123 | perllol |
124 | perlopentut |
125 | perlretut |
126 | |
c2e66d9e |
127 | perlre |
d396a558 |
128 | perlref |
129 | |
c2e66d9e |
130 | perlform |
d396a558 |
131 | |
132 | perlboot |
133 | perltoot |
890a53b9 |
134 | perltooc |
d396a558 |
135 | perlobj |
136 | perlbot |
137 | perltie |
c2e66d9e |
138 | |
139 | perlipc |
140 | perlfork |
141 | perlnumber |
53d7eaa8 |
142 | |
c2e66d9e |
143 | perlthrtut |
53d7eaa8 |
144 | perlothrtut |
c2e66d9e |
145 | |
146 | perlport |
d396a558 |
147 | perllocale |
07fcf8ff |
148 | perluniintro |
d396a558 |
149 | perlunicode |
150 | perlebcdic |
c2e66d9e |
151 | |
d396a558 |
152 | perlsec |
c2e66d9e |
153 | |
154 | perlmod |
c2e66d9e |
155 | perlmodinstall |
35bf961c |
156 | perlmodlib |
157 | perlmodstyle |
c2e66d9e |
158 | perlnewmod |
159 | |
4755096e |
160 | perlfaq1 |
161 | perlfaq2 |
162 | perlfaq3 |
163 | perlfaq4 |
164 | perlfaq5 |
165 | perlfaq6 |
166 | perlfaq7 |
167 | perlfaq8 |
168 | perlfaq9 |
169 | |
170 | perlcompile |
171 | |
172 | perlembed |
173 | perldebguts |
174 | perlxstut |
175 | perlxs |
f40a6c71 |
176 | perlclib |
4755096e |
177 | perlguts |
178 | perlcall |
179 | perlutil |
180 | perlfilter |
181 | perldbmfilter |
182 | perlapi |
183 | perlintern |
dc5c060f |
184 | perliol |
4755096e |
185 | perlapio |
186 | perltodo |
187 | perlhack |
188 | |
189 | perlhist |
190 | perldelta |
245d750e |
191 | perl572delta |
1db9e106 |
192 | perl571delta |
193 | perl570delta |
4755096e |
194 | perl56delta |
195 | perl5005delta |
196 | perl5004delta |
197 | |
a83b6f46 |
198 | ), |
199 | |
200 | @ARCHPODS |
201 | |
202 | ); |
4755096e |
203 | |
4755096e |
204 | for (@ARCHPODS) { s/$/.pod/ } |
205 | @ARCHPODS{@ARCHPODS} = (); |
206 | |
207 | for (@pods) { s/$/.pod/ } |
208 | @pods{@pods} = (); |
209 | @PODS{@PODS} = (); |
210 | |
211 | open(MANI, "../MANIFEST") || die "$0: opening ../MANIFEST failed: $!"; |
212 | while (<MANI>) { |
213 | if (m!^pod/([^.]+\.pod)\s+!i) { |
214 | push @MANIPODS, $1; |
215 | } |
216 | } |
217 | close(MANI); |
218 | @MANIPODS{@MANIPODS} = (); |
219 | |
220 | open(PERLPOD, "perl.pod") || die "$0: opening perl.pod failed: $!\n"; |
221 | while (<PERLPOD>) { |
222 | if (/^For ease of access, /../^\(If you're intending /) { |
c2e66d9e |
223 | if (/^\s+(perl\S*)\s+\w/) { |
4755096e |
224 | push @PERLPODS, "$1.pod"; |
225 | } |
226 | } |
227 | } |
228 | close(PERLPOD); |
229 | die "$0: could not find the pod listing of perl.pod\n" |
230 | unless @PERLPODS; |
231 | @PERLPODS{@PERLPODS} = (); |
232 | |
233 | # Cross-check against ourselves |
234 | # Cross-check against the MANIFEST |
235 | # Cross-check against the perl.pod |
236 | |
237 | foreach my $i (sort keys %PODS) { |
238 | warn "$0: $i exists but is unknown by buildtoc\n" |
239 | unless exists $pods{$i}; |
240 | warn "$0: $i exists but is unknown by ../MANIFEST\n" |
241 | if !exists $MANIPODS{$i} && !exists $ARCHPODS{$i}; |
242 | warn "$0: $i exists but is unknown by perl.pod\n" |
243 | unless exists $PERLPODS{$i}; |
244 | } |
245 | foreach my $i (sort keys %pods) { |
246 | warn "$0: $i is known by buildtoc but does not exist\n" |
247 | unless exists $PODS{$i}; |
248 | } |
249 | foreach my $i (sort keys %MANIPODS) { |
250 | warn "$0: $i is known by ../MANIFEST but does not exist\n" |
251 | unless exists $PODS{$i}; |
252 | } |
253 | foreach my $i (sort keys %PERLPODS) { |
254 | warn "$0: $i is known by perl.pod but does not exist\n" |
255 | unless exists $PODS{$i}; |
256 | } |
257 | |
258 | # We are ready to rock. |
259 | open(OUT, ">perltoc.pod") || die "$0: creating perltoc.pod failed: $!"; |
260 | |
261 | $/ = ''; |
262 | @ARGV = @pods; |
263 | |
264 | ($_= <<EOPOD2B) =~ s/^\t//gm && output($_); |
265 | |
266 | =head1 NAME |
267 | |
268 | perltoc - perl documentation table of contents |
269 | |
270 | =head1 DESCRIPTION |
271 | |
272 | This page provides a brief table of contents for the rest of the Perl |
273 | documentation set. It is meant to be scanned quickly or grepped |
274 | through to locate the proper section you're looking for. |
275 | |
276 | =head1 BASIC DOCUMENTATION |
277 | |
278 | EOPOD2B |
279 | #' make emacs happy |
280 | |
281 | podset(@pods); |
282 | |
283 | find \&getpods => qw(../lib ../ext); |
284 | |
285 | sub getpods { |
286 | if (/\.p(od|m)$/) { |
287 | # Skip .pm files that have corresponding .pod files, and Functions.pm. |
288 | return if /(.*)\.pm$/ && -f "$1.pod"; |
289 | my $file = $File::Find::name; |
290 | return if $file eq '../lib/Pod/Functions.pm'; # Used only by pod itself |
a83b6f46 |
291 | return if $file =~ m!lib/Attribute/Handlers/demo/!; |
bc3d371b |
292 | return if $file =~ m!lib/Net/FTP/.+\.pm!; # Hi, Graham! :-) |
ba62762e |
293 | return if $file =~ m!lib/Math/BigInt/t/!; |
428dc699 |
294 | return if $file =~ m!lib/Devel/Harness.pm|Devel/PPPort/harness/!; |
4755096e |
295 | |
296 | die "tut $name" if $file =~ /TUT/; |
297 | unless (open (F, "< $_\0")) { |
298 | warn "bogus <$file>: $!"; |
299 | system "ls", "-l", $file; |
300 | } |
301 | else { |
302 | my $line; |
303 | while ($line = <F>) { |
304 | if ($line =~ /^=head1\s+NAME\b/) { |
305 | push @modpods, $file; |
306 | #warn "GOOD $file\n"; |
307 | return; |
308 | } |
309 | } |
310 | warn "$0: $file: cannot find =head1 NAME\n"; |
311 | } |
312 | } |
313 | } |
314 | |
315 | die "no pods" unless @modpods; |
316 | |
317 | for (@modpods) { |
318 | #($name) = /(\w+)\.p(m|od)$/; |
319 | $name = path2modname($_); |
320 | if ($name =~ /^[a-z]/) { |
321 | push @pragmata, $_; |
322 | } else { |
323 | if ($done{$name}++) { |
324 | # warn "already did $_\n"; |
325 | next; |
326 | } |
327 | push @modules, $_; |
328 | push @modname, $name; |
329 | } |
330 | } |
331 | |
332 | ($_= <<EOPOD2B) =~ s/^\t//gm && output($_); |
333 | |
334 | |
335 | |
336 | =head1 PRAGMA DOCUMENTATION |
337 | |
338 | EOPOD2B |
339 | |
340 | podset(sort @pragmata); |
341 | |
342 | ($_= <<EOPOD2B) =~ s/^\t//gm && output($_); |
343 | |
344 | |
345 | |
346 | =head1 MODULE DOCUMENTATION |
347 | |
348 | EOPOD2B |
349 | |
350 | podset( @modules[ sort { $modname[$a] cmp $modname[$b] } 0 .. $#modules ] ); |
351 | |
352 | ($_= <<EOPOD2B) =~ s/^\t//gm; |
353 | |
354 | |
355 | =head1 AUXILIARY DOCUMENTATION |
356 | |
357 | Here should be listed all the extra programs' documentation, but they |
358 | don't all have manual pages yet: |
359 | |
13a2d996 |
360 | =over 4 |
4755096e |
361 | |
362 | =item a2p |
363 | |
364 | =item s2p |
365 | |
366 | =item find2perl |
367 | |
368 | =item h2ph |
369 | |
370 | =item c2ph |
371 | |
372 | =item h2xs |
373 | |
374 | =item xsubpp |
375 | |
376 | =item pod2man |
377 | |
378 | =item wrapsuid |
379 | |
380 | =back |
381 | |
382 | =head1 AUTHOR |
383 | |
384 | Larry Wall <F<larry\@wall.org>>, with the help of oodles |
385 | of other folks. |
386 | |
387 | |
388 | EOPOD2B |
389 | output $_; |
390 | output "\n"; # flush $LINE |
391 | exit; |
392 | |
393 | sub podset { |
394 | local @ARGV = @_; |
395 | |
396 | while(<>) { |
397 | if (s/^=head1 (NAME)\s*/=head2 /) { |
398 | $pod = path2modname($ARGV); |
399 | unhead1(); |
400 | output "\n \n\n=head2 "; |
401 | $_ = <>; |
402 | if ( /^\s*$pod\b/ ) { |
403 | s/$pod\.pm/$pod/; # '.pm' in NAME !? |
404 | output $_; |
405 | } else { |
406 | s/^/$pod, /; |
407 | output $_; |
408 | } |
409 | next; |
410 | } |
411 | if (s/^=head1 (.*)/=item $1/) { |
412 | unhead2(); |
13a2d996 |
413 | output "=over 4\n\n" unless $inhead1; |
4755096e |
414 | $inhead1 = 1; |
415 | output $_; nl(); next; |
416 | } |
417 | if (s/^=head2 (.*)/=item $1/) { |
418 | unitem(); |
13a2d996 |
419 | output "=over 4\n\n" unless $inhead2; |
4755096e |
420 | $inhead2 = 1; |
421 | output $_; nl(); next; |
422 | } |
423 | if (s/^=item ([^=].*)/$1/) { |
424 | next if $pod eq 'perldiag'; |
425 | s/^\s*\*\s*$// && next; |
426 | s/^\s*\*\s*//; |
427 | s/\n/ /g; |
428 | s/\s+$//; |
429 | next if /^[\d.]+$/; |
430 | next if $pod eq 'perlmodlib' && /^ftp:/; |
13a2d996 |
431 | ##print "=over 4\n\n" unless $initem; |
4755096e |
432 | output ", " if $initem; |
433 | $initem = 1; |
434 | s/\.$//; |
435 | s/^-X\b/-I<X>/; |
436 | output $_; next; |
437 | } |
438 | if (s/^=cut\s*\n//) { |
439 | unhead1(); |
440 | next; |
441 | } |
442 | } |
443 | } |
444 | |
445 | sub path2modname { |
446 | local $_ = shift; |
447 | s/\.p(m|od)$//; |
448 | s-.*?/(lib|ext)/--; |
449 | s-/-::-g; |
450 | s/(\w+)::\1/$1/; |
451 | return $_; |
452 | } |
453 | |
454 | sub unhead1 { |
455 | unhead2(); |
456 | if ($inhead1) { |
457 | output "\n\n=back\n\n"; |
458 | } |
459 | $inhead1 = 0; |
460 | } |
461 | |
462 | sub unhead2 { |
463 | unitem(); |
464 | if ($inhead2) { |
465 | output "\n\n=back\n\n"; |
466 | } |
467 | $inhead2 = 0; |
468 | } |
469 | |
470 | sub unitem { |
471 | if ($initem) { |
472 | output "\n\n"; |
473 | ##print "\n\n=back\n\n"; |
474 | } |
475 | $initem = 0; |
476 | } |
477 | |
478 | sub nl { |
479 | output "\n"; |
480 | } |
481 | |
482 | my $NEWLINE; # how many newlines have we seen recently |
483 | my $LINE; # what remains to be printed |
484 | |
485 | sub output ($) { |
486 | for (split /(\n)/, shift) { |
487 | if ($_ eq "\n") { |
488 | if ($LINE) { |
489 | print OUT wrap('', '', $LINE); |
490 | $LINE = ''; |
491 | } |
492 | if ($NEWLINE < 2) { |
493 | print OUT; |
494 | $NEWLINE++; |
495 | } |
496 | } |
497 | elsif (/\S/ && length) { |
498 | $LINE .= $_; |
499 | $NEWLINE = 0; |
500 | } |
501 | } |
502 | } |
503 | |
504 | !NO!SUBS! |
505 | |
6bbf1b34 |
506 | close OUT or die "Can't close $file: $!"; |
507 | chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; |
508 | exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; |
509 | chdir $origdir; |