use Text::Tabs;
use Text::Wrap;
use Getopt::Long;
-use Carp;
-# Generate the sections of files listed in %Targets from pod.lst
+if (ord("A") == 193) {
+ print "1..0 # EBCDIC sort order is different\n";
+ exit;
+}
+
+# Generate the sections of files listed in %Targets from pod/perl.pod
# Mostly these are rules in Makefiles
#
# --verbose gives slightly more output
# --build-all tries to build everything
# --build-foo updates foo as follows
# --showfiles shows the files to be changed
-# --test exit if perl.pod, pod.lst, MANIFEST are consistent, and regenerated
+# --test exit if perl.pod, MANIFEST are consistent, and regenerated
# files are up to date, die otherwise.
%Targets = (
manifest => 'MANIFEST',
- perlpod => 'pod/perl.pod',
vms => 'vms/descrip_mms.template',
nmake => 'win32/Makefile',
dmake => 'win32/makefile.mk',
+ gmake => 'win32/GNUmakefile',
podmak => 'win32/pod.mak',
unix => 'Makefile.SH',
# plan9 => 'plan9/mkfile',
}
if ($Verbose) {
- print "I will be building $_\n" foreach keys %Build;
+ print "I will be building $_\n" foreach sort keys %Build;
}
my $test = 1;
? get_pod_metadata(0, sub {
printf "1..%d\n", 1 + scalar keys %Build;
if (@_) {
- print "not ok $test\n";
+ print "not ok $test # got Pod metadata\n";
die @_;
}
- print "ok $test\n";
+ print "ok $test # got Pod metadata\n";
})
: get_pod_metadata(1, sub { warn @_ if @_ }, values %Build);
-sub generate_perlpod {
- my @output;
- my $maxlength = 0;
- foreach (@{$state->{master}}) {
- my $flags = $_->[0];
- next if $flags->{aux};
- next if $flags->{perlpod_omit};
-
- if (@$_ == 2) {
- # Heading
- push @output, "=head2 $_->[1]\n";
- } elsif (@$_ == 5) {
- # Section
- my $start = " " x (4 + $flags->{indent}) . $_->[4];
- $maxlength = length $start if length ($start) > $maxlength;
- push @output, [$start, $_->[3]];
- } elsif (@$_ == 0) {
- # blank line
- push @output, "\n";
- } else {
- my_die "Illegal length " . scalar @$_;
- }
- }
- # want at least 2 spaces padding
- $maxlength += 2;
- $maxlength = ($maxlength + 3) & ~3;
- # sprintf gives $1.....$2 where ... are spaces:
- return unexpand (map {ref $_ ? sprintf "%-${maxlength}s%s\n", @$_ : $_}
- @output);
-}
-
sub generate_manifest {
# Annoyingly, unexpand doesn't consider it good form to replace a single
# space before a tab with a tab
$line;
}
-sub verify_contiguous {
- my ($name, $content, $what) = @_;
- my $sections = () = $content =~ m/\0+/g;
- croak("$0: $name contains no $what") if $sections < 1;
- croak("$0: $name contains discontiguous $what") if $sections > 1;
-}
-
sub do_manifest {
my ($name, $prev) = @_;
my @manifest =
- grep {! m!^pod/[^.]+\.pod.*!}
+ grep {! m!^pod/[^. \t]+\.pod.*!}
grep {! m!^README\.(\S+)! || $state->{ignore}{$1}} split "\n", $prev;
join "\n", (
# Dictionary order - fold and handle non-word chars as nothing
sub do_nmake {
my ($name, $makefile) = @_;
- $makefile =~ s/^\tcopy \.\.\\README.*\n/\0/gm;
- verify_contiguous($name, $makefile, 'README copies');
+ my $re = qr/^\tcopy \.\.\\README[^\n]*\n/sm;
+ $makefile = verify_contiguous($name, $makefile, $re, 'README copies');
# Now remove the other copies that follow
1 while $makefile =~ s/\0\tcopy .*\n/\0/gm;
$makefile =~ s/\0+/join ("", &generate_nmake_1)/se;
# shut up used only once warning
*do_dmake = *do_dmake = \&do_nmake;
-
-sub do_perlpod {
- my ($name, $pod) = @_;
-
- unless ($pod =~ s{(For\ ease\ of\ access,\ .*\n)
- (?:\s+[a-z]{4,}.*\n # fooo
- |=head.*\n # =head foo
- |\s*\n # blank line
- )+
- }
- {$1 . join "", &generate_perlpod}mxe) {
- my_die "Failed to insert amendments in do_perlpod";
- }
- $pod;
-}
+*do_gmake = *do_gmake = \&do_nmake;
sub do_podmak {
my ($name, $body) = @_;
# Looking for the macro defining the current perldelta:
#PERLDELTA_CURRENT = [.pod]perl5139delta.pod
- $makefile =~ s{\nPERLDELTA_CURRENT\s+=\s+\Q[.pod]perl\E\d+delta\.pod\n}
- {\0}sx;
- verify_contiguous($name, $makefile, 'current perldelta macro');
+ my $re = qr{\nPERLDELTA_CURRENT\s+=\s+\Q[.pod]perl\E\d+delta\.pod\n}smx;
+ $makefile
+ = verify_contiguous($name, $makefile, $re, 'current perldelta macro');
$makefile =~ s/\0+/join "\n", '', "PERLDELTA_CURRENT = [.pod]$state->{delta_target}", ''/se;
$makefile;
# pod/perl511delta.pod: pod/perldelta.pod
# cd pod && $(LNS) perldelta.pod perl511delta.pod
- $makefile_SH =~ s!(
+ # although it seems that HP-UX make gets confused, always tried to
+ # regenerate the symlink, and then the ln -s fails, as the target exists.
+
+ my $re = qr{(
pod/perl[a-z0-9_]+\.pod: pod/perl[a-z0-9_]+\.pod
+ \$\(RMS\) pod/perl[a-z0-9_]+\.pod
\$\(LNS\) perl[a-z0-9_]+\.pod pod/perl[a-z0-9_]+\.pod
-)+!\0!gm;
-
- verify_contiguous($name, $makefile_SH, 'copy rules');
+)+}sm;
+ $makefile_SH = verify_contiguous($name, $makefile_SH, $re, 'copy rules');
my @copy_rules = map "
pod/$_: pod/$state->{copies}{$_}
+ \$(RMS) pod/$_
\$(LNS) $state->{copies}{$_} pod/$_
", keys %{$state->{copies}};
}
# Do stuff
-while (my ($target, $name) = each %Build) {
- print "Now processing $name\n" if $Verbose;
-
- my $orig = slurp_or_die($name);
- my_die "$name contains NUL bytes" if $orig =~ /\0/;
-
- my $new = do {
- no strict 'refs';
- &{"do_$target"}($target, $orig);
- };
-
- if ($Test) {
- printf "%s %d # $name is up to date\n",
- $new eq $orig ? 'ok' : 'not ok',
- ++$test;
- next;
- } elsif ($new eq $orig) {
- print "Was not modified\n"
- if $Verbose;
- next;
- }
+process($_, $Build{$_}, main->can("do_$_"), $Test && ++$test, $Verbose)
+ foreach sort keys %Build;
- my $mode = (stat $name)[2] // my_die "Can't stat $name: $!";
- rename $name, "$name.old" or my_die "Can't rename $name to $name.old: $!";
-
- write_or_die($name, $new);
- chmod $mode & 0777, $name or my_die "can't chmod $mode $name: $!";
-}
-
-# Local variables:
-# cperl-indent-level: 4
-# indent-tabs-mode: nil
-# End:
-#
# ex: set ts=8 sts=4 sw=4 et: