blob: 776991298fc6d7986a8693f1f3ad7529909d00f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
use strict;
unless (@ARGV) {
@ARGV = qw( constants );
}
my %gen = map { ($_ => 1) } @ARGV;
if (delete $gen{constants}) {
make_constants();
}
for my $key (keys %gen) {
print STDERR "Invalid request to regenerate $key!\n";
}
sub make_constants
{
unless (eval { require ExtUtils::Constant; 1 }) {
my @files = qw( const-c.inc const-xs.inc );
die "Cannot regenerate constants:\n$@\n" if grep { !-f } @files;
my @deps = qw( regen.pl lib/IPC/SysV.pm );
my $oldage = (sort { $a <=> $b } map { -M } @files)[-1]; # age of oldest file
my $depage = (sort { $a <=> $b } map { -M } @deps)[0]; # age of newest dependency
my @outdated = grep { (-M) > $depage } @files;
my @newdeps = grep { (-M) < $oldage } @deps;
print STDERR <<EOM;
***********************************************************************
The following files seem to be out of date:
@outdated
The reason is probably that you modified these files:
@newdeps
If you're absolutely sure you didn't touch the files, please ignore
this message.
Otherwise, please install the ExtUtils::Constant module.
***********************************************************************
EOM
exit 0; # will build anyway, since the files exist
}
my $source = 'lib/IPC/SysV.pm';
local $_;
local *SYSV;
open SYSV, $source or die "$source: $!\n";
my $parse = 0;
my @const;
while (<SYSV>) {
if ($parse) {
if (/^\)/) { $parse++; last }
push @const, split;
}
/^\@EXPORT_OK\s*=/ and $parse++;
}
close SYSV;
die "couldn't parse $source" if $parse != 2;
eval {
ExtUtils::Constant::WriteConstants(
NAME => 'IPC::SysV',
NAMES => \@const,
XS_FILE => 'const-xs.inc',
C_FILE => 'const-c.inc',
XS_SUBNAME => '_constant',
);
};
if ($@) {
my $err = "Cannot regenerate constants:\n$@\n";
if ($[ < 5.006) {
print STDERR $err;
exit 0;
}
die $err;
}
print "Writing const-xs.inc\n";
print "Writing const-c.inc\n";
}
|