dnl ********************************************************************** dnl * $Id$ dnl * dnl * PostGIS - Spatial Types for PostgreSQL dnl * WKTRaster - RASTER type support for PostGIS dnl * dnl * http://postgis.refractions.net dnl * Copyright 2008 Mark Cave-Ayland dnl * dnl * http://www.deimos-space.com dnl * http://www.espanavirtual.org/?q=en dnl * Contributions made by Jorge Arevalo dnl * dnl * This is free software; you can redistribute and/or modify it under dnl * the terms of the GNU General Public Licence. See the COPYING file. dnl * dnl ********************************************************************** AC_INIT() AC_CONFIG_HEADERS([wktraster_config.h]) AC_CONFIG_MACRO_DIR([macros]) dnl Invoke libtool: we do this as it is the easiest way to find the PIC dnl flags required to build the libs AC_PROG_LIBTOOL dnl dnl Compilers dnl AC_PROG_CC AC_PROG_CPP AC_PROG_CXX dnl dnl Define PIC flags in PICFLAGS dnl (note: this variable is set as part of libtool initialisation above) dnl PICFLAGS="$lt_prog_compiler_pic" AC_SUBST([PICFLAGS]) dnl dnl For GCC enable additional warning flags dnl -Wall and -Wmissing-prototypes (using macro included with libtool) dnl WARNFLAGS="" AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -Wall], [dummy_cv_Wall], [-Wall], [], [WARNFLAGS="$WARNFLAGS -Wall"], []) AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -Wmissing-prototypes], [dummy_cv_Wmissing_prototypes], [-Wmissing-prototypes], [], [WARNFLAGS="$WARNFLAGS -Wmissing-prototypes"], []) AC_SUBST([WARNFLAGS]) dnl dnl Define executable suffix for use with the loader Makefiles dnl EXESUFFIX="$ac_cv_exeext" AC_SUBST([EXESUFFIX]) dnl dnl Version Information imported from Version.config dnl POSTGIS_RASTER_MAJOR_VERSION=`cat Version.config | grep POSTGIS_RASTER_MAJOR_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'` POSTGIS_RASTER_MINOR_VERSION=`cat Version.config | grep POSTGIS_RASTER_MINOR_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'` POSTGIS_RASTER_MICRO_VERSION=`cat Version.config | grep POSTGIS_RASTER_MICRO_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'` AC_DEFINE_UNQUOTED([POSTGIS_RASTER_MAJOR_VERSION], ["$POSTGIS_RASTER_MAJOR_VERSION"], [WKTRaster major version]) AC_DEFINE_UNQUOTED([POSTGIS_RASTER_MINOR_VERSION], ["$POSTGIS_RASTER_MINOR_VERSION"], [WKTRaster minor version]) AC_DEFINE_UNQUOTED([POSTGIS_RASTER_MICRO_VERSION], ["$POSTGIS_RASTER_MICRO_VERSION"], [WKTRaster micro version]) AC_SUBST([POSTGIS_RASTER_MAJOR_VERSION]) AC_SUBST([POSTGIS_RASTER_MINOR_VERSION]) AC_SUBST([POSTGIS_RASTER_MICRO_VERSION]) dnl dnl Search for flex/bison to build the parser dnl AC_PROG_LEX AC_PROG_YACC AC_SUBST([LEX]) AC_SUBST([YACC]) dnl =========================================================================== dnl Find components needed to build documentation dnl =========================================================================== dnl dnl Search for xsltproc which is required for building documentation dnl AC_PATH_PROG([XSLTPROC], [xsltproc], []) if test "x$XSLTPROC" = "x"; then AC_MSG_WARN([xsltproc is not installed so documentation cannot be built]) fi dnl dnl Search for db2pdf which is required for building PDF documentation dnl AC_PATH_PROG([DB2PDF], [db2pdf], []) if test "x$DB2PDF" = "x"; then AC_MSG_WARN([db2pdf is not installed so PDF documentation cannot be built]) fi dnl dnl Search for dblatex which is required for building PDF documentation dnl AC_PATH_PROG([DBLATEX], [dblatex], []) if test "x$DBLATEX" = "x"; then AC_MSG_WARN([dblatex is not installed so PDF documentation cannot be built]) fi dnl dnl Allow the user to specify the location of the html/docbook.xsl stylesheet dnl AC_ARG_WITH([xsldir], [AS_HELP_STRING([--with-xsldir=PATH], [specify the directory containing the docbook.xsl stylesheet])], [XSLBASE="$withval"], [XSLBASE=""]) XSLBASE_AUTO="" if test "x$XSLBASE" = "x"; then dnl If the user did not specify a directory for the docbook dnl stylesheet, choose the first directory dnl that matches from the following list SEARCHPATH=" /usr/share/sgml/docbook/xsl-stylesheets /usr/share/xml/docbook/stylesheet/nwalsh /usr/share/sgml/docbook/stylesheet/xsl/nwalsh " for p in ${SEARCHPATH}; do if test -r "${p}"/html/docbook.xsl; then XSLBASE_AUTO="${p}" break fi done dnl Check to see if the automatically searched paths above located a dnl valid Docbook stylesheet if test "x$XSLBASE_AUTO" = "x"; then AC_MSG_WARN([could not locate Docbook stylesheets required to build the documentation]) fi else dnl The user specified an alternate directory so make sure everything dnl looks sensible if test ! -d "$XSLBASE"; then AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not exist]) fi if test ! -f "$XSLBASE/html/docbook.xsl"; then AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not contain the html/docbook.xsl file]) fi fi dnl dnl If XSLBASE has been set then at this point we know it must be dnl valid and so we can just use it. If XSLBASE_AUTO has been set, and XSLBASE dnl is empty then a valid stylesheet was found in XSLBASE_AUTO so we dnl should use that. Otherwise just continue silently with a blank XSLBASE dnl variable which will trigger the error message in the documentation Makefile dnl if test "x$XSLBASE" = "x"; then if test ! "x$XSLBASE_AUTO" = "x"; then XSLBASE="$XSLBASE_AUTO" fi fi AC_SUBST([XSLBASE]) dnl =========================================================================== dnl Detect if various RT DEBUG modes requested dnl =========================================================================== POSTGIS_RASTER_API_DEBUG_CFLAGS="" POSTGIS_RASTER_PG_DEBUG_CFLAGS="" rt_debug_msg="" AC_MSG_CHECKING([for low-level RASTER API debug mode]) AC_ARG_ENABLE([rtapi-debug], AC_HELP_STRING([--enable-rtapi-debug=@<:@yes|no@:>@], [enable to debug low-level RASTER API @<:@default=no@:>@] ), [ if test "x$enableval" = "xyes"; then rt_api_debug=1 AC_DEFINE_UNQUOTED([POSTGIS_RASTER_API_DEBUG], [$rt_api_debug], [debug low-level RASTER API]) POSTGIS_RASTER_API_DEBUG_CFLAGS="-DPOSTGIS_RASTER_API_DEBUG=$rt_api_debug" rt_debug_msg="enabled" else rt_debug_msg="disabled" fi ], [rt_debug_msg="disabled"] ) AC_MSG_RESULT([$rt_debug_msg]) AC_MSG_CHECKING([for PostGIS RASTER activity debug mode]) AC_ARG_ENABLE([rtpg-debug], AC_HELP_STRING([--enable-rtpg-debug=@<:@yes|no@:>@], [enable to debug PostGIS RASTER activity @<:@default=no@:>@] ), [ if test "x$enableval" = "xyes"; then rt_pg_debug=1 AC_DEFINE_UNQUOTED([POSTGIS_RASTER_PG_DEBUG], [$rt_pg_debug], [debug PostGIS RASTER activity]) POSTGIS_RASTER_PG_DEBUG_CFLAGS="$POSTGIS_RASTER_PG_DEBUG_CFLAGS -DPOSTGIS_RASTER_PG_DEBUG=$rt_pg_debug" rt_debug_msg="enabled" else rt_debug_msg="disabled" fi ], [rt_debug_msg="disabled"] ) AC_MSG_RESULT([$rt_debug_msg]) AC_MSG_CHECKING([for PostGIS RASTER memory activity debug mode]) AC_ARG_ENABLE([rtpgmem-debug], AC_HELP_STRING([--enable-rtpgmem-debug=@<:@yes|no@:>@], [enable to debug PostGIS RASTER memory activity @<:@default=no@:>@] ), [ if test "x$enableval" = "xyes"; then rt_pgmem_debug=1 AC_DEFINE_UNQUOTED([POSTGIS_RASTER_PG_DEBUG_MEM], [$POSTGIS_RASTER_PG_DEBUG_MEM], [debug PostGIS RASTER memory activity]) POSTGIS_RASTER_PG_DEBUG_CFLAGS="$POSTGIS_RASTER_PG_DEBUG_CFLAGS -DPOSTGIS_RASTER_PG_DEBUG_MEM=$rt_pgmem_debug" rt_debug_msg="enabled" else rt_debug_msg="disabled" fi ], [rt_debug_msg="disabled"] ) AC_MSG_RESULT([$rt_debug_msg]) AC_SUBST([POSTGIS_RASTER_API_DEBUG_CFLAGS]) AC_SUBST([POSTGIS_RASTER_PG_DEBUG_CFLAGS]) dnl =========================================================================== dnl Detect CUnit if it is installed (used for unit testing) dnl dnl Note that we pass any specified CPPFLAGS and LDFLAGS into the Makefile dnl as CUnit is the only compile-time dependency that cannot obtain any dnl specialised flags using a --with-X parameter, and so we allow this dnl information to be passed in if required. dnl =========================================================================== CUNIT_LDFLAGS="" AC_CHECK_HEADER([CUnit/CUnit.h], [ CUNIT_CPPFLAGS="$CPPFLAGS" AC_CHECK_LIB([cunit], [CU_initialize_registry], [CUNIT_LDFLAGS="$LDFLAGS -lcunit"], [AC_MSG_WARN([could not locate CUnit required for liblwgeom unit tests])]) ], [ AC_MSG_WARN([could not locate CUnit required for liblwgeom unit tests]) ]) AC_SUBST([CUNIT_CPPFLAGS]) AC_SUBST([CUNIT_LDFLAGS]) dnl =========================================================================== dnl Detect iconv if it is installed (used for shp2pgsql encoding conversion dnl if available) dnl =========================================================================== HAVE_ICONV_H=0 AC_CHECK_HEADER([iconv.h], [HAVE_ICONV_H=1], []) dnl If we find the header file, try and link against the library if test "x$HAVE_ICONV_H" != "x0"; then dnl Check for iconv includes as part of libc AC_CHECK_LIB([c], [iconv_open], [ICONV_LDFLAGS=-lc HAVE_ICONV=1], []) if test "x$HAVE_ICONV" = "x"; then dnl If not found, check for iconv included as part of libiconv AC_CHECK_LIB([iconv], [iconv_open], [ICONV_LDFLAGS=-liconv HAVE_ICONV=1], []) if test "x$HAVE_ICONV" = "x"; then dnl If not found, check for Win32 iconv (some of them use a lib prefix for functions within the iconv DLLs) AC_CHECK_LIB([iconv], [libiconv_open], [ICONV_LDFLAGS=-liconv HAVE_ICONV=1], []) if test "x$HAVE_ICONV" = "x"; then dnl No iconv library was found; issue a warning to the console AC_MSG_WARN([could not find iconv library: no support for encoding conversion will be included]) fi fi fi else dnl No iconv header was found; issue a warning to the console AC_MSG_WARN([could not find iconv.h header: no support for encoding conversion will be included]) fi dnl Only define HAVE_ICONV in postgis_config.h if we detect iconv sucessfully if test "x$HAVE_ICONV" != "x"; then AC_DEFINE_UNQUOTED([HAVE_ICONV], [$HAVE_ICONV], [Defined if libiconv headers and library are present]) fi AC_SUBST([ICONV_LDFLAGS]) dnl =========================================================================== dnl Detect the version of PostgreSQL installed on the system dnl =========================================================================== AC_ARG_WITH([pgconfig], [AS_HELP_STRING([--with-pgconfig=FILE], [specify an alternative pg_config file])], [PGCONFIG="$withval"], [PGCONFIG=""]) if test "x$PGCONFIG" = "x"; then dnl PGCONFIG was not specified, so search within the current path AC_PATH_PROG([PGCONFIG], [pg_config]) dnl If we couldn't find pg_config, display an error if test "x$PGCONFIG" = "x"; then AC_MSG_ERROR([could not find pg_config within the current path. You may need to try re-running configure with a --with-pgconfig parameter.]) fi else dnl PGCONFIG was specified; display a message to the user if test "x$PGCONFIG" = "xyes"; then AC_MSG_ERROR([you must specify a parameter to --with-pgconfig, e.g. --with-pgconfig=/path/to/pg_config]) else if test -f $PGCONFIG; then AC_MSG_RESULT([Using user-specified pg_config file: $PGCONFIG]) else AC_MSG_ERROR([the user-specified pg_config file $PGCONFIG does not exist]) fi fi fi dnl =========================================================================== dnl Ensure that $PG_CONFIG --pgxs points to a valid file. This is because some dnl distributions such as Debian also include pg_config as part of libpq-dev dnl packages, but don't install the Makefile it points to unless dnl the postgresql-server-dev packages are installed :) dnl =========================================================================== PGXS=`$PGCONFIG --pgxs` if test ! -f $PGXS; then AC_MSG_ERROR([the PGXS Makefile $PGXS cannot be found. Please install the PostgreSQL server development packages and re-run configure.]) fi AC_SUBST([PGXS]) dnl Extract the version information from pg_config dnl Note: we extract the major & minor separately, ensure they are numeric, and then combine to give dnl the final version. This is to guard against user error... PGSQL_MAJOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f1 | sed 's/[[^0-9]]//g'` PGSQL_MINOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f2 | sed 's/[[^0-9]]//g'` POSTGIS_RASTER_PGSQL_VERSION="$PGSQL_MAJOR_VERSION$PGSQL_MINOR_VERSION" dnl Ensure that we are using PostgreSQL >= 8.3 if test ! "$PGSQL_MAJOR_VERSION" -ge 8; then AC_MSG_ERROR([WKTRaster requires PostgreSQL >= 8.3]) else if test "$PGSQL_MAJOR_VERSION" -eq 8; then if test ! "$PGSQL_MINOR_VERSION" -ge 3; then AC_MSG_ERROR([WKTRaster requires PostgreSQL >= 8.3]) fi fi fi dnl Note: We don't need the server-side LDFLAGS or CPPFLAGS because we get these from PGXS dnl Extract the linker and include flags for the frontend (for programs that use libpq) PGSQL_FE_LDFLAGS=-L`$PGCONFIG --libdir`" -lpq" PGSQL_FE_CPPFLAGS=-I`$PGCONFIG --includedir` AC_SUBST([PGSQL_FE_LDFLAGS]) AC_SUBST([PGSQL_FE_CPPFLAGS]) dnl Extract the documentation and man page directories PGSQL_DOCDIR=`$PGCONFIG --docdir` PGSQL_MANDIR=`$PGCONFIG --mandir` AC_SUBST([PGSQL_DOCDIR]) AC_SUBST([PGSQL_MANDIR]) dnl Extract the executable directory PGSQL_BINDIR=`$PGCONFIG --bindir` AC_SUBST([PGSQL_BINDIR]) dnl Ensure that we can parse libpq-fe.h CPPFLAGS_SAVE="$CPPFLAGS" CPPFLAGS="$PGSQL_FE_CPPFLAGS" AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([could not find libpq-fe.h])]) CPPFLAGS="$CPPFLAGS_SAVE" dnl Ensure we can link against libpq LIBS_SAVE="$LIBS" LIBS="$PGSQL_FE_LDFLAGS" AC_CHECK_LIB([pq], [PQserverVersion], [], [AC_MSG_ERROR([could not find libpq])], []) LIBS="$LIBS_SAVE" AC_DEFINE_UNQUOTED([POSTGIS_RASTER_PGSQL_VERSION], [$POSTGIS_RASTER_PGSQL_VERSION], [PostgreSQL server version]) AC_SUBST([POSTGIS_RASTER_PGSQL_VERSION]) dnl ======================================================================== dnl Determine in ENABLE_DEVELOPMENT must be set or not. This enviroment dnl var activates the build of some experimental functions. dnl dnl Another good way of doing this is creating an experimental branch in dnl repository... dnl ======================================================================== ENABLE_DEVELOPMENT_CFLAGS="" enable_development_msg="" AC_MSG_CHECKING([for development mode]) AC_ARG_ENABLE([development], AC_HELP_STRING([--enable-development=@<:@yes|no@:>@], [enable to allow development options @<:@default=no@:>@] ), [ if test "x$enableval" = "xyes"; then enable_development=1 AC_DEFINE_UNQUOTED([ENABLE_DEVELOPMENT], [$enable_development], [Enable development variable]) ENABLE_DEVELOPMENT_CFLAGS="-g -O0" enable_development_msg="enabled" else enable_development_msg="disabled" fi ], [enable_development_msg="disabled"] ) AC_MSG_RESULT([$enable_development_msg] AC_SUBST([ENABLE_DEVELOPMENT_CFLAGS])) dnl ======================================================================== dnl Determine GDAL Support dnl dnl TODO: Now, --with-gdal can have only 1 value: path to gdal-config. It dnl could be useful to allow path to GDAL tree, because the cflags and the dnl libs can be obtained from GDAL tree too, apart from gdal-config dnl How to get cflags and libs from GDAL tree? dnl dnl LIBGDAL_CFLAGS="-I$with_gdal/port -I$with_gdal/ogr -I$with_gdal/alg -I$with_gdal/gcore -I$with_gdal/frmts " dnl LIBGDAL_LDFLAGS="-L${with_gdal}/.libs -lgdal -L${with_gdal}/ -lgdal" dnl ======================================================================== dnl not used right now USE_GDAL_SOURCE_TREE="no" LIBGDAL_CFLAGS="" LIBGDAL_LDFLAGS="" AC_MSG_CHECKING([for GDAL]) AC_ARG_WITH([gdal], AC_HELP_STRING([--with-gdal=@<:@ARG@:>@],[specify location of gdal-config (ARG=path)]), [GDAL_CONFIG="$withval"], [GDAL_CONFIG=""]) dnl If GDAL_CONFIG path not provided, try to find it if test "$GDAL_CONFIG" = ""; then GDAL_CONFIG_TMP=`which gdal-config` if test "`basename xx/${GDAL_CONFIG_TMP}`" = "gdal-config" ; then AC_MSG_RESULT([yes]) GDAL_CONFIG=${GDAL_CONFIG_TMP} else AC_MSG_ERROR([gdal-config not found. Try --with-gdal=]) fi fi dnl Check for GDAL options AC_MSG_CHECKING([for GDAL version]) GDAL_VERSION=`$GDAL_CONFIG --version` AC_MSG_RESULT([$GDAL_VERSION]) LIBGDAL_CFLAGS=`$GDAL_CONFIG --cflags` LIBGDAL_LDFLAGS=`$GDAL_CONFIG --libs` AC_SUBST([LIBGDAL_CFLAGS]) AC_SUBST([LIBGDAL_LDFLAGS]) dnl =========================================================================== dnl Find postgis sources, as we rely on liblwgeom dnl =========================================================================== POSTGIS_SRCDIR="" LIBLWGEOM_CFLAGS="" LIBLWGEOM_LDFLAGS="" AC_ARG_WITH([postgis-sources], AC_HELP_STRING([--with-postgis-sources=DIR], [specify location of postgis sources]), [POSTGIS_SRCDIR="$withval"], [POSTGIS_SRCDIR=""]) if test -f "$POSTGIS_SRCDIR/liblwgeom/liblwgeom.h"; then LIBLWGEOM_CFLAGS="-I${POSTGIS_SRCDIR}/liblwgeom" LIBLWGEOM_LDFLAGS="${POSTGIS_SRCDIR}/liblwgeom/liblwgeom.a" else AC_MSG_ERROR([${POSTGIS_SRCDIR} does not contain liblwgeom/liblwgeom.h or lwgeom/liblwgeom.h, try --with-postgis-sources=DIR (requires postgis svn version)]) fi AC_SUBST([LIBLWGEOM_CFLAGS]) AC_SUBST([LIBLWGEOM_LDFLAGS]) AC_SUBST([POSTGIS_SRCDIR]) dnl =========================================================================== dnl Detect the version of GEOS installed on the system dnl =========================================================================== AC_ARG_WITH([geos], AS_HELP_STRING([--with-geos=@<:@ARG@:>@], [specify location of geos-config (ARG=path)]), [GEOS_CONFIG="$withval"], [GEOS_CONFIG=""]) if test "x$GEOS_CONFIG" = "x"; then dnl GEOS_CONFIG was not specified, so search within the current path AC_PATH_PROG([GEOS_CONFIG], [geos-config]) dnl If we couldn't find geos-config, display an error if test "x$GEOS_CONFIG" = "x"; then AC_MSG_ERROR([could not find geos-config within the current path. You may need to try re-running configure with a --with-geos parameter.]) fi else dnl GEOS_CONFIG was specified; display a message to the user if test "x$GEOS_CONFIG" = "xyes"; then AC_MSG_ERROR([you must specify a parameter to --with-geos, e.g. --with-geos=/path/to/geos-config]) else if test -f $GEOS_CONFIG; then AC_MSG_RESULT([Using user-specified geos-config file: $GEOS_CONFIG]) else AC_MSG_ERROR([the user-specified geos-config file $GEOS_CONFIG does not exist]) fi fi fi dnl =========================================================================== dnl Define version macros dnl POSTGIS_RASTER_VERSION="$POSTGIS_RASTER_MAJOR_VERSION.$POSTGIS_RASTER_MINOR_VERSION" POSTGIS_RASTER_LIB_VERSION="$POSTGIS_RASTER_MAJOR_VERSION.$POSTGIS_RASTER_MINOR_VERSION.$POSTGIS_RASTER_MICRO_VERSION" POSTGIS_RASTER_BUILD_DATE=`date -u "+%Y-%m-%d %H:%M:%S"` POSTGIS_RASTER_SCRIPTS_VERSION="$POSTGIS_RASTER_LIB_VERSION" AC_DEFINE_UNQUOTED([POSTGIS_RASTER_VERSION], ["$POSTGIS_RASTER_VERSION"], [WKTRaster version]) AC_DEFINE_UNQUOTED([POSTGIS_RASTER_LIB_VERSION], ["$POSTGIS_RASTER_LIB_VERSION"], [WKTRaster library version]) AC_DEFINE_UNQUOTED([POSTGIS_RASTER_BUILD_DATE], ["$POSTGIS_RASTER_BUILD_DATE"], [WKTRaster build date]) AC_DEFINE_UNQUOTED([POSTGIS_RASTER_SCRIPTS_VERSION], ["$POSTGIS_RASTER_SCRIPTS_VERSION"], [WKTRaster scripts version]) AC_SUBST([POSTGIS_RASTER_VERSION]) AC_SUBST([POSTGIS_RASTER_LIB_VERSION]) AC_SUBST([POSTGIS_RASTER_BUILD_DATE]) AC_SUBST([POSTGIS_RASTER_SCRIPTS_VERSION]) dnl =========================================================================== dnl Other parameters dnl CPPFLAGS="$PGSQL_CPPFLAGS $GEOS_CPPFLAGS $PROJ_CPPFLAGS" dnl AC_MSG_RESULT([CPPFLAGS: $CPPFLAGS]) SHLIB_LINK="$PGSQL_LDFLAGS" AC_SUBST([SHLIB_LINK]) dnl AC_MSG_RESULT([SHLIB_LINK: $SHLIB_LINK]) dnl Output the relevant files AC_OUTPUT([ rt_core/Makefile rt_pg/Makefile test/Makefile test/core/Makefile test/regress/Makefile scripts/Makefile ]) dnl =========================================================================== echo echo "Version: ${POSTGIS_RASTER_LIB_VERSION}" echo "Build date: ${POSTGIS_RASTER_BUILD_DATE}" echo echo "Run make to build WKT Raster extension"