forked from mnunberg/perl-Couchbase-Client
/
PLCB_ConfUtil.pm
84 lines (69 loc) · 1.72 KB
/
PLCB_ConfUtil.pm
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
package PLCB_ConfUtil;
use strict;
use warnings;
use Dir::Self;
use File::Spec;
use File::Path qw(rmtree);
use Data::Dumper;
use Config;
use lib __DIR__;
my $config = do 'PLCB_Config.pm';
if(!$config) {
warn("Couldn't find PLCB_Config.pm. Assuming defaults");
$config = {};
}
sub set_gcc_env {
}
sub get_gcc_linker_flags {
my $libpath = $config->{COUCHBASE_LIBRARY_PATH};
if($libpath) {
$libpath = "-L$libpath ";
} else {
$libpath = "";
}
$libpath .= '-lcouchbase -lcouchbase_libevent -lvbucket';
return $libpath;
}
sub get_include_dir {
my $dir = $config->{COUCHBASE_INCLUDE_PATH};
if($dir) {
return "-I$dir";
} else {
return "";
}
}
sub clean_cbc_sources {
my $dir_base = $config->{SRC_DIR};
foreach my $lib (qw(couchbase vbucket)) {
my $dir = sprintf("lib%s-%s", $lib,
$config->{ "LIB" . uc($lib) . "_RELEASE" });
$dir = File::Spec->catfile($dir_base, $dir);
rmtree($dir);
}
rmtree($config->{SRC_INST});
}
sub get_toplevel_dir {
$config->{SRC_DIR};
}
sub get_inst_dir {
$config->{SRC_INST};
}
my $TEMPFILE = File::Spec->catfile(__DIR__, "COMPILER_FLAGS");
sub write_tmpflags {
my ($cflags,$ldflags) = @_;
open my $fh, ">", $TEMPFILE or die "$TEMPFILE: $@";
my $h = {
CFLAGS => $cflags,
LDFLAGS => $ldflags
};
print $fh Dumper($h);
}
sub env_from_tmpflags {
my $confhash = do "$TEMPFILE";
$ENV{CFLAGS} .= ' ' . $confhash->{CFLAGS} . ' ' . $Config{ccflags};
$ENV{CFLAGS} .= ' -I' . __DIR__;
$ENV{LDFLAGS}= "";
# $ENV{LDFLAGS} .= ' ' . $confhash->{LDFLAGS};
# printf("CFLAGS: %s\nLDFLAGS=%s\n", $ENV{CFLAGS}, $ENV{LDFLAGS});
}
1;