-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile.PL
118 lines (95 loc) · 3.15 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/perl
use strict;
use warnings;
use ExtUtils::MakeMaker;
use Getopt::Long;
use File::Spec;
use Config;
$ENV{LD_RUN_PATH} ||= "";
GetOptions(
'incpath=s' => \my $U_IncPath,
'libpath=s' => \my $U_LibPath) or die <<EOD;
OPTIONS:
--incpath=CPPFLAGS
--libpath=LDFLAGS
EOD
our (@LIBS, $INC);
push @LIBS, $U_LibPath if $U_LibPath;
$INC = $U_IncPath || "";
push @LIBS, '-lcouchbase';
my %MM_Options = (
INC => $INC,
LIBS => [ join(' ', @LIBS) || '' ],);
################################################################################
### Our C Source Files ###
################################################################################
my @C_Modules = qw(args async callbacks constants convert operations opcontext query);
my @XS_Modules = qw(Couchbase BucketConfig IO N1QLParams);
foreach (@XS_Modules, @C_Modules) {
my $obj = $_ . $Config{obj_ext};
push @{ $MM_Options{OBJECT} }, File::Spec->catfile('xs', $obj);
}
$MM_Options{OBJECT} = join(' ', @{ $MM_Options{OBJECT} });
foreach my $xs (@XS_Modules) {
$xs = File::Spec->catfile('xs', $xs);
my $c = "$xs.c";
$xs = "$xs.xs";
$MM_Options{XS}->{$xs} = $c;
}
################################################################################
### Check build type and options ###
################################################################################
if ($ENV{PLCB_BUILD_AUTHOR}) {
$MM_Options{OPTIMIZE} = '-Wdeclaration-after-statement -Werror -std=gnu89';
}
# Extra stuff - add compiler flags here
# $MM_Options{OPTIMIZE} .= ' -Wall';
$MM_Options{NEEDS_LINKING} = 1;
$MM_Options{META_MERGE} = { resources => { repository => 'https://github.com/mnunberg/perl-Couchbase-Client' } };
if (!-f 'Changes') {
# eek
system("git log > Changes");
}
# some MakeMaker versions have underscores, like 6.55_02
my ($makemaker_version) = $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/;
WriteMakefile(
NAME => 'Couchbase',
AUTHOR => q{M. Nunberg <[email protected]>},
ABSTRACT_FROM => 'lib/Couchbase.pm',
VERSION_FROM => 'lib/Couchbase/Core.pm',
LICENSE => 'perl_5',
PREREQ_PM => {
'Class::XSAccessor' => 1.11,
'JSON' => '0',
'URI' => '0',
'Constant::Generate'=> '0.16'
},
!$makemaker_version || $makemaker_version >= 6.64
? ( TEST_REQUIRES => {
#These modules are needed for tests, but not strictly required for
#functionality
'Test::More' => 0,
'Test::Class' => 0.36,
'Log::Fu' => 0,
'Dir::Self' => 0
})
: (),
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Couchbase-* COMPILER_FLAGS log.test-*' },
%MM_Options,);
package MY;
use Config;
use strict;
use warnings;
#thanks rafl!
sub const_cccmd {
my $ret = shift->SUPER::const_cccmd(@_);
return q{} unless $ret;
if ($Config{cc} =~ /^cl\b/i) {
warn 'you are using MSVC... my condolences.';
$ret .= ' /Fo$@';
} else {
$ret .= ' -o $@';
}
return $ret;
}