# $Id: Makefile.PL,v 2.12 2001/05/21 17:38:01 ams Exp $ # Copyright 2001 Abhijit Menon-Sen use Config; use File::Spec; use ExtUtils::MakeMaker; ($stdint = <<"TEST") =~ s/^\| {0,3}//gm; | #include | int main(void) { | printf("%d%d", sizeof(uint16_t), sizeof(uint32_t)); | return 0; | } TEST ($inttypes = $stdint) =~ s/stdint/inttypes/; print "Searching for uint*_t... "; if (ftest($inttypes) eq "24") { print "inttypes.h"; $def = "#include "; } elsif (ftest($stdint) eq "24") { print "stdint.h"; $def = "#include "; } else { print "no"; foreach (qw(short int long)) { my $size = $Config{"${_}size"}; $sixteen ||= "unsigned $_" if ($size == 2); $thirtytwo ||= "unsigned $_" if ($size == 4); } $def = "typedef $sixteen uint16_t;\ntypedef $thirtytwo uint32_t;"; } print "\n"; ($text = <<"PLATFORM") =~ s/^\| {0,3}//gm; | /* Automatically generated by "perl Makefile.PL" */ | | #ifndef _PLATFORM_H_ | #define _PLATFORM_H_ | | $def | | #endif PLATFORM open(F, ">platform.h") || die "platform.h: $!\n"; print F $text; close F; sub MY::postamble { "tables.h: tab/tables.pl\n\tperl tab/tables.pl\n" } WriteMakefile( NAME => 'Crypt::Twofish', OBJECT => 'Twofish.o _twofish.o', VERSION_FROM => 'Twofish.pm', ABSTRACT_FROM => 'Twofish.pm', depend => { '_twofish.c' => 'tables.h' } ); # Compile and run a program to test for a particular feature. sub ftest { my $null = File::Spec->devnull; my $result = 0; open(F, ">ftest.c") || die "ftest.c: $!\n"; print F $_[0]; close F; unlink("ftest"); open OLDERR, ">&STDERR" || die; open OLDOUT, ">&STDOUT" || die; open STDOUT, ">$null" || die; open STDERR, ">$null" || die; if (system("$Config{cc} $Config{ccflags} -o ftest ftest.c") == 0) { open STDOUT, ">&OLDOUT" || die; open (F, "./ftest |") && do { local $/; $result = ; }; } open STDERR, ">&OLDERR" || die; open STDOUT, ">&OLDOUT" || die; unlink("ftest", "ftest.c"); return $result; }