1use ExtUtils::MakeMaker; 2use Config; 3 4my $arch = "$Config{'archname'}-$Config{'osvers'}"; 5my $got = ""; 6if (-e 'arch.txt') { 7 open my $in, "<", "arch.txt" or die "Can't read 'arch.txt': $!"; 8 $got = <$in>; 9 close $in; 10} 11if ($got ne $arch) { 12 if (-e "Errno.pm") { 13 print "Removing old 'Errno.pm'\n"; 14 unlink "Errno.pm" 15 or die "Failed to remove out of date 'Errno.pm': $!"; 16 } 17 open my $out, ">", "arch.txt" or die "Can't write 'arch.txt': $!"; 18 print $out $arch; 19 close $out; 20} 21 22WriteMakefile( 23 NAME => 'Errno', 24 VERSION_FROM => 'Errno_pm.PL', 25 PL_FILES => {'Errno_pm.PL'=>'Errno.pm'}, 26 PM => {'Errno.pm' => '$(INST_LIBDIR)/Errno.pm'}, 27 'clean' => {FILES => 'Errno.pm arch.txt'}, 28 'dist' => { 29 COMPRESS => 'gzip -9f', 30 SUFFIX => '.gz', 31 DIST_DEFAULT => 'd/Errno.pm tardist', 32 }, 33); 34 35sub MY::postamble { 36 my $TARG = MM->catfile('d','Errno.pm'); 37qq!$TARG : Makefile 38 echo '#This is a dummy file so CPAN will find a VERSION' > $TARG 39 echo 'package Errno;' >> $TARG 40 echo '\$\$VERSION = "\$(VERSION)";' >>$TARG 41 echo '#This is to make sure require will return an error' >>$TARG 42 echo '0;' >>$TARG 43 44! 45} 46