This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove AT&T UWIN support
[perl5.git] / Porting / pod_rules.pl
index 11e2edf..d10c669 100644 (file)
@@ -1,11 +1,16 @@
 #!/usr/bin/perl -w
 
 use strict;
-use vars qw(%Build %Targets $Verbose $Test);
+our (%Build, %Targets, $Verbose, $Test);
 use Text::Tabs;
 use Text::Wrap;
 use Getopt::Long;
 
+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
 #
@@ -13,20 +18,20 @@ use Getopt::Long;
 # --build-all tries to build everything
 # --build-foo updates foo as follows
 # --showfiles shows the files to be changed
-# --test exit if perl.pod, MANIFEST are consistent, and regenerated
-#   files are up to date, die otherwise.
+# --tap emit TAP (testing) output describing the state of the pod files
 
 %Targets = (
             manifest => 'MANIFEST',
             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',
            );
 
-require 'Porting/pod_lib.pl';
+require './Porting/pod_lib.pl';
+require './Porting/manifest_lib.pl';
 sub my_die;
 
 # process command-line switches
@@ -57,7 +62,7 @@ sub my_die;
 }
 
 if ($Verbose) {
-    print "I will be building $_\n" foreach keys %Build;
+    print "I will be building $_\n" foreach sort keys %Build;
 }
 
 my $test = 1;
@@ -68,10 +73,10 @@ my $state = $Test
     ? 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);
 
@@ -134,14 +139,15 @@ sub do_manifest {
     my @manifest =
         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
-                map  { $_->[0] }
-                sort { $a->[1] cmp $b->[1] || $a->[0] cmp $b->[0] }
-                map  { my $f = lc $_; $f =~ s/[^a-z0-9\s]//g; [ $_, $f ] }
-                @manifest,
-                &generate_manifest_pod(),
-                &generate_manifest_readme()), '';
+    # NOTE - the sort code here is shared with Porting/manisort currently.
+    # If you change one, change the other. Or refactor them. :-)
+    join "\n",  sort_manifest(
+                    @manifest,
+                    &generate_manifest_pod(),
+                    &generate_manifest_readme()
+                ),
+                '', # elegant way to add a newline to the end
+    ;
 }
 
 sub do_nmake {
@@ -158,7 +164,7 @@ sub do_nmake {
 }
 
 # shut up used only once warning
-*do_dmake = *do_dmake = \&do_nmake;
+*do_gmake = *do_gmake = \&do_nmake;
 
 sub do_podmak {
     my ($name, $body) = @_;
@@ -217,38 +223,7 @@ pod/$_: pod/$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;
-    }
-
-    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: $!";
+process($_, $Build{$_}, main->can("do_$_"), $Test && ++$test, $Verbose)
+    foreach sort keys %Build;
 
-    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: