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
|
dnl -*- mode: autoconf -*-
dnl Copyright 2010 Vivien Malerba
dnl
dnl SYNOPSIS
dnl
dnl MDBTOOLS_CHECK([libdirname],[GLib's CFLAGS],[GLib's LIBS])
dnl
dnl [libdirname]: defaults to "lib". Can be overridden by the --with-mdb-libdir-name option
dnl [GLib's CFLAGS]: default to `$PKG_CONFIG --cflags glib-2.0`
dnl [GLib's LIBS]: default to `$PKG_CONFIG --libs glib-2.0`, used when pkg-config is not
dnl used to find the mdbtools package
dnl
dnl
dnl DESCRIPTION
dnl
dnl This macro tries to find the MDBTools libraries and header files
dnl
dnl It defines two options:
dnl --with-mdb=yes/no/<directory>
dnl --with-mdb-libdir-name=<dir. name>
dnl
dnl If the 1st option is "yes" then the macro tries to use pkg-config to locate
dnl the "libmdb" package, and if it fails, it tries in several well known directories
dnl
dnl If the 1st option is "no" then the macro does not attempt at locating the
dnl mdbtools package
dnl
dnl If the 1st option is a directory name, then the macro tries to locate the mdbtools package
dnl in the specified directory.
dnl
dnl If the macro has to try to locate the mdbtools 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).
dnl
dnl USED VARIABLES
dnl
dnl $linklibext: contains the library suffix (like ".so"). If not specified ".so" is used.
dnl
dnl
dnl DEFINED VARIABLES
dnl
dnl This macro always calls:
dnl
dnl AC_SUBST(MDB_LIBS)
dnl AC_SUBST(MDB_CFLAGS)
dnl mdbtools_found=yes (from where)/no
dnl
dnl and if the mdbtools package is found:
dnl
dnl AM_CONDITIONAL(MDB, true)
dnl AC_DEFINE(MDB_WITH_WRITE_SUPPORT,[1],[define if mdb_open accepts MDB_WRITABLE])
dnl AC_DEFINE(MDB_BIND_COLUMN_FOUR_ARGS,[1],[define if mdb_bind_column accepts four args])
dnl AC_DEFINE(MDB_V07,[1],[define if Mdbtools is in version 0.7])
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([_MDBTOOLS_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
mdb_loclibdir=$1
if test "x$mdb_loclibdir" = x
then
if test "x$platform_win32" = xyes
then
mdb_loclibdir=bin
else
mdb_loclibdir=lib
fi
fi
mdb_glib_cflags=$2
if test "x$mdb_glib_cflags" = x
then
mdb_glib_cflags=`$PKG_CONFIG --cflags glib-2.0`
fi
mdb_glib_libs=$3
if test "x$mdb_glib_libs" = x
then
mdb_glib_libs=`$PKG_CONFIG --libs glib-2.0`
fi
# determine if MDBTools should be searched for
# and use pkg-config if the "yes" option is used
mdbtools_found=no
try_mdb=true
pkgmdb=no
MDB_LIBS=""
mdb_test_dir=""
AC_ARG_WITH(mdb,
AS_HELP_STRING([--with-mdb[=@<:@yes/no/<directory>@:>@]],
[Locate MDBTools files for the MS Access backend (read only)]),[
if test $withval = no
then
try_mdb=false
elif test $withval != yes
then
mdb_test_dir=$withval
fi])
AC_ARG_WITH(mdb-libdir-name,
AS_HELP_STRING([--with-mdb-libdir-name[=@<:@<dir. name>@:>@]],
[Locate MDBTools library file, related to the MDB prefix specified from --with-mdb]),
[mdb_loclibdir=$withval])
# try with pkgconfig
if test $try_mdb = true -a "x$mdb_test_dir" = x
then
PKG_CHECK_MODULES(MDB, "libmdb",[pkgmdb=yes],[pkgmdb=no])
if test $pkgmdb = no
then
mdb_test_dir="/usr /usr/local /opt/gnome"
fi
fi
# try to locate files if pkg-config did not already do its job
if test $try_mdb = true
then
if test $pkgmdb = no
then
if test "x$linklibext" = x
then
mdb_libext=".so"
else
mdb_libext="$linklibext"
fi
mdbdir=""
for d in $mdb_test_dir
do
AC_MSG_CHECKING([for MDB Tools files in $d])
if test -f $d/include/mdbtools.h -a -f $d/$mdb_loclibdir/libmdb$mdb_libext -o -f $d/include/mdbtools.h -a -f $d/$mdb_loclibdir/libmdb.a
then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I$d/include $mdb_glib_cflags"
save_LIBS="$LIBS"
LIBS="$LIBS -L$d/$mdb_loclibdir -lmdb $mdb_glib_libs"
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <mdbtools.h>
int main() {
printf("%p", mdb_open);
return 0;
}
])],
mdbdir=$d)
CFLAGS="$save_CFLAGS"
LIBS="$save_LIBS"
if test x$mdbdir != x
then
AC_MSG_RESULT([found])
MDB_CFLAGS=-I${mdbdir}/include
MDB_LIBS="-L${mdbdir}/$mdb_loclibdir -lmdb"
break
else
AC_MSG_RESULT([not found])
fi
else
AC_MSG_RESULT([not found])
fi
done
fi
if test "x$MDB_LIBS" = x
then
AC_MSG_NOTICE([MDB backend not used])
else
mdbtools_found="yes (from system installation)"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $MDB_CFLAGS $mdb_glib_cflags"
AC_MSG_CHECKING([whether mdb_open takes one or two arguments])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <mdbtools.h>
int main() {
const char *filename;
mdb_open(filename, MDB_WRITABLE);
return 0;
}
])],
mdb_open_args=two, mdb_open_args=one)
AC_MSG_RESULT($mdb_open_args)
if test "$mdb_open_args" = "two"; then
AC_DEFINE(MDB_WITH_WRITE_SUPPORT,[1],[define if mdb_open accepts MDB_WRITABLE])
fi
AC_MSG_CHECKING([whether mdb_bind_column takes three or four arguments])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <mdbtools.h>
int main() {
MdbHandle *mdb;
int c;
char *bound_data[256];
int len;
mdb_bind_column(mdb, c, bound_data[c], &len);
return 0;
}
]])],
mdb_bind_column_args=four, mdb_bind_column_args=three)
AC_MSG_RESULT($mdb_bind_column_args)
if test "$mdb_bind_column_args" = "four"; then
AC_DEFINE(MDB_BIND_COLUMN_FOUR_ARGS,[1],[define if mdb_bind_column accepts four args])
fi
AC_MSG_CHECKING([whether Mdbtools is in version 0.7])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <mdbtools.h>
int main() {
int a;
a = MDB_SDATETIME;
return 0;
}
]])],
mdb_v7=no, mdb_v7=yes)
AC_MSG_RESULT($mdb_v7)
if test "$mdb_v7" = "yes"; then
AC_DEFINE(MDB_V07,[1],[define if Mdbtools is in version 0.7])
fi
CFLAGS="$save_CFLAGS"
fi
fi
AM_CONDITIONAL(MDB,[test "$mdbtools_found" != "no"])
AM_CONDITIONAL(MDBEMBEDDED, false)
AC_SUBST(MDB_LIBS)
AC_SUBST(MDB_CFLAGS)
])
dnl Usage:
dnl MDBTOOLS_CHECK([libdirname],[GLib's CFLAGS],[GLib's LIBS])
AC_DEFUN([MDBTOOLS_CHECK],
[
AC_ARG_ENABLE(system-mdbtools,
AS_HELP_STRING([--enable-system-mdbtools], [Use MDBTools installed on the system [default=yes]]),
[use_syst_mdb=$enableval], [use_syst_mdb="yes"])
if test "x$use_syst_mdb" = "xyes"; then
_MDBTOOLS_CHECK_INTERNAL([$1],[$2],[$3])
else
AM_ICONV
AM_CONDITIONAL(MDB, true)
AM_CONDITIONAL(MDBEMBEDDED, true)
AC_DEFINE(MDB_BIND_COLUMN_FOUR_ARGS,[1],[define if mdb_bind_column accepts four args])
AC_DEFINE(MDB_WITH_WRITE_SUPPORT,[1],[define if mdb_open accepts MDB_WRITABLE])
mdbtools_found="yes (embedded)"
fi
])
|