Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MakeMaker.pm: Allow the user to specify which OpenSSL and/or libssh2 to use #94

Merged
merged 2 commits into from
Apr 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
54 changes: 53 additions & 1 deletion inc/MakeMaker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 = '';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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=<path> Specify <path> for the root of the OpenSSL installation.
--with-openssl-libs=<libs> Specify <libs> for the OpenSSL libraries.
--with-libssh2-include=<path> Specify <path> for the root of the libssh2 installation.
--with-libssh2-lib=<lib> Specify <lib> for the libssh2 library.
USAGE

exit(1);
}

{{ $share_dir_block[1] }}
TEMPLATE

Expand Down
6 changes: 6 additions & 0 deletions t/10-clone.t
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down