This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
[perl5.git] / regen.pl
1 #!/usr/bin/perl -w
2 require 5.003;  # keep this compatible, an old perl is all we may have before
3                 # we build the new one
4
5 # The idea is to move the regen_headers target out of the Makefile so that
6 # it is possible to rebuild the headers before the Makefile is available.
7 # (and the Makefile is unavailable until after Configure is run, and we may
8 # wish to make a clean source tree but with current headers without running
9 # anything else.
10
11 use strict;
12 my $perl = $^X;
13
14 require 'regen_lib.pl';
15 # keep warnings.pl in sync with the CPAN distribution by not requiring core
16 # changes
17 safer_unlink ("warnings.h", "lib/warnings.pm");
18
19 my %gen = (
20            'autodoc.pl'  => [qw[pod/perlapi.pod pod/perlintern.pod]],
21            'bytecode.pl' => [qw[ext/ByteLoader/byterun.h
22                                 ext/ByteLoader/byterun.c
23                                 ext/B/B/Asmdata.pm]],
24            'embed.pl'    => [qw[proto.h embed.h embedvar.h global.sym
25                                 perlapi.h perlapi.c]],
26            'keywords.pl' => [qw[keywords.h]],
27            'opcode.pl'   => [qw[opcode.h opnames.h pp_proto.h pp.sym]],
28            'regcomp.pl'  => [qw[regnodes.h]],
29            'warnings.pl' => [qw[warnings.h lib/warnings.pm]],
30            'reentr.pl'   => [qw[reentr.c reentr.h]],
31            'overload.pl' => [qw[overload.h]],
32            );
33
34 sub do_cksum {
35     my $pl = shift;
36     my %cksum;
37     for my $f (@{ $gen{$pl} }) {
38         local *FH;
39         if (open(FH, $f)) {
40             local $/;
41             $cksum{$f} = unpack("%32C*", <FH>);
42             close FH;
43         } else {
44             warn "$0: $f: $!\n";
45         }
46     }
47     return %cksum;
48 }
49
50 foreach my $pl (qw (keywords.pl opcode.pl embed.pl bytecode.pl
51                     regcomp.pl warnings.pl autodoc.pl reentr.pl)) {
52   print "$^X $pl\n";
53   my %cksum0;
54   %cksum0 = do_cksum($pl) unless $pl eq 'warnings.pl'; # the files were removed
55   system "$^X $pl";
56   next if $pl eq 'warnings.pl'; # the files were removed
57   my %cksum1 = do_cksum($pl);
58   my @chg;
59   for my $f (@{ $gen{$pl} }) {
60       push(@chg, $f)
61           if !defined($cksum0{$f}) ||
62              !defined($cksum1{$f}) ||
63              $cksum0{$f} ne $cksum1{$f};
64   }
65   print "Changed: @chg\n" if @chg;
66 }