1use strict; 2use warnings; 3 4use ExtUtils::MakeMaker; 5use Getopt::Long; 6 7eval "use ExtUtils::MakeMaker::Coverage"; 8$@ or print "Adding testcover target\n"; 9 10my @authors = reverse ( # reverse chronological order 11 'Gisle Aas', 12 'Joshua Chamas', 13 'David Landgren', 14 'A. Sinan Unur <nanis@cpan.org>', 15); 16 17my $mm_version = $ExtUtils::MakeMaker::VERSION; 18$mm_version =~ tr/_//d; 19 20my ($opt_static, $opt_live_tests); 21 22GetOptions( 23 'static', \$opt_static, 24 'live-tests!', \$opt_live_tests, 25); 26 27$opt_live_tests ||= $ENV{CRYPT_SSLEAY_LIVE_TEST_WANTED}; 28$opt_live_tests ||= is_live_test_wanted(); 29 30my $test_config = 'test.config'; 31 32WriteMakefile( 33 NAME => 'Crypt::SSLeay', 34 35 AUTHOR => $mm_version > 6.5701 ? \@authors : $authors[0], 36 37 ABSTRACT_FROM => 'SSLeay.pm', 38 39 VERSION_FROM => 'SSLeay.pm', 40 41 LIBS => [q{-lz -lssl -lcrypto -lssl32 -lssleay32 -leay32}], 42 43 ($opt_static ? (LINK_TYPE => 'static') : ()), 44 45 BUILD_REQUIRES => { 46 'Try::Tiny' => '0.09', 47 'Test::More' => '0.88', 48 }, 49 50 PREREQ_PM => { 51 'LWP::Protocol::https' => '6.02', 52 'MIME::Base64' => 0, # for Net::SSL 53 }, 54 55 clean => { 56 FILES => $test_config, 57 }, 58 59 ($mm_version > 6.3 ? (LICENSE => 'artistic_2') : ()), 60); 61 62write_test_config($test_config, {network_tests => $opt_live_tests}); 63 64sub is_live_test_wanted { 65 print <<EO_CHUNK; 66The test suite can attempt to connect to public servers to ensure that the 67code is working properly. If you are behind a strict firewall or have no 68network connectivity, these tests may fail (through no fault of the code). 69EO_CHUNK 70 my $wanted = prompt "Do you want to run the live tests (y/N)?", 'N'; 71 $wanted =~ s/\A\s+//; 72 $wanted =~ s/\s+\z//; 73 74 return $wanted =~ /\Ay(?:es)?\z/i ? 1 : 0; 75} 76 77sub write_test_config { 78 my ($file, $config) = @_; 79 80 open my $out, '>', $file 81 or die "Cannot open '$file' for writing: $!"; 82 83 for my $key (sort keys %$config) { 84 printf $out "%s\t%s\n", $key, $config->{$key}; 85 } 86 87 close $out 88 or die "Cannot close '$file': $!"; 89 90 return; 91} 92 93