From 36f40cbd879fb773c3e7fb8a04f80741c67dab74 Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Mon, 28 Apr 2014 16:44:49 +0200 Subject: [PATCH 1/2] MakeMaker.pm: Allow the user to specify which OpenSSL and/or libssh2 to use --- dist.ini | 4 +++- inc/MakeMaker.pm | 54 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/dist.ini b/dist.ini index 95cdfa94..a543d0ed 100644 --- a/dist.ini +++ b/dist.ini @@ -9,7 +9,9 @@ repo = p5-Git-Raw makemaker = 0 [Prereqs / ConfigureRequires] -Devel::CheckLib = 0 +Devel::CheckLib = 0.6 +File::Basename = 2.74 +Getopt::Long = 2.35 ExtUtils::MakeMaker = 6.63_03 [=inc::MakeMaker / MakeMaker] diff --git a/inc/MakeMaker.pm b/inc/MakeMaker.pm index 67271d45..326e1395 100644 --- a/inc/MakeMaker.pm +++ b/inc/MakeMaker.pm @@ -12,6 +12,8 @@ override _build_MakeFile_PL_template => sub { use strict; use warnings; use Config; +use Getopt::Long; +use File::Basename qw(basename dirname); use Devel::CheckLib; @@ -26,6 +28,17 @@ my $is_windows = ($^O =~ /MSWin32/i) ? 1 : 0; my $is_linux = ($^O =~ /linux/i) ? 1 : 0; my $is_osx = ($^O =~ /darwin/i) ? 1 : 0; +# allow the user to override/specify the locations of OpenSSL and libssh2 +our $opt = {}; + +Getopt::Long::GetOptions( + "help" => \&usage, + 'with-openssl-include=s' => \$opt->{'ssl'}->{'incdir'}, + 'with-openssl-libs=s@' => \$opt->{'ssl'}->{'libs'}, + 'with-libssh2-include=s' => \$opt->{'ssh2'}->{'incdir'}, + 'with-libssh2-lib=s@' => \$opt->{'ssh2'}->{'libs'}, +) || die &usage(); + my $def = ''; my $lib = ''; my $inc = ''; @@ -81,7 +94,30 @@ my %library_opts = ( # check for optional libraries while (my ($library, $test) = each %library_tests) { - if (check_lib(%$test)) { + my $user_library_opt = $opt->{$library}; + my $user_incpath = $user_library_opt->{'incdir'}; + my $user_libs = $user_library_opt->{'libs'}; + + if ($user_incpath && $user_libs) { + $inc .= " -I$user_incpath"; + + # perform some magic + foreach my $user_lib (@$user_libs) { + my ($link_dir, $link_lib) = (dirname($user_lib), basename($user_lib)); + + if (!$is_msvc) { + my @tokens = grep { $_ } split(/(lib|.)/, $link_lib); + shift @tokens if ($tokens[0] eq 'lib'); + $link_lib = shift @tokens; + } + $lib .= " -L$link_dir -l$link_lib"; + } + + my $opts = $library_opts{$library}; + $def .= $opts->{'defines'}; + + print uc($library), " support enabled (user provided)", "\n"; + } elsif (check_lib(%$test)) { if (exists($test->{'incpath'})) { if (my $incpath = $test->{'incpath'}) { $inc .= ' -I'.join (' -I', @$incpath); @@ -234,6 +270,22 @@ delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker -> VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); +exit(0); + +sub usage { + print STDERR << "USAGE"; +Usage: perl $0 [options] + +Possible options are: + --with-openssl-include= Specify for the root of the OpenSSL installation. + --with-openssl-libs= Specify for the OpenSSL libraries. + --with-libssh2-include= Specify for the root of the libssh2 installation. + --with-libssh2-lib= Specify for the libssh2 library. +USAGE + + exit(1); +} + {{ $share_dir_block[1] }} TEMPLATE From e0feaa2e2f25bc99d127b8d22071d5baa6b92622 Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Mon, 28 Apr 2014 17:23:11 +0200 Subject: [PATCH 2/2] 10-clone.t: skip SSH clone tests on Windows, it doesn't have an SSH server --- t/10-clone.t | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/10-clone.t b/t/10-clone.t index 3e9dcf50..e19bddf9 100644 --- a/t/10-clone.t +++ b/t/10-clone.t @@ -151,6 +151,12 @@ rmtree abs_path('t/test_repo_clone_callbacks'); rmtree abs_path('t/test_repo_disable_checkout'); rmtree abs_path('t/test_repo_remote_name'); +if ($^O eq 'MSWin32') { + diag("Windows doesn't have a SSH server, skipping SSH clone tests"); + done_testing; + exit; +} + my $remote_path = File::Spec -> rel2abs('t/test_repo'); my $remote_url = "ssh://$ENV{USER}\@localhost$remote_path"; $path = File::Spec -> rel2abs('t/test_repo_ssh');