summaryrefslogtreecommitdiff
path: root/cpan/IPC-SysV/regen.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-09-24 10:30:56 +0100
committerNicholas Clark <nick@ccl4.org>2009-09-24 10:30:56 +0100
commit5aacae8537a14b9d6238ea441c002451d7abea35 (patch)
treeceef13c1be4ac11d2e7a13ff0737d44cbe1c446c /cpan/IPC-SysV/regen.pl
parente14adb6005c86f724c57fce18f4514abf3c57041 (diff)
downloadperl-5aacae8537a14b9d6238ea441c002451d7abea35.tar.gz
Move IPC-SysV from ext/ to cpan/
(Also XS, skipped on Win32 and VMS)
Diffstat (limited to 'cpan/IPC-SysV/regen.pl')
-rw-r--r--cpan/IPC-SysV/regen.pl97
1 files changed, 97 insertions, 0 deletions
diff --git a/cpan/IPC-SysV/regen.pl b/cpan/IPC-SysV/regen.pl
new file mode 100644
index 0000000000..776991298f
--- /dev/null
+++ b/cpan/IPC-SysV/regen.pl
@@ -0,0 +1,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";
+}