FS-5512 --resolve ; clean up PostgreSQL libpq client detection in configure

Clean up the libpq autodection and make sure it functionswith both pg_config and pkg-config.

if you are installing into a non-FHS standard location such as what happens with RPMs from the Postgres yum repo, you will need to make sure pkg-config can fild the libpq.pc file.
example: export PKG_CONFIG_PATH=/usr/pgsql-9.3/lib/pkgconfig

you may also want to make sure your path can find pg_config
example: export PATH=/usr/pgsql-9.3/bin:$PATH
This commit is contained in:
Ken Rice 2014-02-21 14:51:46 -06:00
parent 2907a4824f
commit 81185aa9b7
1 changed files with 24 additions and 15 deletions

View File

@ -1,4 +1,5 @@
# -*- Autoconf -*- # -*- Autoconf -*-
>>>>>>> 1a85246... svn has been long retired
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
# Must change all of the below together # Must change all of the below together
@ -425,39 +426,47 @@ AC_ARG_ENABLE(core-pgsql-pkgconfig,
if test x"$enable_core_pgsql_support" = x"yes" ; then if test x"$enable_core_pgsql_support" = x"yes" ; then
AC_PATH_PROG([PG_CONFIG], [pg_config], [no]) AC_PATH_PROG([PG_CONFIG], [pg_config], [no])
AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no]) AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no])
if test "$PG_CONFIG" = "no"; then
AC_MSG_RESULT([no])
AC_MSG_FAILURE([Unabled to find pg_config in PATH. Is PostgreSQL installed?])
else
if test "$PKG_CONFIG" = "no" \ if test "$PKG_CONFIG" = "no" \
|| test x"$enable_core_pgsql_pkgconfig" = x"no" \ || test x"$enable_core_pgsql_pkgconfig" = x"no" \
|| ! pkg-config libpq; then || ! pkg-config libpq; then
AC_MSG_CHECKING([for PostgreSQL libraries]) if test "$PG_CONFIG" != "no"; then
POSTGRESQL_CXXFLAGS="`$PG_CONFIG --cppflags` -I`$PG_CONFIG --includedir`" AC_MSG_CHECKING([for PostgreSQL libraries via pg_config])
POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags|sed 's/ -Wl,--as-needed//g'` -L`$PG_CONFIG --libdir` -lpq" POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"
POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` POSTGRESQL_LIBDIR="-L`$PG_CONFIG --libdir`"
POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL ([0-9]+).[0-9]+.?[0-9]+?#\1#'` POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir` -lpq"
POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.([0-9]+).?[0-9]+?#\1#'` POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'`
POSTGRESQL_PATCH_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.[0-9]+.?([0-9]+)?#\1#'` POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL ([0-9]+).[0-9]+.?[0-9]+?#\1#'`
POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.([0-9]+).?[0-9]+?#\1#'`
POSTGRESQL_PATCH_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.[0-9]+.?([0-9]+)?#\1#'`
else
AC_MSG_ERROR([no usable pkg-config or pg_config; please install libpq devel package or equivalent])
fi
else else
AC_MSG_CHECKING([for PostgreSQL libraries]) AC_MSG_CHECKING([for PostgreSQL libraries via pkg_config])
POSTGRESQL_CXXFLAGS="`$PKG_CONFIG --cflags libpq`" POSTGRESQL_CFLAGS="`$PKG_CONFIG --cflags libpq`"
POSTGRESQL_LIBDIR="`$PKG_CONFIG libpq --libs-only-L`"
POSTGRESQL_LDFLAGS="`$PKG_CONFIG --libs libpq`" POSTGRESQL_LDFLAGS="`$PKG_CONFIG --libs libpq`"
POSTGRESQL_VERSION="`$PKG_CONFIG --modversion libpq`" POSTGRESQL_VERSION="`$PKG_CONFIG --modversion libpq`"
POSTGRESQL_MAJOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f1`" POSTGRESQL_MAJOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f1`"
POSTGRESQL_MINOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f2`" POSTGRESQL_MINOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f2`"
POSTGRESQL_PATCH_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f3`" POSTGRESQL_PATCH_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f3`"
fi fi
save_LIBS="$LIBS"
LIBS="$POSTGRESQL_LIBDIR $LIBS"
AC_MSG_RESULT([$POSTGRESQL_LIBDIR])
AC_DEFINE([SWITCH_HAVE_PGSQL], [1], [Define to 1 if PostgreSQL libraries are available]) AC_DEFINE([SWITCH_HAVE_PGSQL], [1], [Define to 1 if PostgreSQL libraries are available])
AC_DEFINE_UNQUOTED([POSTGRESQL_VERSION], "${POSTGRESQL_VERSION}", [Specifies the version of PostgreSQL we are linking against]) AC_DEFINE_UNQUOTED([POSTGRESQL_VERSION], "${POSTGRESQL_VERSION}", [Specifies the version of PostgreSQL we are linking against])
AC_DEFINE_UNQUOTED([POSTGRESQL_MAJOR_VERSION], ${POSTGRESQL_MAJOR_VERSION}, [Specifies the version of PostgreSQL we are linking against]) AC_DEFINE_UNQUOTED([POSTGRESQL_MAJOR_VERSION], ${POSTGRESQL_MAJOR_VERSION}, [Specifies the version of PostgreSQL we are linking against])
AC_DEFINE_UNQUOTED([POSTGRESQL_MINOR_VERSION], ${POSTGRESQL_MINOR_VERSION}, [Specifies the version of PostgreSQL we are linking against]) AC_DEFINE_UNQUOTED([POSTGRESQL_MINOR_VERSION], ${POSTGRESQL_MINOR_VERSION}, [Specifies the version of PostgreSQL we are linking against])
AC_DEFINE_UNQUOTED([POSTGRESQL_PATCH_VERSION], ${POSTGRESQL_PATCH_VERSION}, [Specifies the version of PostgreSQL we are linking against]) AC_DEFINE_UNQUOTED([POSTGRESQL_PATCH_VERSION], ${POSTGRESQL_PATCH_VERSION}, [Specifies the version of PostgreSQL we are linking against])
AC_CHECK_LIB([pq], [PQgetvalue],, AC_MSG_ERROR([no usable libpq; please install PostgreSQL devel package or equivalent])) AC_CHECK_LIB([pq], [PQgetvalue],, AC_MSG_ERROR([no usable libpq; please install PostgreSQL devel package or equivalent]))
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
SWITCH_AM_CXXFLAGS="$POSTGRESQL_CXXFLAGS $SWITCH_AM_CXXFLAGS" SWITCH_AM_CXXFLAGS="$POSTGRESQL_CFLAGS $SWITCH_AM_CXXFLAGS"
SWITCH_AM_LDFLAGS="$POSTGRESQL_LDFLAGS $SWITCH_AM_LDFLAGS" SWITCH_AM_LDFLAGS="$POSTGRESQL_LDFLAGS $SWITCH_AM_LDFLAGS"
fi
LIBS="$save_LIBS"
fi fi
AC_ARG_ENABLE(deprecated-core-db-events, AC_ARG_ENABLE(deprecated-core-db-events,