-# 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])