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 d46061a..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
@@ -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) = @_;
@@ -216,42 +222,8 @@ pod/$_: pod/$state->{copies}{$_}
     $makefile_SH;
 }
 
-sub process {
-    my ($desc, $filename, $callback, $test, $verbose) = @_;
-
-    print "Now processing $filename\n" if $verbose;
-    my $orig = slurp_or_die($filename);
-    my_die "$filename contains NUL bytes" if $orig =~ /\0/;
-
-    my $new = $callback->($desc, $orig);
-
-    if (defined $test) {
-        printf "%s%s # $filename is up to date\n",
-            ($new eq $orig ? 'ok' : 'not ok'), ($test ? " $test" : '');
-        return;
-    } elsif ($new eq $orig) {
-        print "Was not modified\n"
-            if $verbose;
-        return;
-    }
-
-    my $mode = (stat $filename)[2];
-    my_die "Can't stat $filename: $!"
-        unless defined $mode;
-    rename $filename, "$filename.old"
-        or my_die "Can't rename $filename to $filename.old: $!";
-
-    write_or_die($filename, $new);
-    chmod $mode & 0777, $filename or my_die "can't chmod $mode $filename: $!";
-}
-
 # Do stuff
 process($_, $Build{$_}, main->can("do_$_"), $Test && ++$test, $Verbose)
     foreach sort keys %Build;
 
-# Local variables:
-# cperl-indent-level: 4
-# indent-tabs-mode: nil
-# End:
-#
 # ex: set ts=8 sts=4 sw=4 et: