dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/gcm_input/message.h)
-AM_INIT_AUTOMAKE(GnuCoMo, 0.0.8)
+AM_INIT_AUTOMAKE(GnuCoMo, 0.0.9)
dnl Checks for programs.
XML_LFLAGS=`$XML_CONFIG --libs`
LIBS="$LIBS $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS"
-LDFLAGS="$LDFLAGS -L/usr/local/lib $XML_LFLAGS"
+LIBS="$LIBS -L/usr/local/lib $XML_LFLAGS"
CFLAGS="$CFLAGS $X_CFLAGS $XML_CFLAGS "
-CXXFLAGS="$CXXFLAGS $X_CFLAGS $XML_CFLAGS"
+CXXFLAGS="$CXXFLAGS -Wno-deprecated $X_CFLAGS $XML_CFLAGS"
-AC_HAVE_LIBRARY(pqxx)
AC_CHECK_LIB(AXE, main, , AC_MSG_ERROR(AXE Library is not installed))
#AC_CHECK_LIB(X11, XOpenDisplay)
#AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData)
#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
+)
+
+AC_SUBST(with_postgres_lib)
+AC_SUBST(with_postgres_include)
+POSTGRES_LIB="-L${with_postgres_lib} -R${with_postgres_lib} -lpq"
+AC_SUBST(POSTGRES_LIB)
+POSTGRES_INCLUDE="-I${with_postgres_include}"
+AC_SUBST(POSTGRES_INCLUDE)
+
+# Checks for libraries.
+AC_CHECK_LIB([pq], [PQexec], [], [AC_MSG_ERROR([Failed to find a suitable libpq.
+
+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"
#
# There is no convenient way to detect libpqxx, so we'll
# use fixed paths for the time being.
CXXFLAGS="$CXXFLAGS -I/usr/local/pqxx/include"
-LDFLAGS="$LDFLAGS -L/usr/local/pqxx/lib -lpqxx"
+LIBS="$LIBS -L/usr/local/pqxx/lib -lpqxx"
dnl Checks for header files.
AC_HEADER_DIRENT