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 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
dnl -*- mode: autoconf -*-
dnl Copyright 2010 Vivien Malerba
dnl
dnl SYNOPSIS
dnl
dnl BDB_CHECK([libdirname], [includedirname])
dnl
dnl [libdirname]: defaults to "lib". Can be overridden by the --with-bdb-libdir-name option
dnl [includedirname]: defaults to "include". Can be overridden by the
dnl --with-bdb-includedir-name option
dnl
dnl DESCRIPTION
dnl
dnl This macro tries to find the Bdb libraries and header files. If the BDB setup is found
dnl then it also tries to find the SQL extension to BDB (starting from version 5.0)
dnl
dnl It defines two options:
dnl --with-bdb=yes/no/<directory>
dnl --with-bdb-libdir-name=<dir. name>
dnl --with-bdb-includedir-name=<dir. name>
dnl
dnl If the 1st option is "yes" then the macro in several well known directories
dnl
dnl If the 1st option is "no" then the macro does not attempt at locating the
dnl bdb package
dnl
dnl If the 1st option is a drectory name, then the macro tries to locate the bdb package
dnl in the specified directory.
dnl
dnl If the macro has to try to locate the bdb package in one or more directories, it will
dnl try to locate the header files in $dir/include and the library files in $dir/lib, unless
dnl the second option is used to specify a directory name to be used instead of "lib" (for
dnl example lib64), and the third option is used to specify a path name to be used instead
dnl of "include" (for example include/db5).
dnl
dnl USED VARIABLES
dnl
dnl $linklibext: contains the library suffix (like ".so"). If not specified ".so" is used.
dnl $platform_win32: contains "yes" on Windows platforms. If not specified, assumes "no"
dnl
dnl
dnl DEFINED VARIABLES
dnl
dnl This macro always calls:
dnl
dnl AC_SUBST(BDB_LIBS)
dnl AC_SUBST(BDB_LIB)
dnl AC_SUBST(BDB_CFLAGS)
dnl AC_SUBST(LIBGDA_BDB_INC)
dnl AC_SUBST(LIBGDA_BDB_TYPE)
dnl bdb_found=yes/no
dnl bdbsql_found=yes/no
dnl AC_SUBST(BDBSQL_LIBS)
dnl AC_SUBST(BDBSQL_CFLAGS)
dnl
dnl and if the bdb package is found:
dnl
dnl AM_CONDITIONAL(BDB, true)
dnl AM_CONDITIONAL(BDBSQL, true)
dnl
dnl
dnl LICENSE
dnl
dnl This file is free software; the author(s) gives unlimited
dnl permission to copy and/or distribute it, with or without
dnl modifications, as long as this notice is preserved.
dnl
m4_define([_BDB_CHECK_INTERNAL],
[
AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
bdb_loclibdir=$1
if test "x$bdb_loclibdir" = x
then
if test "x$platform_win32" = xyes
then
bdb_loclibdir=bin
else
bdb_loclibdir=lib
fi
fi
bdb_locincludedir=$2
if test "x$bdb_locincludedir" = x
then
bdb_locincludedir=include
fi
# determine if Bdb should be searched for
# and use pkg-config if the "yes" option is used
bdb_found=no
try_bdb=true
BDB_LIBS=""
bdb_test_dir="/usr /usr/local /local"
AC_ARG_WITH(bdb,
AS_HELP_STRING([--with-bdb[=@<:@yes/no/<directory>@:>@]],
[Locate Berkeley DB files]),[
if test $withval = no
then
try_bdb=false
elif test $withval != yes
then
bdb_test_dir=$withval
fi])
AC_ARG_WITH(bdb-libdir-name,
AS_HELP_STRING([--with-bdb-libdir-name[=@<:@<dir. name>@:>@]],
[Locate BDB library file, related to the prefix specified from --with-bdb]),
[bdb_loclibdir=$withval])
AC_ARG_WITH(bdb-includedir-name,
AS_HELP_STRING([--with-bdb-includedir-name[=@<:@<dir. name>@:>@]],
[Locate BDB header file, related to the prefix specified from --with-bdb]),
[bdb_locincludedir=$withval])
# try to locate files
if test $try_bdb = true
then
if test "x$linklibext" = x
then
bdb_libext=".so"
else
bdb_libext="$linklibext"
fi
bdbdir=""
for d in $bdb_test_dir
do
bdbdir=""
AC_MSG_CHECKING([for Berkeley DB files in $d])
for version in "" 6.0 5.3 5.1 5.0 4.9 4.8 4.7
do
if test $platform_win32 = yes
then
sversion=`echo $version | sed -e 's,\.,,g'`
else
sversion=`echo $version | sed -e 's,\..*,,g'`
fi
if test -z $version
then
db_libfilename="libdb$bdb_libext"
db_lib="-ldb"
db_libfile="$d/$bdb_loclibdir/libdb$bdb_libext"
try_headers="db.h"
else
if test $platform_win32 = yes
then
db_libfilename="libdb$sversion$bdb_libext"
db_lib="-ldb$sversion"
db_libfile="$d/$bdb_loclibdir/libdb$sversion$bdb_libext"
try_headers="db.h db$version/db.h db$sversion/db.h"
else
db_libfilename="libdb-$version$bdb_libext"
db_lib="-ldb-$version"
db_libfile="$d/$bdb_loclibdir/libdb-$version$bdb_libext"
try_headers="db.h db$version/db.h db$sversion/db.h"
fi
fi
for db_hdr in $try_headers
do
#echo "Checking for files $d/$bdb_locincludedir/$db_hdr and $db_libfile"
if test -f $d/$bdb_locincludedir/$db_hdr -a -f $db_libfile
then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I$d/$bdb_locincludedir"
save_LIBS="$LIBS"
LIBS="$LIBS -L$d/$bdb_loclibdir $db_lib"
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <${db_hdr}>
int main() {
printf("%p", db_create);
return 0;
}
])],
bdbdir=$d)
CFLAGS="$save_CFLAGS"
LIBS="$save_LIBS"
if test x$bdbdir != x
then
break;
fi
fi
done
if test x$bdbdir != x
then
break;
fi
done
if test x$bdbdir != x
then
if test -z $version
then
AC_MSG_RESULT([found])
else
AC_MSG_RESULT([found version $version])
fi
BDB_CFLAGS=-I${bdbdir}/$bdb_locincludedir
BDB_LIBS="-L${bdbdir}/$bdb_loclibdir $db_lib"
BDB_LIB=$db_libfilename
BDB_DIR="$bdbdir"
AC_MSG_NOTICE([the runtime shared library to load will be $BDB_LIB])
break
else
AC_MSG_RESULT([not found])
fi
done
if test "x$BDB_LIBS" = x
then
AC_MSG_NOTICE([BDB backend not used])
else
LIBGDA_BDB_INC="#include <libgda/gda-data-model-bdb.h>"
LIBGDA_BDB_TYPE="gda_data_model_bdb_get_type"
bdb_found=yes
fi
fi
AM_CONDITIONAL(BDB,[test "$bdb_found" = "yes"])
AC_SUBST(BDB_LIB)
AC_SUBST(BDB_LIBS)
AC_SUBST(BDB_CFLAGS)
AC_SUBST(LIBGDA_BDB_INC)
AC_SUBST(LIBGDA_BDB_TYPE)
])
m4_define([_BDBSQL_CHECK_INTERNAL],
[
AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
m4_if([$1],[],[bdbsql_loclibdir=""],[bdbsql_loclibdir=$1])
if test "x$bdbsql_loclibdir" = x
then
if test "x$platform_win32" = xyes
then
bdbsql_loclibdir=bin
else
bdbsql_loclibdir=lib
fi
fi
bdbsql_found=no
bdbsqldir=""
if test "x$BDB_DIR" != x
then
AC_MSG_CHECKING([for Berkeley DB SQL files along with found BDB installation])
#echo "Checking $BDB_DIR/$bdb_locincludedir/dbsql.h and $BDB_DIR/$bdb_locincludedir/libdb/dbsql.h"
if test -f $BDB_DIR/$bdb_locincludedir/dbsql.h -o -f $BDB_DIR/$bdb_locincludedir/libdb/dbsql.h
then
if test -f $BDB_DIR/$bdb_locincludedir/libdb/dbsql.h
then
BDBSQL_CFLAGS="$BDB_CFLAGS/libdb"
else
BDBSQL_CFLAGS="$BDB_CFLAGS"
fi
BDBSQL_LIBS="-L$BDB_DIR/$bdb_loclibdir -ldb_sql"
BDBSQL_PATH="$BDB_DIR/$bdb_loclibdir"
AC_MSG_RESULT([found])
AC_CHECK_LIB(db_sql, sqlite3_table_column_metadata,[bdbsql_api=1], [bdbsql_api=0], $BDBSQL_CFLAGS $BDBSQL_LIBS -pthread -ldl)
if test $bdbsql_api = 0
then
BDBSQL_CFLAGS=""
BDBSQL_LIBS=""
AC_MSG_NOTICE([Installed BDB Sql was not compiled with the SQLITE_ENABLE_COLUMN_METADATA, BDB Sql provider not compiled])
else
bdbsql_found=yes
bdbsqldir="$BDB_DIR"
fi
else
AC_MSG_RESULT([not found])
fi
fi
AM_CONDITIONAL(BDBSQL,[test "$bdbsql_found" = "yes"])
AC_SUBST(BDBSQL_LIBS)
AC_SUBST(BDBSQL_CFLAGS)
])
dnl Usage:
dnl BDB_CHECK([libdirname], [includedirname])
AC_DEFUN([BDB_CHECK],
[
_BDB_CHECK_INTERNAL([$1], [$2])
_BDBSQL_CHECK_INTERNAL([$1], [$2])
])
|