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
|
@conf_vars=qw( CXXFLAGS LDFLAGS LIBS );
sub allowed_options {
my ($allowed_options, $allowed_with)=@_;
# @$allowed_options{ qw( ACTION ) }=();
@$allowed_with{ qw( mongoc mongoc-include mongoc-lib bson-include bson-lib ) }=();
}
sub usage {
print STDERR " --with-mongoc=PATH installation path of mongoc and bson libraries, if non-standard\n",
" --with-mongoc-include=PATH include path of mongoc library\n",
" --with-mongoc-lib=PATH path with mongoc library\n",
" --with-bson-include=PATH include path of bson library\n",
" --with-bson-lib=PATH path with bson library\n",
}
sub proceed {
my ($options)=@_;
my $path;
my $lmc1 = "libmongoc-1.0";
my $lb1 = "libbson-1.0";
my $usedopts = 0;
$CXXFLAGS = "-Wno-shadow ";
if (defined($path = $options->{mongoc})){
$usedopts++;
if (-d "$path/include/$lmc1" && -d "$path/include/$lb1") {
$CXXFLAGS = "-I$path/include/$lmc1";
$CXXFLAGS .= " -I$path/include/$lb1";
if ($path ne "/usr") {
my $libpath=Polymake::Configure::get_libdir($path, "mongoc-1.0");
$LDFLAGS = "-L$libpath -Wl,-rpath,$libpath";
}
} else {
# make sure we fail the main configure here instead of just disabling
# the interface
$options->{polydb} = "";
die <<"---";
libmongoc or libbson headers not found in $path/include. Make sure
$path/include/$lmc1
$path/include/$lb1
are valid.
---
}
} else {
if (defined($path = $options->{"mongoc-include"})){
$usedopts++;
$path .= "/$lmc1" if -d "$path/$lmc1";
$CXXFLAGS .= " -I$path";
}
if (defined($path = $options->{"bson-include"})){
$usedopts++;
$path .= "/$lb1" if -d "$path/$lb1";
$CXXFLAGS .= " -I$path";
}
if (defined($path = $options->{"mongoc-lib"})){
$usedopts++;
$LDFLAGS .= " -L$path";
if ($path ne "/usr") {
$LDFLAGS .= " -Wl,-rpath,$path";
}
}
if (defined($path = $options->{"bson-lib"})){
$usedopts++;
$LDFLAGS .= " -L$path";
if ($path ne "/usr") {
$LDFLAGS .= " -Wl,-rpath,$path";
}
}
}
$LIBS = "-lmongoc-1.0 -lbson-1.0";
my @ver = (1,16,0);
my $testcode = <<"---";
#include <mongoc/mongoc.h>
#include <bson/bson.h>
int
main (int argc, char *argv[])
{
#if !MONGOC_CHECK_VERSION($ver[0],$ver[1],$ver[2])
#error libmongoc version check failed
#endif
mongoc_init ();
bson_t child;
bson_t *document = bson_new ();
BSON_APPEND_DOCUMENT_BEGIN (document, "software", &child);
BSON_APPEND_UTF8 (&child, "name", "polymake");
bson_append_document_end (document, &child);
bson_destroy (document);
mongoc_cleanup ();
return 0;
}
---
$add_mongoc_flag = "";
$add_bson_flag = "";
$mongoc_tries = 0;
$bson_tries = 0;
RETRY:
my $error=Polymake::Configure::build_test_program($testcode, CXXFLAGS => $CXXFLAGS.$add_mongoc_flag.$add_bson_flag, LDFLAGS => $LDFLAGS, LIBS => $LIBS);
if ($? != 0) {
if ($error =~ /libmongoc version check failed/) {
my $verstr = join(".",@ver);
$options->{polydb} = "" if $usedopts > 0;
die <<"---";
libmongoc version too old, please install a newer version (>= $verstr) and use
--with-mongoc=prefix to specify the installation directory.
---
}
# retry with /usr/include/<subdir> only when no --with flags are used
if ($usedopts == 0 && $mongoc_tries == 0 && $error =~ /#include.*mongoc\.h.*/ ) {
$mongoc_tries = 1;
$add_mongoc_flag .= " -I/usr/include/$lmc1";
goto RETRY;
}
if ($usedopts == 0 && $mongoc_tries == 1 && $error =~ /#include.*mongoc\.h.*/ && ( defined($pkg_base=$Polymake::Configure::BrewBase) or defined($pkg_base=$Polymake::Configure::FinkBase) )) {
$mongoc_tries = 2;
$add_mongoc_flag .= " -I$pkg_base/include/$lmc1";
goto RETRY;
}
if ($usedopts == 0 && $bson_tries == 0 && $error =~ /#include.*bson\.h.*/ && $CXXFLAGS !~ /$lb1/) {
$bson_tries = 1;
$add_bson_flag .= " -I/usr/include/$lb1";
goto RETRY;
}
if ($usedopts == 0 && $bson_tries == 1 && $error =~ /#include.*bson\.h.*/ && $CXXFLAGS !~ /$lb1/ && ( defined($pkg_base=$Polymake::Configure::BrewBase) or defined($pkg_base=$Polymake::Configure::FinkBase) )) {
$bson_tries = 2;
$add_bson_flag .= " -I$pkg_base/include/$lb1";
goto RETRY;
}
$options->{polydb} = "" if $usedopts > 0;
die <<"---";
Could not compile test program checking for libmongoc and libbson.
Please try using --with-mongoc to specify the installation prefix, or check
./configure --help for more flags to set the include and libary paths.
The complete error log follows:\n\n$error\n
---
}
$CXXFLAGS .= $add_mongoc_flag.$add_bson_flag;
return "CXXFLAGS '$CXXFLAGS', LDFLAGS '$LDFLAGS'";
}
|