# $Id: Makefile.PL 1061 2012-12-03 14:43:09Z willem $ -*-perl-*- use strict; $^W = 1; use ExtUtils::MakeMaker qw(WriteMakefile prompt); use IO::Socket (); use Config qw(%Config); use Getopt::Long qw(GetOptions); sub DEBUG { 0; } # An existing makefile can confuse the CC test. unlink('Makefile'); # clean up the online testing flag file. unlink("t/online.enabled"); unlink("t/online.disabled"); # clean up the IPv6 testing flag file. unlink("t/IPv6.enabled"); unlink("t/IPv6.disabled"); warn < \$use_xs, 'pm' => sub { warn qq/\n\tWARNING: Use of "--pm" is deprecated. Use "--noxs" instead.\n\n/; $use_xs = 0; }, 'online-tests!' => \$online_tests, 'non-fatal-online-tests' => sub { $online_tests = 2; }, 'IPv6-tests!' => \$IPv6_tests, 'help|?' => \$help, ); push @options, ( 'iphelper!' => \$iphelper ) if ( $^O eq 'cygwin' ); unless ( GetOptions(@options) ) { print "Error: Unrecognized option.\n"; print "Try perl Makefile.PL --help for more information\n"; exit 1; } if ($help) { print < 'Net::DNS', VERSION_FROM => 'lib/Net/DNS.pm', ABSTRACT => 'Perl DNS resolver module', AUTHOR => 'Olaf Kolkman ', LICENSE => 'perl', PREREQ_PM => { 'Test::More' => 0.18, 'IO::Socket' => 0, 'MIME::Base64' => 2.11, 'Digest::MD5' => 2.12, 'Digest::SHA' => 5.23, 'Digest::HMAC_MD5' => 1.00, }, XS => {}, C => [], clean => { FILES => 't/IPv6.enabled t/online.enabled t/online.nonfatal compile.* DNS.o DNS.c DNS.bs lib/Net/DNS/Resolver/MSWin32 zone[0-9].txt zone[0-9][0-9].txt' }, ); if ( $^O eq 'MSWin32' || $^O eq "cygwin" && $iphelper ) { unless (eval { local $SIG{__WARN__} = sub { }; require WIN32::API; } ) { warn <{'enum'} = 1.0; # Dependency for Win32::IPHelper $Makefile{'PREREQ_PM'}->{'Win32::IPHelper'} = 0.07; $Makefile{'PREREQ_PM'}->{'Win32::API'} = 0.55; $Makefile{'PREREQ_PM'}->{'Win32::TieRegistry'} = 0; } # # Check if we have a C compiler unless ( defined $use_xs ) { if ( test_cc() ) { print "You have a working compiler.\n"; $use_xs = 1; $Makefile{'MYEXTLIB'} = 'netdns$(LIB_EXT)'; } else { $use_xs = 0; $Makefile{'MYEXTLIB'} = ''; print <new( PeerAddr => "www.google.com:80", Timeout => 10, ); unless ($s) { $online_tests = 0; print <t/online.enabled" ) || die "Can't touch ./t/online.enabled $!"; close(ENABLED) || die "Can't touch ./t/online.enabled $!"; if ( $online_tests == 2 ) { open( NONFATAL, ">t/online.nonfatal" ) || die "Can't touch ./t/online.nonfatal $!"; close(NONFATAL) || die "Can't touch ./t/online.nonfatal $!"; } } # # Test to see if IPv6 is available, unless IPv6 testing has been declined. # if ( !defined $IPv6_tests || $IPv6_tests == 1 ) { unless ( eval { require IO::Socket::INET6; IO::Socket::INET6->VERSION("2.01"); } ) { print <t/IPv6.enabled' ) || die "Can't touch ./t/IPv6.enabled $!"; close(ENABLED) || die "Can't touch ./t/IPv6.enabled $!"; } } WriteMakefile(%Makefile); sub test_cc { # # The perl/C checking voodoo is stolen from Graham Barr's # Scalar-List-Utils distribution. # print "Testing if you have a C compiler and the needed header files....\n"; unless ( open( F, ">compile.c" ) ) { warn "Cannot write compile.c, skipping test compilation and installing pure Perl version.\n"; return; } print F <<'EOF'; #include "netdns.h" int main() { return 0; } EOF close(F) or return; my $ret = system("$Config{'cc'} -c compile.c -o compile$Config{obj_ext}"); my $ar = exists $Config{'full_ar'} ? $Config{'full_ar'} : $Config{'ar'}; my $cr = ( $^O eq 'MSWin32' && $Config{'cc'} eq 'cl' ? '/OUT:' : 'cr ' ); # ar action $ret = system( "$ar $cr compile$Config{lib_ext} compile$Config{obj_ext}" ) unless $ret; foreach my $file ( glob('compile*') ) { unlink($file) || warn "Could not delete $file: $!\n"; } return ( $ret == 0 ); } package MY; use Config qw(%Config); sub postamble { my $cr = ( $^O eq 'MSWin32' && $Config{'cc'} eq 'cl' ? '/OUT:' : 'cr ' ); # ar action my $content = ' test_cover : pure_all cover -delete HARNESS_PERL_SWITCHES=-MDevel::Cover $(MAKE) test cover netdns$(LIB_EXT): netdns$(OBJ_EXT) $(FULL_AR) ' . $cr . '$@ netdns$(OBJ_EXT) $(RANLIB) $@ '; return $content; } sub MY::libscan { my $path = $_[1]; return '' if $path =~ /\B\.svn\b/; return '' if $^O eq 'cygwin' && !$iphelper && $path =~ /Resolver[^\w]MSWin32\.pm$/; return $path; }