From 88da6a0adecc179c4b0d4de4d6354fc288102174 Mon Sep 17 00:00:00 2001 From: arjen Date: Sat, 4 Jun 2005 07:30:25 +0000 Subject: [PATCH] Improved the search for Postgres libraries --- configure.in | 93 ++++++++---------------------------------------------------- 1 file changed, 12 insertions(+), 81 deletions(-) diff --git a/configure.in b/configure.in index d1567df..0b57e30 100644 --- a/configure.in +++ b/configure.in @@ -41,81 +41,24 @@ AC_CHECK_LIB(AXE, main, , AC_MSG_ERROR(AXE Library is not installed)) #AC_CHECK_LIB(pthread, pthread_create) AC_CHECK_LIB(xml2, xmlParseFile) -# Where are the postgres includes... -postgres_include_default= -for usual_suspect in \ - /usr/local/include/postgresql \ - /usr/local/include/pgsql \ - /usr/local/pgsql/include \ - /usr/local/include \ - /usr/include/postgresql \ - /usr/include/pgsql \ - /usr/include \ - /opt/postgresql/include \ - /opt/pgsql/include \ - /usr/freeware/include \ -; do -AC_CHECK_FILE([$usual_suspect/libpq-fe.h], - [postgres_include_default=$usual_suspect], -) - if test -n "$postgres_include_default" ; then - break - fi -done - -AC_ARG_WITH(postgres-include, - --with-postgres-include PostgreSQL headers directory - - , test "$withval" = no || with_postgres_include=$withval - , with_postgres_include=$postgres_include_default -) - -# ..and libraries? -postgres_lib_default= -for usual_suspect in \ - /usr/local/lib/postgresql \ - /usr/local/lib/pgsql \ - /usr/local/pgsql/lib \ - /usr/local/lib \ - /usr/lib/postgresql \ - /usr/lib/pgsql \ - /usr/lib \ - /opt/postgresql/lib \ - /opt/pgsql/lib \ - /usr/freeware/lib32 \ -; do - for library_extension in so a sa ; do -AC_CHECK_FILE([$usual_suspect/libpq.$library_extension], - [postgres_lib_default=$usual_suspect], -) - done - if test -n "$postgres_lib_default" ; then - break - fi -done - -AC_ARG_WITH(postgres-lib, - --with-postgres-lib PostgreSQL library directory containing libpq - , test "$withval" = no || with_postgres_lib=$withval - , with_postgres_lib=$postgres_lib_default -) - -# provide one way to specify both include and lib -AC_ARG_WITH(postgres, - --with-postgres PostgreSQL common directory. Use this to specify libs & includes rooted at one place - , test "$withval" = no || with_postgres=$withval - with_postgres_lib=${with_postgres}/lib - with_postgres_include=${with_postgres}/include - , with_postgres=no -) +# Find PostgreSQL includes and libraries +AC_PATH_PROGS(PG_CONFIG, pqxx-config) +if test -z "$PG_CONFIG" || test ! -r "$PG_CONFIG"; then + AC_MSG_ERROR([libpqxx configuration script was not found]) +fi +with_postgres_include=`$PG_CONFIG --cflags` +AC_MSG_NOTICE([using PostgreSQL headers at $with_postgres_include]) +with_postgres_lib=`$PG_CONFIG --libs` +AC_MSG_NOTICE([using PostgreSQL libraries at $with_postgres_lib]) AC_SUBST(with_postgres_lib) AC_SUBST(with_postgres_include) -POSTGRES_LIB="-L${with_postgres_lib} -R${with_postgres_lib} -lpq" +POSTGRES_LIB="${with_postgres_lib}" AC_SUBST(POSTGRES_LIB) -POSTGRES_INCLUDE="-I${with_postgres_include}" +POSTGRES_INCLUDE="${with_postgres_include}" AC_SUBST(POSTGRES_INCLUDE) + # Checks for libraries. AC_CHECK_LIB([pq], [PQexec], [], [AC_MSG_ERROR([Failed to find a suitable libpq. @@ -123,18 +66,6 @@ PostgreSQL's libpq needs to be installed. Perhaps you need to specify --with-postgres-lib? ])], -L${with_postgres_lib}) -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADER([${with_postgres_include}/libpq-fe.h],,AC_MSG_ERROR( -[Can't find libpq-fe.h in ${with_postgres_include}. -Please specify the location of the PostgreSQL include files with ---with-postgres-include=... or --with-postgres=...] -)) - -AC_CHECK_HEADER([${with_postgres_include}/libpq/libpq-fs.h],,AC_MSG_ERROR( -[Can't find libpq-fs.h in ${with_postgres_include}/libpq. -Please locate it and report your findings so this script can be corrected.] -)) CXXFLAGS="$CXXFLAGS $POSTGRES_INCLUDE" LIBS="$LIBS $POSTGRES_LIB" -- 2.11.0