perl/regen.pl
<<
>>
Prefs
   1#!/usr/bin/perl -w
   2require 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
  11use strict;
  12my $perl = $^X;
  13
  14require 'regen_lib.pl';
  15# keep warnings.pl in sync with the CPAN distribution by not requiring core
  16# changes
  17safer_unlink ("warnings.h", "lib/warnings.pm");
  18
  19my %gen = (
  20           'autodoc.pl'  => [qw[pod/perlapi.pod pod/perlintern.pod]],
  21           'embed.pl'    => [qw[proto.h embed.h embedvar.h global.sym
  22                                perlapi.h perlapi.c]],
  23           'keywords.pl' => [qw[keywords.h]],
  24           'opcode.pl'   => [qw[opcode.h opnames.h pp_proto.h pp.sym]],
  25           'regcomp.pl'  => [qw[regnodes.h]],
  26           'warnings.pl' => [qw[warnings.h lib/warnings.pm]],
  27           'reentr.pl'   => [qw[reentr.c reentr.h]],
  28           'overload.pl' => [qw[overload.h]],
  29           );
  30
  31sub do_cksum {
  32    my $pl = shift;
  33    my %cksum;
  34    for my $f (@{ $gen{$pl} }) {
  35        local *FH;
  36        if (open(FH, $f)) {
  37            local $/;
  38            $cksum{$f} = unpack("%32C*", <FH>);
  39            close FH;
  40        } else {
  41            warn "$0: $f: $!\n";
  42        }
  43    }
  44    return %cksum;
  45}
  46
  47foreach my $pl (qw (keywords.pl opcode.pl embed.pl
  48                    regcomp.pl warnings.pl autodoc.pl reentr.pl)) {
  49  print "$^X $pl\n";
  50  my %cksum0;
  51  %cksum0 = do_cksum($pl) unless $pl eq 'warnings.pl'; # the files were removed
  52  system "$^X $pl";
  53  next if $pl eq 'warnings.pl'; # the files were removed
  54  my %cksum1 = do_cksum($pl);
  55  my @chg;
  56  for my $f (@{ $gen{$pl} }) {
  57      push(@chg, $f)
  58          if !defined($cksum0{$f}) ||
  59             !defined($cksum1{$f}) ||
  60             $cksum0{$f} ne $cksum1{$f};
  61  }
  62  print "Changed: @chg\n" if @chg;
  63}
  64
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.