From 67212ade1deca02d9fedf2b6c0246274766f502f Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 12 Oct 2005 08:12:30 +0000 Subject: [PATCH] Use pg_config to find libpq. --- Makefile.am | 4 ++- configure.ac | 88 +++++----------------------------------------------- 2 files changed, 11 insertions(+), 81 deletions(-) diff --git a/Makefile.am b/Makefile.am index a4e5e97..3d27814 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ # # Makefile.am for psqlodbc (PostgreSQL ODBC driver) # -# $Header: /home/heikki/psqlodbc-cvs-copy/psqlodbc/Makefile.am,v 1.25 2005/09/19 13:31:58 anoop Exp $ +# $Header: /home/heikki/psqlodbc-cvs-copy/psqlodbc/Makefile.am,v 1.26 2005/10/12 08:12:30 petere Exp $ # #------------------------------------------------------------------------- @@ -12,6 +12,8 @@ lib_LTLIBRARIES = psqlodbc.la psqlodbc_la_LDFLAGS = -module -no-undefined -avoid-version +psqlodbc_la_LIBADD = -lpq + psqlodbc_la_SOURCES = \ info.c bind.c columninfo.c connection.c convert.c drvconn.c \ environ.c execute.c win_md5.c misc.c options.c \ diff --git a/configure.ac b/configure.ac index b85849c..e9ab46b 100644 --- a/configure.ac +++ b/configure.ac @@ -118,91 +118,19 @@ AC_C_CONST AC_TYPE_SIZE_T AC_STRUCT_TM - -# -#Options for pgsql headers and libraries -# - -AC_MSG_CHECKING(for pgsql include files) -AC_ARG_WITH(pgsql-include, -[ --with-pgsql-include=DIR Look for postgreSQL include files in DIR], -[if test "$withval" != no; then - AC_MSG_RESULT(yes) - pgsql_include="$withval" -else - AC_MSG_RESULT(no) - AC_MSG_ERROR([you must specify a directory when using --with-pgsql-include=DIR]) -fi]) # -# Library directories +# Find libpq headers and libraries # -AC_MSG_CHECKING(for pgsql) -AC_ARG_WITH(pgsql, -[ --with-pgsql=DIR look for PostgreSQL libraries and headers in DIR], -[if test "$withval" != no -then - AC_MSG_RESULT(yes) - LIBPQ_HOME="$withval" -else - AC_MSG_RESULT(no) -fi], [ -AC_MSG_RESULT(yes) -LIBPQ_HOME="/usr/local/pgsql" -if test "$pgsql_include" = "" -then - if test ! -f "${LIBPQ_HOME}/include/libpq-fe.h" - then - LIBPQ_HOME=/usr/local - if test ! -f "${LIBPQ_HOME}/include/libpq-fe.h" - then - LIBPQ_HOME=/usr - fi - fi - if test -f "/usr/include/libpq-fe.h" - then - pgsql_include="/usr/include" - else - if test -f "/usr/include/pgsql/libpq-fe.h" - then - pgsql_include="/usr/include/pgsql" - fi - fi +AC_PATH_PROGS(PG_CONFIG, pg_config) +if test -z "$PG_CONFIG" ; then + AC_MSG_ERROR([pg_config not found]) fi - ]) -# -# Check for libpq libraries and headers -# -if test -n "${LIBPQ_HOME}" -then - OLD_LDFLAGS="$LDFLAGS" - OLD_CPPFLAGS="$CPPFLAGS" - LDFLAGS="$LDFLAGS -L${LIBPQ_HOME}/lib" - AC_CHECK_LIB(pq, PQexec, [pgsql_cv_libpq=yes], [pgsql_cv_libpq=no]) - - if test "$pgsql_include" != "" - then - CPPFLAGS="$CPPFLAGS -I${pgsql_include}" - else - CPPFLAGS="$CPPFLAGS -I${LIBPQ_HOME}/include" - fi - AC_CHECK_HEADER(libpq-fe.h, [pgsql_cv_libpqfe_h=yes], [pgsql_cv_libpqfe_h=no]) - - if test "$pgsql_cv_libpq" = "yes" -a "$pgsql_cv_libpqfe_h" = "yes" - then - AC_MSG_CHECKING(pgsql in ${LIBPQ_HOME}) - AC_MSG_RESULT(ok) - else - AC_MSG_CHECKING(pgsql in ${LIBPQ_HOME}) - AC_MSG_RESULT(failed) - LDFLAGS="$OLD_LDFLAGS" - CPPFLAGS="$OLD_CPPFLAGS" - AC_MSG_ERROR([you must specify a valid pgsql installation with --with-pgsql=DIR]) - fi - LIBS="$LIBS -lpq" - CPPFLAGS="$CPPFLAGS " +pg_includedir=`$PG_CONFIG --includedir` +pg_libdir=`$PG_CONFIG --libdir` +CPPFLAGS="$CPPFLAGS -I$pg_includedir" +LDFLAGS="$LDFLAGS -L$pg_libdir" -fi AC_CONFIG_FILES([Makefile]) AC_OUTPUT -- 2.39.5