# # SYNOPSIS # # AX_SAGA_CHECK_POSTGRESQL([MINIMUM-VERSION]) # # DESCRIPTION # # Test for the POSTGRESQL libraries of a particular version (or newer) # # If no path to the installed postgresql library is given, # the macro searchs under /usr, /usr/local, /opt and # /usr/local/package/postgresql-* # # This macro calls: # # AC_SUBST(HAVE_POSTGRESQL) # AC_SUBST(POSTGRESQL_LOCATION) # AC_SUBST(POSTGRESQL_CPPFLAGS) # AC_SUBST(POSTGRESQL_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_POSTGRESQL], [ AC_ARG_VAR([POSTGRESQL_LOCATION],[POSTGRESQL installation directory]) HAVE_POSTGRESQL=no tmp_location="" AC_ARG_WITH([postgresql], AS_HELP_STRING([--with-postgresql=DIR], [use postgresql (default is YES) at DIR (optional)]), [ if test "$withval" = "no"; then want_postgresql="no" elif test "$withval" = "yes"; then want_postgresql="yes" tmp_location="" else want_postgresql="yes" tmp_location="$withval" fi ], [want_postgresql="yes"]) # use POSTGRESQL_LOCATION if avaialble, and if not # overwritten by --with-postgresql= if test "x$want_postgresql" = "xyes"; then # unused # postgresql_lib_version_req=ifelse([$1], ,0.8.6,$1) packages=`ls /usr/local/package/postgresql-* 2>>/dev/null` for tmp_path in $tmp_location $POSTGRESQL_LOCATION /usr /usr/local /opt $packages; do AC_MSG_CHECKING(for postgresql in $tmp_path) saved_cppflags=$CPPFLAGS saved_ldflags=$LDFLAGS POSTGRESQL_PATH=$tmp_path POSTGRESQL_LDFLAGS="-L$tmp_path/lib/ -lpq" POSTGRESQL_CPPFLAGS="-I$tmp_path/include/postgresql" CPPFLAGS="$CPPFLAGS $POSTGRESQL_CPPFLAGS" export CPPFLAGS LDFLAGS="$LDFLAGS $POSTGRESQL_LDFLAGS" export LDFLAGS AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], [[ PGconn* connection = PQconnectdb ("testdb"); return (0); ]])], link_postgresql="yes", link_postgresql="no") if test "x$link_postgresql" = "xno"; then AC_MSG_RESULT(no) LDFLAGS=$saved_ldflags CPPFLAGS=$saved_cppflags else AC_MSG_RESULT(yes) POSTGRESQL_LOCATION=$tmp_path HAVE_POSTGRESQL=yes export HAVE_POSTGRESQL AC_SUBST(HAVE_POSTGRESQL) AC_SUBST(POSTGRESQL_LOCATION) AC_SUBST(POSTGRESQL_CPPFLAGS) AC_SUBST(POSTGRESQL_LDFLAGS) if test "$tmp_location" != "" && \ test "$tmp_location" != "$tmp_path" ; then AC_MSG_WARN([POSTGRESQL found: not in $tmp_location but in $tmp_path]) fi break; fi # link ok done # foreach path if test "$HAVE_POSTGRESQL" == "no" ; then AC_MSG_WARN(POSTGRESQL not found) fi fi # want_postgresql ])