# # SYNOPSIS # # AX_SAGA_CHECK_SOCI([MINIMUM-VERSION]) # # DESCRIPTION # # Test for the SOCI libraries of a particular version (or newer) # # If no path to the installed soci library is given, # the macro searchs under /usr, /usr/local, /opt and # /usr/local/package/soci-* # # This macro calls: # # AC_SUBST(HAVE_SOCI) # AC_SUBST(SOCI_LOCATION) # AC_SUBST(SOCI_CPPFLAGS) # AC_SUBST(SOCI_LDFLAGS) # # LAST MODIFICATION # # 2007-03-04 # # COPYLEFT # # Copyright (c) 2007 Andre Merzky # # Copying and distribution of this file, with or without # modification, are permitted in any medium without royalty provided # the copyright notice and this notice are preserved. AC_DEFUN([AX_SAGA_CHECK_SOCI], [ AC_ARG_VAR([SOCI_LOCATION],[SOCI installation directory]) HAVE_SOCI=no HAVE_INTERNAL_SOCI=no export HAVE_INTERNAL_SOCI tmp_location="" AC_ARG_WITH([soci], AS_HELP_STRING([--with-soci=DIR], [use soci (default is YES) at DIR (optional)]), [ if test "$withval" = "no"; then want_soci="no" elif test "$withval" = "yes"; then want_soci="yes" tmp_location="" else want_soci="yes" tmp_location="$withval" fi ], [want_soci="yes"]) # use SOCI_LOCATION if avaialble, and if not # overwritten by --with-soci= if test "x$want_soci" = "xyes"; then # unused # soci_lib_version_req=ifelse([$1], ,0.8.6,$1) packages=`ls /usr/local/package/soci-* 2>>/dev/null` for tmp_path in $tmp_location $SOCI_LOCATION /usr /usr/local /opt $packages; do AC_MSG_CHECKING(for soci in $tmp_path) saved_cppflags=$CPPFLAGS saved_ldflags=$LDFLAGS # try to guess libsuffix lib_name=`ls $lib_name $tmp_path/lib/libsoci_core.dylib 2>/dev/null` lib_name=`ls $lib_name $tmp_path/lib/libsoci_core.so 2>/dev/null` lib_name=`ls $lib_name $tmp_path/lib/libsoci_core.a 2>/dev/null` lib_name=`ls $lib_name $tmp_path/lib/libsoci_core-*-*-*.dylib 2>/dev/null` lib_name=`ls $lib_name $tmp_path/lib/libsoci_core-*-*-*.so 2>/dev/null` lib_name=`ls $lib_name $tmp_path/lib/libsoci_core-*-*-*.a 2>/dev/null` lib_name=`echo $lib_name | head -1 | rev | cut -f 1 -d '/' | rev` lib_suffix=`echo $lib_name | cut -f 2 -d e` lib_suffix=`echo $lib_suffix | rev | cut -f 2- -d . | rev` SOCI_LDFLAGS="-L$tmp_path/lib/ -lsoci_core$lib_suffix" SOCI_CPPFLAGS="-I$tmp_path/include/soci/" CPPFLAGS="$CPPFLAGS $SOCI_CPPFLAGS" export CPPFLAGS LDFLAGS="$LDFLAGS $SOCI_LDFLAGS" export LDFLAGS AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], [[ SOCI::SOCIError ("test"); return (0); ]])], link_soci="yes", link_soci="no") if test "x$link_soci" = "xno"; then AC_MSG_RESULT(no) SOCI_LDFLAGS="" SOCI_CPPFLAGS="" LDFLAGS=$saved_ldflags CPPFLAGS=$saved_cppflags else AC_MSG_RESULT(yes) SOCI_LOCATION=$tmp_path HAVE_SOCI=yes export HAVE_SOCI if test "$tmp_location" != "" && \ test "$tmp_location" != "$tmp_path" ; then AC_MSG_WARN([SOCI found: not in $tmp_location but in $tmp_path]) fi ############################################################# # so much for soci core - now we need to detect the backends soci_default_backends="sqlite3,postgresql,oracle,mysql,firebird" AC_ARG_WITH([backend], AS_HELP_STRING([--with-backend=all], [use these soci backends (default is all). specify a comma separeted list of backends. Allowed values: sqlite3, postgresql, oracle, mysql, firebird, empty, and all)]), [if test "$withval" = "no"; then tmp_want="none" elif test "$withval" = "yes"; then tmp_want=$soci_default_backends else tmp_want=$withval fi ], [tmp_want=$soci_default_backends]) if test "x$tmp_want" = "xall"; then tmp_want=$soci_default_backends fi while $TRUE do tmp_this=`echo $tmp_want | cut -f1 -d','` tmp_want=`echo $tmp_want | grep ',' | cut -f2- -d','` if test "x$tmp_this" == "x"; then break fi AC_MSG_CHECKING(for backend $tmp_this) if ! test -e $SOCI_LOCATION/include/soci/$tmp_this/soci-$tmp_this.h; then AC_MSG_RESULT(not found) soci_backends_nok="$soci_backends_nok $tmp_this" LDFLAGS=$saved_ldflags else AC_MSG_RESULT(found) soci_backends_ok="$soci_backends_ok-$tmp_this-" SOCI_BACKENDS="$SOCI_BACKENDS $tmp_this" SOCI_BACKEND_TMP=`echo $tmp_this | tr 'a-z' 'A-Z'` SOCI_CPPFLAGS="$SOCI_CPPFLAGS -DSAGA_USE_SOCI_$SOCI_BACKEND_TMP" SOCI_LDFLAGS="$SOCI_LDFLAGS -lsoci_$tmp_this$lib_suffix" fi done if test "x$soci_backends_nok" != "x"; then AC_MSG_WARN(Could not find backends:$soci_backends_nok) fi if test "x$soci_backends_ok" == "x"; then AC_MSG_ERROR(Could not find any backend!) fi case "x$soci_backends_ok" in *-sqlite3-* ) HAVE_SOCI_SQLITE3=yes ;; *-postgresql-* ) HAVE_SOCI_POSTGRESQL=yes ;; *-oracle-* ) HAVE_SOCI_ORACLE=yes ;; *-mysql-* ) HAVE_SOCI_MYSQL=yes ;; *-odbc-* ) HAVE_SOCI_ODBC=yes ;; *-firebird-* ) HAVE_SOCI_FIREBIRD=yes ;; esac # done detecting backends ############################################################# break; # iterate over locations fi # link ok done # foreach path if test "$HAVE_SOCI" == "no" ; then AC_MSG_NOTICE(SOCI will be build internally) HAVE_INTERNAL_SOCI=yes export HAVE_INTERNAL_SOCI # internal backends AC_MSG_CHECKING(for backend sqlite3) if test "x$HAVE_SQLITE3" = "xyes"; then AC_MSG_RESULT(found) soci_backends_ok="$soci_backends_ok-sqlite3-" SOCI_BACKENDS="$SOCI_BACKENDS sqlite3" HAVE_SOCI_SQLITE3=yes else AC_MSG_RESULT(not found) fi AC_MSG_CHECKING(for backend postgresql) if test "x$HAVE_POSTGRESQL" = "xyes"; then AC_MSG_RESULT(found) soci_backends_ok="$soci_backends_ok-postgresql-" SOCI_BACKENDS="$SOCI_BACKENDS postgresql" HAVE_SOCI_POSTGRESQL=yes else AC_MSG_RESULT(not found) fi if test "x$soci_backends_ok" == "x"; then AC_MSG_ERROR(Cannot build any of the internal backends!) fi fi fi # want_soci AC_SUBST(HAVE_INTERNAL_SOCI) AC_SUBST(HAVE_SOCI) AC_SUBST(HAVE_SOCI_SQLITE3) AC_SUBST(HAVE_SOCI_POSTGRESQL) AC_SUBST(HAVE_SOCI_MYSQL) AC_SUBST(HAVE_SOCI_ODBC) AC_SUBST(HAVE_SOCI_ORACLE) AC_SUBST(HAVE_SOCI_FIREBIRD) AC_SUBST(SOCI_BACKENDS) AC_SUBST(SOCI_CPPFLAGS) AC_SUBST(SOCI_LDFLAGS) AC_SUBST(SOCI_LOCATION) ])