Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v0.12_0
Fetching contributors…

Cannot retrieve contributors at this time

file 204 lines (167 sloc) 5.896 kb
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
#!/usr/bin/perl
use strict;
use warnings;

use ExtUtils::MakeMaker;
use Dir::Self;
use Getopt::Long;
use Config;
use File::Spec;
use Config;
use lib __DIR__;
use PLCB_ConfUtil;

GetOptions(
    'dynamic' => \my $UseDynamic,
    'include=s' => \my $ExtraInclude,
    'ldpath=s' => \my $ExtraLDPath,
);

my %MM_Options;
################################################################################
### Our C Source Files ###
################################################################################
{
    my @C_Modules = qw(
callbacks convert ctor async_base async_callbacks async_events);
    my @XS_Modules = qw(Client Client_multi);
    
    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;
    }
}

################################################################################
### These scripts generate constants ###
################################################################################
foreach ([qw(error Errors)], [qw(idx IDXConst)]) {
    my ($script,$genpm) = @$_;
    $script = "constants/$script" . "_constants.pl";
    $genpm = '$(INST_LIB)/Couchbase/Client/' . "$genpm" . "_const.pm";
    $MM_Options{PL_FILES}->{$script} = $genpm;
}

################################################################################
### Check dependencies ###
################################################################################
my $inc;
my $libs;

################################################################################
### Check build type and options ###
################################################################################
my $myextlib;

my $inst_dir = PLCB_ConfUtil::get_inst_dir();
my $inst_lib_dir = File::Spec->catfile($inst_dir, 'lib');
my $inst_inc_dir = File::Spec->catfile($inst_dir, 'include');

my $buildscript_options = "";

#my @extra_deps;
#foreach my $dep (['sasl2', 'sasl'], ['event', 'event']) {
# my ($installed,$new) = @$dep;
# print STDERR "Checking if $installed is present...";
# if(check_lib(lib => $installed,
# LIBS => $ExtraLDPath, INC => $ExtraInclude)) {
# print STDERR "OK\n";
# push @extra_deps, "-l$installed";
# } else {
# print STDERR "NOT FOUND (will build embedded)\n";
# push @extra_deps, File::Spec->catfile($inst_lib_dir,
# "lib".$new.$Config{lib_ext});
# $buildscript_options .= ' --build-'.$new;
# }
#}

if(!$UseDynamic) {
    $inc = '-I' . $inst_inc_dir;
    $libs = "-L$inst_lib_dir -lsasl2 -levent -ldl -lresolv";
    
    #Set path for linker and friends
    $myextlib = join(' ',
        map(File::Spec->catfile($inst_lib_dir, $_.'$(LIB_EXT)'),
            qw(libcouchbase libvbucket)));
} else {
    $myextlib = "";
    $libs = " -lcouchbase -lvbucket -lcouchbase_libevent";
}

{
    $inc .= " " . join(" ", map("-I$_", split(/\s+/, $Config{locincpth})));
    $libs .= " " . join(" ", map("-L$_", split(/\s+/, $Config{libpth})));
}

foreach ([\$inc, \$ExtraInclude], [\$libs, \$ExtraLDPath]) {
    my ($defl,$extra) = @$_;
    if($$extra) {
        $$defl ||= "";
        $$defl = "$$extra $$defl";
    }
}

$MM_Options{INC} = $inc;
$MM_Options{LIBS} = $libs;
$MM_Options{MYEXTLIB} = $myextlib;

#Write our temporary parameters
PLCB_ConfUtil::write_tmpflags($inc, $libs);



WriteMakefile(
    NAME => 'Couchbase::Client',
    AUTHOR => q{M. Nunberg <mnunberg@haskalah.org>},
    VERSION_FROM => 'lib/Couchbase/Client.pm',
    ABSTRACT_FROM => 'lib/Couchbase/Client.pm',
    
    ($ExtUtils::MakeMaker::VERSION >= 6.3002
      ? ('LICENSE'=> 'perl')
      : ()),
    
    CONFIGURE_REQUIRES => {
        'Dir::Self' => 0,
    },

    PREREQ_PM => {
        'Array::Assign' => 0,
        'ExtUtils::H2PM' => 0.08,
        'Class::XSAccessor' => 1.11,
        'Test::More' => 0,
        
        #We need libevent for whatever we're doing
        'Alien::Libevent' => 0.001004,
        
        #These modules are needed for tests, but not strictly required for
        #functionality
        
        'Log::Fu' => 0.25,
        'Test::Class' => 0.36,
        
        #these are needed for asynchronous tests and modules
        'POE::Sugar::Attributes' => 0.02,
        'POE' => 1.312,
    },

    NEEDS_LINKING => 1,
    OPTIMIZE =>
                ' -Wdeclaration-after-statement -Werror -std=gnu89',
                
    dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
    clean => { FILES => 'Couchbase-Client-* COMPILER_FLAGS' },
    %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;
}

sub libscan {
    my ($self,$path) = @_;
    if($path =~ /\.pl$/i) {
        return "";
    } else {
        return $path;
    }
}

sub postamble {
    return unless $myextlib;
    
    my $make_text = <<'EOM';
$(MYEXTLIB):
$(PERLRUN) build_libraries.pl __BUILD_LIBRARIES_OPTIONS__
EOM

    $make_text =~ s/__BUILD_LIBRARIES_OPTIONS__/$buildscript_options/g;
    $make_text =~ s/^\s+/\t/msg;
    $make_text;
}
Something went wrong with that request. Please try again.