Commit | Line | Data |
---|---|---|
36bb303b | 1 | #!/usr/bin/perl -w |
9ad884cb JH |
2 | require 5.003; # keep this compatible, an old perl is all we may have before |
3 | # we build the new one | |
36bb303b | 4 | |
9ad884cb JH |
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. | |
36bb303b | 10 | |
9ad884cb JH |
11 | use strict; |
12 | my $perl = $^X; | |
36bb303b | 13 | |
9ad884cb | 14 | # keep warnings.pl in sync with the CPAN distribution by not requiring core |
b6b9a099 JC |
15 | # changes. Um, what ? |
16 | # safer_unlink ("warnings.h", "lib/warnings.pm"); | |
36bb303b | 17 | |
9ad884cb JH |
18 | my %gen = ( |
19 | 'autodoc.pl' => [qw[pod/perlapi.pod pod/perlintern.pod]], | |
9ad884cb JH |
20 | 'embed.pl' => [qw[proto.h embed.h embedvar.h global.sym |
21 | perlapi.h perlapi.c]], | |
22 | 'keywords.pl' => [qw[keywords.h]], | |
23 | 'opcode.pl' => [qw[opcode.h opnames.h pp_proto.h pp.sym]], | |
24 | 'regcomp.pl' => [qw[regnodes.h]], | |
0bfd2b7f | 25 | 'warnings.pl' => [qw[warnings.h lib/warnings.pm]], |
8c798f87 | 26 | 'reentr.pl' => [qw[reentr.c reentr.h]], |
cd387eed | 27 | 'overload.pl' => [qw[overload.c overload.h]], |
9ad884cb | 28 | ); |
36bb303b | 29 | |
9ad884cb JH |
30 | sub do_cksum { |
31 | my $pl = shift; | |
32 | my %cksum; | |
33 | for my $f (@{ $gen{$pl} }) { | |
34 | local *FH; | |
35 | if (open(FH, $f)) { | |
36 | local $/; | |
37 | $cksum{$f} = unpack("%32C*", <FH>); | |
38 | close FH; | |
39 | } else { | |
40 | warn "$0: $f: $!\n"; | |
41 | } | |
42 | } | |
43 | return %cksum; | |
36bb303b NC |
44 | } |
45 | ||
cd387eed | 46 | foreach my $pl (keys %gen) { |
95aa0565 RB |
47 | my @command = ($^X, $pl, @ARGV); |
48 | print "@command\n"; | |
9ad884cb JH |
49 | my %cksum0; |
50 | %cksum0 = do_cksum($pl) unless $pl eq 'warnings.pl'; # the files were removed | |
95aa0565 | 51 | system @command; |
9ad884cb JH |
52 | next if $pl eq 'warnings.pl'; # the files were removed |
53 | my %cksum1 = do_cksum($pl); | |
54 | my @chg; | |
55 | for my $f (@{ $gen{$pl} }) { | |
56 | push(@chg, $f) | |
57 | if !defined($cksum0{$f}) || | |
58 | !defined($cksum1{$f}) || | |
59 | $cksum0{$f} ne $cksum1{$f}; | |
60 | } | |
61 | print "Changed: @chg\n" if @chg; | |
36bb303b | 62 | } |