-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile.PL
102 lines (82 loc) · 2.59 KB
/
Makefile.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use strict;
use warnings;
use ExtUtils::MakeMaker;
use ExtUtils::CBuilder;
use Getopt::Std;
use Config;
my $aliensodium_version = '1.0.8.0';
my %opts;
getopt('L:I:', \%opts) or die usage();
my @defines;
my @dirs;
my $include_dirs;
if ( $opts{L} && $opts{I} ) {
@dirs = $opts{L};
$include_dirs = "-I$opts{I}";
die "Could not locate sodium.h in $opts{I}\n"
unless -e "$opts{I}/sodium.h";
} else {
require Alien::Sodium;
require File::Spec;
require File::ShareDir;
require Text::ParseWords;
my $libsodium = Alien::Sodium->new;
$include_dirs = $libsodium->cflags;
@dirs = map { s/^-L//g; $_ } grep { /^-L/ } Text::ParseWords::shellwords($libsodium->libs);
# NOTE: since Alien::Sodium v1.0.3.1 it may not be needed anymore
push @dirs, File::Spec->catdir( File::ShareDir::dist_dir("Alien-Sodium"), 'lib' );
# NOTE: some smokers still cannot find libsodium.a, but don't add it yet, as
# the updated Alien::Base could have fixed that
# push @dirs, map { "$_/.libs/" } grep { /_alien/ } @dirs;
}
my $lib_ext = $Config{lib_ext};
my $libsodium_lib = "libsodium${lib_ext}";
my $libsodium_path;
for my $dir ( @dirs ) {
if ( -e "$dir/$libsodium_lib" ) {
$libsodium_path = "$dir/$libsodium_lib";
last;
}
}
die "Is Alien::Sodium available? Could not locate $libsodium_lib in @dirs\n"
unless $libsodium_path;
WriteMakefile(
ABSTRACT_FROM => 'lib/Crypt/Sodium/Nitrate.pm', # retrieve abstract from module
AUTHOR => [
"Brian Fraser (brian.fraser at booking.com)",
"Gonzalo Diethelm (gonzalo.diethelm at booking.com)",
],
CONFIGURE_REQUIRES => {
"File::ShareDir" => 0,
"File::Spec" => 0,
"Alien::Sodium" => $aliensodium_version,
"Alien::Base::ModuleBuild" => 0,
"ExtUtils::MakeMaker" => 0,
},
DISTNAME => "Crypt-Sodium-Nitrate",
DEFINE => join(" ", map { "-D$_" } @defines),
EXE_FILES => [],
MYEXTLIB => $libsodium_path,
INC => join(' ', "-I.", $include_dirs),
LICENSE => "perl",
NAME => "Crypt::Sodium::Nitrate",
PREREQ_PM => {
"Alien::Sodium" => $aliensodium_version,
"Carp" => 0,
"XSLoader" => 0,
"strict" => 0,
"warnings" => 0
},
TEST_REQUIRES => {
"Test::More" => 0,
"Test::Exception" => 0,
},
VERSION_FROM => 'lib/Crypt/Sodium/Nitrate.pm',
test => {
"TESTS" => "t/*.t"
}
);
sub usage {
return "Example usage:\n"
."\tperl $0 -L /usr/lib/x86_64-linux-gnu/ -I /usr/include/\n"
}