dovecot-2.0: configure: Support finding PostgreSQL without pg_co...

dovecot at dovecot.org dovecot at dovecot.org
Sun Jul 26 09:18:56 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/5714aba539f0
changeset: 9654:5714aba539f0
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jul 26 02:16:45 2009 -0400
description:
configure: Support finding PostgreSQL without pg_config after all.

diffstat:

1 file changed, 56 insertions(+), 45 deletions(-)
configure.in |  101 ++++++++++++++++++++++++++++++++--------------------------

diffs (116 lines):

diff -r ad5d34c9031d -r 5714aba539f0 configure.in
--- a/configure.in	Fri Jul 24 20:59:49 2009 -0400
+++ b/configure.in	Sun Jul 26 02:16:45 2009 -0400
@@ -1946,56 +1946,67 @@ fi
 fi
 
 if test $want_pgsql != no; then
-  # pg_config exists since 7.1, don't bother with older versions
   AC_CHECK_PROG(PG_CONFIG, pg_config, YES, NO)
   if test $PG_CONFIG = NO; then
-	  if test $want_pgsql = yes; then
-	    AC_ERROR([Can't build with PostgreSQL support: pg_config not found])
+    # based on code from PHP
+    for i in /usr /usr/local /usr/local/pgsql; do
+      for j in include include/pgsql include/postgres include/postgresql ""; do
+	if test -r "$i/$j/libpq-fe.h"; then
+	  PGSQL_INCLUDE=$i/$j
+	fi
+      done
+      for lib in lib lib64; do
+	for j in $lib $lib/pgsql $lib/postgres $lib/postgresql ""; do
+	  if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
+	    PGSQL_LIBDIR=$i/$j
 	  fi
+	done
+      done
+    done
   else
-	PGSQL_INCLUDE="`pg_config --includedir`"
-	PGSQL_LIBDIR="`pg_config --libdir`"
-
-	old_LIBS=$LIBS
-	if test "$PGSQL_LIBDIR" != ""; then
-	  LIBS="$LIBS -L$PGSQL_LIBDIR"
-	fi
-
-	AC_CHECK_LIB(pq, PQconnectdb, [
-		AC_CHECK_LIB(pq, PQescapeStringConn, [
-			AC_DEFINE(HAVE_PQESCAPE_STRING_CONN,, Define if libpq has PQescapeStringConn function)
-		])
-		old_CPPFLAGS=$CPPFLAGS
-		if test "$PGSQL_INCLUDE" != ""; then
-			CPPFLAGS="$CPPFLAGS -I $PGSQL_INCLUDE"
-		fi
-		AC_CHECK_HEADER(libpq-fe.h, [
-			if test "$PGSQL_INCLUDE" != ""; then
-				PGSQL_CFLAGS="$PGSQL_CFLAGS -I$PGSQL_INCLUDE"
-			fi
-			if test "$PGSQL_LIBDIR" != ""; then
-				PGSQL_LIBS="$PGSQL_LIBS -L$PGSQL_LIBDIR"
-			fi
-			PGSQL_LIBS="$PGSQL_LIBS -lpq"
-			AC_DEFINE(HAVE_PGSQL,, Build with PostgreSQL support)
-			found_sql_drivers="$found_sql_drivers pgsql"
-
-                        if test "$all_sql_drivers" = "yes"; then
-			  sql_drivers="$sql_drivers pgsql"
-			fi
-		], [
-		  if test $want_pgsql = yes; then
-		    AC_ERROR([Can't build with PostgreSQL support: libpq-fe.h not found])
+    PGSQL_INCLUDE="`pg_config --includedir`"
+    PGSQL_LIBDIR="`pg_config --libdir`"  
+  fi
+
+  old_LIBS=$LIBS
+  if test "$PGSQL_LIBDIR" != ""; then
+    LIBS="$LIBS -L$PGSQL_LIBDIR"
+  fi
+
+  AC_CHECK_LIB(pq, PQconnectdb, [
+	  AC_CHECK_LIB(pq, PQescapeStringConn, [
+		  AC_DEFINE(HAVE_PQESCAPE_STRING_CONN,, Define if libpq has PQescapeStringConn function)
+	  ])
+	  old_CPPFLAGS=$CPPFLAGS
+	  if test "$PGSQL_INCLUDE" != ""; then
+		  CPPFLAGS="$CPPFLAGS -I $PGSQL_INCLUDE"
+	  fi
+	  AC_CHECK_HEADER(libpq-fe.h, [
+		  if test "$PGSQL_INCLUDE" != ""; then
+			  PGSQL_CFLAGS="$PGSQL_CFLAGS -I$PGSQL_INCLUDE"
 		  fi
-		])
-		CPPFLAGS=$old_CPPFLAGS
-	], [
-	  if test $want_pgsql = yes; then
-	    AC_ERROR([Can't build with PostgreSQL support: libpq not found])
-	  fi
-	])
-	LIBS=$old_LIBS
-  fi
+		  if test "$PGSQL_LIBDIR" != ""; then
+			  PGSQL_LIBS="$PGSQL_LIBS -L$PGSQL_LIBDIR"
+		  fi
+		  PGSQL_LIBS="$PGSQL_LIBS -lpq"
+		  AC_DEFINE(HAVE_PGSQL,, Build with PostgreSQL support)
+		  found_sql_drivers="$found_sql_drivers pgsql"
+
+		  if test "$all_sql_drivers" = "yes"; then
+		    sql_drivers="$sql_drivers pgsql"
+		  fi
+	  ], [
+	    if test $want_pgsql = yes; then
+	      AC_ERROR([Can't build with PostgreSQL support: libpq-fe.h not found])
+	    fi
+	  ])
+	  CPPFLAGS=$old_CPPFLAGS
+  ], [
+    if test $want_pgsql = yes; then
+      AC_ERROR([Can't build with PostgreSQL support: libpq not found])
+    fi
+  ])
+  LIBS=$old_LIBS
 fi
 
 if test $want_mysql != no; then


More information about the dovecot-cvs mailing list