Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 87 lines (72 sloc) 1.87 kb
94b63d3 @mnunberg Lots and lots of fixes
authored
1 package PLCB_ConfUtil;
2 use strict;
3 use warnings;
4 use Dir::Self;
2aec41c @mnunberg A whole bunch of changes, mainly build-related.. ugh
authored
5 use File::Spec;
6 use File::Path qw(rmtree);
7 use Data::Dumper;
8 use Config;
9
94b63d3 @mnunberg Lots and lots of fixes
authored
10 use lib __DIR__;
11
12 my $config = do 'PLCB_Config.pm';
13 if(!$config) {
14 warn("Couldn't find PLCB_Config.pm. Assuming defaults");
15 $config = {};
16 }
17
18 sub set_gcc_env {
2aec41c @mnunberg A whole bunch of changes, mainly build-related.. ugh
authored
19
94b63d3 @mnunberg Lots and lots of fixes
authored
20 }
21
22 sub get_gcc_linker_flags {
23 my $libpath = $config->{COUCHBASE_LIBRARY_PATH};
24 if($libpath) {
25 $libpath = "-L$libpath ";
26 } else {
27 $libpath = "";
28 }
29 $libpath .= '-lcouchbase -lcouchbase_libevent -lvbucket';
30 return $libpath;
31 }
32
33 sub get_include_dir {
34 my $dir = $config->{COUCHBASE_INCLUDE_PATH};
35 if($dir) {
36 return "-I$dir";
37 } else {
38 return "";
39 }
40 }
41
2aec41c @mnunberg A whole bunch of changes, mainly build-related.. ugh
authored
42 sub clean_cbc_sources {
43 my $dir_base = $config->{SRC_DIR};
9c6277d @mnunberg Fixed build scripts, changed absolute to relative time offsets
authored
44 while (my ($kname,$release) = each %$config) {
45 next unless $kname =~ /RELEASE/;
46 my ($libname,$version) = ($kname =~ /(LIB[^_]+)(.+)/);
47 $libname = lc($libname);
48 my $dir = "$libname-$release";
49 warn $dir;
2aec41c @mnunberg A whole bunch of changes, mainly build-related.. ugh
authored
50 $dir = File::Spec->catfile($dir_base, $dir);
51 rmtree($dir);
52 }
53 rmtree($config->{SRC_INST});
54 }
55
56 sub get_toplevel_dir {
57 $config->{SRC_DIR};
58 }
59
60 sub get_inst_dir {
61 $config->{SRC_INST};
62 }
63
64 my $TEMPFILE = File::Spec->catfile(__DIR__, "COMPILER_FLAGS");
65
66 sub write_tmpflags {
67 my ($cflags,$ldflags) = @_;
68 open my $fh, ">", $TEMPFILE or die "$TEMPFILE: $@";
69 my $h = {
70 CFLAGS => $cflags,
71 LDFLAGS => $ldflags
72 };
73 print $fh Dumper($h);
74 }
75
76 sub env_from_tmpflags {
77 my $confhash = do "$TEMPFILE";
78 $ENV{CFLAGS} .= ' ' . $confhash->{CFLAGS} . ' ' . $Config{ccflags};
22fe27c @mnunberg Cleaned up source tree, build process is now cleaner
authored
79 $ENV{CFLAGS} .= ' -I' . File::Spec->catfile(__DIR__, 'xs');
2aec41c @mnunberg A whole bunch of changes, mainly build-related.. ugh
authored
80 $ENV{LDFLAGS}= "";
81 # $ENV{LDFLAGS} .= ' ' . $confhash->{LDFLAGS};
82
83 # printf("CFLAGS: %s\nLDFLAGS=%s\n", $ENV{CFLAGS}, $ENV{LDFLAGS});
84 }
85
94b63d3 @mnunberg Lots and lots of fixes
authored
86 1;
Something went wrong with that request. Please try again.