Skip to content

Instantly share code, notes, and snippets.

@Habbie
Created April 22, 2013 11:46
Show Gist options
  • Save Habbie/5434137 to your computer and use it in GitHub Desktop.
Save Habbie/5434137 to your computer and use it in GitHub Desktop.
Index: configure.in
===================================================================
--- configure.in (revision 930)
+++ configure.in (working copy)
@@ -294,62 +294,21 @@
if test "$needpgsql"
then
- AC_ARG_WITH(pgsql,
- [ --with-pgsql=<path> root directory path of PgSQL installation],
- [PGSQL_lib_check="$withval/lib/pgsql $with_pgsql/lib"
- PGSQL_inc_check="$withval/include/pgsql"],
- [PGSQL_lib_check="/usr/local/pgsql/lib/pgsql /usr/local/lib/pgsql /opt/pgsql/lib/pgsql /usr/lib/pgsql /usr/local/pgsql/lib /usr/local/lib /opt/pgsql/lib /usr/lib"
- PGSQL_inc_check="/usr/local/pgsql/include/pgsql /usr/local/include/postgresql/ /usr/local/include /opt/pgsql/include/pgsql /opt/pgsql/include /usr/include/pgsql/ /usr/include/postgresql"])
- AC_ARG_WITH(pgsql-lib,
- [ --with-pgsql-lib=<path> directory path of PgSQL library installation],
- [PGSQL_lib_check="$withval/lib/pgsql $withval/pgsql $withval"])
- AC_ARG_WITH(pgsql-includes,
- [ --with-pgsql-includes=<path>
- directory path of PgSQL header installation],
- [PGSQL_inc_check="$withval/include/pgsql $withval/pgsql $withval"])
- AC_MSG_CHECKING([for PgSQL library directory])
- PGSQL_libdir=
- for m in $PGSQL_lib_check; do
- if test -d "$m" && \
- (test -f "$m/libpq.a" || test -f "$m/libpq++.a")
- then
- PGSQL_libdir=$m
- break
- fi
- done
- if test -z "$PGSQL_libdir"; then
- AC_MSG_ERROR([Didn't find the pgsql library dir in '$PGSQL_lib_check'])
- fi
- case "$PGSQL_libdir" in
- /usr/lib ) PGSQL_lib="" ;;
- /* ) PGSQL_lib="-L$PGSQL_libdir -Wl,-rpath,$PGSQL_libdir"
- LDFLAGS="$PGSQL_lib $LDFLAGS"
- ;;
- * ) AC_MSG_ERROR([The PgSQL library directory ($PGSQL_libdir) must be an absolute path.]) ;;
- esac
+ AC_ARG_VAR([PG_CONFIG], [Path to PostgreSQLs pg_config(1)])
+ AC_PATH_PROG([PG_CONFIG], [pg_config],
+ [AC_MSG_ERROR([pg_config cannot be found.])])
- AC_SUBST(PGSQL_lib)
+ PGSQL_libdir="`$PG_CONFIG --libdir | sed s/\'//g`"
+ PGSQL_ldflags="`$PG_CONFIG --ldflags | sed s/\'//g`"
+ LDFLAGS="-L$PGSQL_libdir $PGSQL_ldflags $LDFLAGS"
+
+ AC_MSG_CHECKING([for PostgreSQL library directory])
AC_MSG_RESULT([$PGSQL_libdir])
- AC_MSG_CHECKING([for PgSQL include directory])
- PGSQL_incdir=
- for m in $PGSQL_inc_check; do
- if test -d "$m" && test -f "$m/libpq-fe.h"
- then
- PGSQL_incdir=$m
- break
- fi
- done
- if test -z "$PGSQL_incdir"; then
- AC_MSG_ERROR([Didn't find the PgSQL include dir in '$PGSQL_inc_check'])
- fi
- case "$PGSQL_incdir" in
- /* ) ;;
- * ) AC_MSG_ERROR([The PgSQL include directory ($PGSQL_incdir) must be an absolute path.]) ;;
- esac
+
+ PGSQL_incdir="`$PG_CONFIG --includedir | sed s/\'//g`"
AC_SUBST(PGSQL_incdir)
+ AC_MSG_CHECKING([for PostgreSQL include directory])
AC_MSG_RESULT([$PGSQL_incdir])
-
-# LIBS="$LIBS -lpq++ -lpq -lssl -lcrypt -lcrypto"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment