forked from mnunberg/perl-Couchbase-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_libraries.pl
executable file
·112 lines (88 loc) · 2.73 KB
/
build_libraries.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
#!/usr/bin/perl
use strict;
use warnings;
use Cwd qw(getcwd);
use File::Basename qw(fileparse);
use Log::Fu;
use File::Spec;
use Dir::Self;
use Config;
use File::Path qw(mkpath);
use lib __DIR__;
use PLCB_ConfUtil;
require 'PLCB_Config.pm';
my $plcb_conf = do 'PLCB_Config.pm' or die "Cannot find configuration";
sub runcmd {
my $cmd = join(" ", @_);
system($cmd . " > /dev/null") == 0 or die "$cmd failed";
}
#Figure out various ways to get a tarball
my $LIBVBUCKET_TARBALL = $plcb_conf->{LIBVBUCKET_RELEASE};
my $LIBCOUCHBASE_TARBALL = $plcb_conf->{LIBCOUCHBASE_RELEASE};
unless ($LIBCOUCHBASE_TARBALL && $LIBVBUCKET_TARBALL) {
die("Cannot find appropriate tarball names. Please edit PLCB_Config.pm");
}
$LIBVBUCKET_TARBALL = "libvbucket-$LIBVBUCKET_TARBALL.tar.gz";
$LIBCOUCHBASE_TARBALL = "libcouchbase-$LIBCOUCHBASE_TARBALL.tar.gz";
my $MEMCACHED_H_TARBALL = "memcached-headers.tar.gz";
sub tarball_2_dir {
my $tarball = shift;
runcmd("tar xf $tarball");
my $filename = fileparse($tarball, qr/\.tar\..*/);
return $filename;
}
my $TOPLEVEL = PLCB_ConfUtil::get_toplevel_dir();
my $INST_DIR = PLCB_ConfUtil::get_inst_dir();
chdir $TOPLEVEL;
mkpath($INST_DIR);
log_info("We're in $TOPLEVEL now");
my @COMMON_OPTIONS = (
"--prefix=$INST_DIR",
qw(
--silent
--disable-shared
--enable-static
--without-docs)
);
runcmd("tar xf $MEMCACHED_H_TARBALL -C $INST_DIR");
$ENV{CPPFLAGS} .= ' -fPIC ';
#build libvbucket first:
{
chdir tarball_2_dir($LIBVBUCKET_TARBALL);
if(!-e 'Makefile') {
runcmd("./configure", @COMMON_OPTIONS);
log_info("Configured libvbucket");
}
runcmd("make");
log_info("build libvbucket");
runcmd("make install");
log_info("installed libvbucket");
runcmd("make check");
log_info("tested libvbucket");
}
{
chdir $TOPLEVEL;
chdir tarball_2_dir($LIBCOUCHBASE_TARBALL);
$ENV{CPPFLAGS} .= " -I".File::Spec->catfile($INST_DIR, "include");
$ENV{LDFLAGS} .= " -lm -L".File::Spec->catfile($INST_DIR, "lib");
log_info("CPPFLAGS:", $ENV{CPPFLAGS});
log_info("LDFLAS:", $ENV{LDFLAGS});
my @libcouchbase_options = (
@COMMON_OPTIONS,
"--disable-tools",
"--enable-embed-libevent-plugin",
);
my $have_java = eval { runcmd("java", "-version"); 1; };
my $mockpath = File::Spec->catfile(
__DIR__, 't', 'tmp', 'CouchbaseMock.jar');
if($have_java && -e $mockpath) {
push @libcouchbase_options, '--with-couchbase-mock='.$mockpath;
} else {
push @libcouchbase_options, '--disable-couchbasemock';
}
if(!-e 'Makefile') {
runcmd("./configure", @libcouchbase_options);
}
runcmd("make install check -s");
}
#Write a little file about where our stuff is located: