| 1 | dnl ********************************************************************** |
|---|
| 2 | dnl * $Id$ |
|---|
| 3 | dnl * |
|---|
| 4 | dnl * PostGIS - Spatial Types for PostgreSQL |
|---|
| 5 | dnl * WKTRaster - RASTER type support for PostGIS |
|---|
| 6 | dnl * |
|---|
| 7 | dnl * http://postgis.refractions.net |
|---|
| 8 | dnl * Copyright 2008 Mark Cave-Ayland |
|---|
| 9 | dnl * |
|---|
| 10 | dnl * http://www.deimos-space.com |
|---|
| 11 | dnl * http://www.espanavirtual.org/?q=en |
|---|
| 12 | dnl * Contributions made by Jorge Arevalo |
|---|
| 13 | dnl * |
|---|
| 14 | dnl * This is free software; you can redistribute and/or modify it under |
|---|
| 15 | dnl * the terms of the GNU General Public Licence. See the COPYING file. |
|---|
| 16 | dnl * |
|---|
| 17 | dnl ********************************************************************** |
|---|
| 18 | |
|---|
| 19 | AC_INIT() |
|---|
| 20 | AC_CONFIG_HEADERS([wktraster_config.h]) |
|---|
| 21 | AC_CONFIG_MACRO_DIR([macros]) |
|---|
| 22 | |
|---|
| 23 | dnl Invoke libtool: we do this as it is the easiest way to find the PIC |
|---|
| 24 | dnl flags required to build the libs |
|---|
| 25 | AC_PROG_LIBTOOL |
|---|
| 26 | |
|---|
| 27 | dnl |
|---|
| 28 | dnl Compilers |
|---|
| 29 | dnl |
|---|
| 30 | AC_PROG_CC |
|---|
| 31 | AC_PROG_CPP |
|---|
| 32 | AC_PROG_CXX |
|---|
| 33 | |
|---|
| 34 | dnl |
|---|
| 35 | dnl Define PIC flags in PICFLAGS |
|---|
| 36 | dnl (note: this variable is set as part of libtool initialisation above) |
|---|
| 37 | dnl |
|---|
| 38 | PICFLAGS="$lt_prog_compiler_pic" |
|---|
| 39 | AC_SUBST([PICFLAGS]) |
|---|
| 40 | |
|---|
| 41 | dnl |
|---|
| 42 | dnl For GCC enable additional warning flags |
|---|
| 43 | dnl -Wall and -Wmissing-prototypes (using macro included with libtool) |
|---|
| 44 | dnl |
|---|
| 45 | WARNFLAGS="" |
|---|
| 46 | AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -Wall], |
|---|
| 47 | [dummy_cv_Wall], [-Wall], [], [WARNFLAGS="$WARNFLAGS -Wall"], []) |
|---|
| 48 | AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -Wmissing-prototypes], |
|---|
| 49 | [dummy_cv_Wmissing_prototypes], [-Wmissing-prototypes], [], |
|---|
| 50 | [WARNFLAGS="$WARNFLAGS -Wmissing-prototypes"], []) |
|---|
| 51 | AC_SUBST([WARNFLAGS]) |
|---|
| 52 | |
|---|
| 53 | dnl |
|---|
| 54 | dnl Define executable suffix for use with the loader Makefiles |
|---|
| 55 | dnl |
|---|
| 56 | EXESUFFIX="$ac_cv_exeext" |
|---|
| 57 | AC_SUBST([EXESUFFIX]) |
|---|
| 58 | |
|---|
| 59 | dnl |
|---|
| 60 | dnl Version Information imported from Version.config |
|---|
| 61 | dnl |
|---|
| 62 | POSTGIS_RASTER_MAJOR_VERSION=`cat Version.config | grep POSTGIS_RASTER_MAJOR_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'` |
|---|
| 63 | POSTGIS_RASTER_MINOR_VERSION=`cat Version.config | grep POSTGIS_RASTER_MINOR_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'` |
|---|
| 64 | POSTGIS_RASTER_MICRO_VERSION=`cat Version.config | grep POSTGIS_RASTER_MICRO_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'` |
|---|
| 65 | |
|---|
| 66 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_MAJOR_VERSION], ["$POSTGIS_RASTER_MAJOR_VERSION"], [WKTRaster major version]) |
|---|
| 67 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_MINOR_VERSION], ["$POSTGIS_RASTER_MINOR_VERSION"], [WKTRaster minor version]) |
|---|
| 68 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_MICRO_VERSION], ["$POSTGIS_RASTER_MICRO_VERSION"], [WKTRaster micro version]) |
|---|
| 69 | |
|---|
| 70 | AC_SUBST([POSTGIS_RASTER_MAJOR_VERSION]) |
|---|
| 71 | AC_SUBST([POSTGIS_RASTER_MINOR_VERSION]) |
|---|
| 72 | AC_SUBST([POSTGIS_RASTER_MICRO_VERSION]) |
|---|
| 73 | |
|---|
| 74 | dnl |
|---|
| 75 | dnl Search for flex/bison to build the parser |
|---|
| 76 | dnl |
|---|
| 77 | AC_PROG_LEX |
|---|
| 78 | AC_PROG_YACC |
|---|
| 79 | AC_SUBST([LEX]) |
|---|
| 80 | AC_SUBST([YACC]) |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | dnl =========================================================================== |
|---|
| 84 | dnl Find components needed to build documentation |
|---|
| 85 | dnl =========================================================================== |
|---|
| 86 | dnl |
|---|
| 87 | dnl Search for xsltproc which is required for building documentation |
|---|
| 88 | dnl |
|---|
| 89 | |
|---|
| 90 | AC_PATH_PROG([XSLTPROC], [xsltproc], []) |
|---|
| 91 | if test "x$XSLTPROC" = "x"; then |
|---|
| 92 | AC_MSG_WARN([xsltproc is not installed so documentation cannot be built]) |
|---|
| 93 | fi |
|---|
| 94 | |
|---|
| 95 | dnl |
|---|
| 96 | dnl Search for db2pdf which is required for building PDF documentation |
|---|
| 97 | dnl |
|---|
| 98 | |
|---|
| 99 | AC_PATH_PROG([DB2PDF], [db2pdf], []) |
|---|
| 100 | if test "x$DB2PDF" = "x"; then |
|---|
| 101 | AC_MSG_WARN([db2pdf is not installed so PDF documentation cannot be built]) |
|---|
| 102 | fi |
|---|
| 103 | |
|---|
| 104 | dnl |
|---|
| 105 | dnl Search for dblatex which is required for building PDF documentation |
|---|
| 106 | dnl |
|---|
| 107 | |
|---|
| 108 | AC_PATH_PROG([DBLATEX], [dblatex], []) |
|---|
| 109 | if test "x$DBLATEX" = "x"; then |
|---|
| 110 | AC_MSG_WARN([dblatex is not installed so PDF documentation cannot be built]) |
|---|
| 111 | fi |
|---|
| 112 | |
|---|
| 113 | dnl |
|---|
| 114 | dnl Allow the user to specify the location of the html/docbook.xsl stylesheet |
|---|
| 115 | dnl |
|---|
| 116 | |
|---|
| 117 | AC_ARG_WITH([xsldir], |
|---|
| 118 | [AS_HELP_STRING([--with-xsldir=PATH], [specify the directory containing the docbook.xsl stylesheet])], |
|---|
| 119 | [XSLBASE="$withval"], [XSLBASE=""]) |
|---|
| 120 | |
|---|
| 121 | XSLBASE_AUTO="" |
|---|
| 122 | if test "x$XSLBASE" = "x"; then |
|---|
| 123 | dnl If the user did not specify a directory for the docbook |
|---|
| 124 | dnl stylesheet, choose the first directory |
|---|
| 125 | dnl that matches from the following list |
|---|
| 126 | SEARCHPATH=" |
|---|
| 127 | /usr/share/sgml/docbook/xsl-stylesheets |
|---|
| 128 | /usr/share/xml/docbook/stylesheet/nwalsh |
|---|
| 129 | /usr/share/sgml/docbook/stylesheet/xsl/nwalsh |
|---|
| 130 | " |
|---|
| 131 | for p in ${SEARCHPATH}; do |
|---|
| 132 | if test -r "${p}"/html/docbook.xsl; then |
|---|
| 133 | XSLBASE_AUTO="${p}" |
|---|
| 134 | break |
|---|
| 135 | fi |
|---|
| 136 | done |
|---|
| 137 | |
|---|
| 138 | dnl Check to see if the automatically searched paths above located a |
|---|
| 139 | dnl valid Docbook stylesheet |
|---|
| 140 | if test "x$XSLBASE_AUTO" = "x"; then |
|---|
| 141 | AC_MSG_WARN([could not locate Docbook stylesheets required to build the documentation]) |
|---|
| 142 | fi |
|---|
| 143 | else |
|---|
| 144 | dnl The user specified an alternate directory so make sure everything |
|---|
| 145 | dnl looks sensible |
|---|
| 146 | if test ! -d "$XSLBASE"; then |
|---|
| 147 | AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not exist]) |
|---|
| 148 | fi |
|---|
| 149 | |
|---|
| 150 | if test ! -f "$XSLBASE/html/docbook.xsl"; then |
|---|
| 151 | AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not contain the html/docbook.xsl file]) |
|---|
| 152 | fi |
|---|
| 153 | fi |
|---|
| 154 | |
|---|
| 155 | dnl |
|---|
| 156 | dnl If XSLBASE has been set then at this point we know it must be |
|---|
| 157 | dnl valid and so we can just use it. If XSLBASE_AUTO has been set, and XSLBASE |
|---|
| 158 | dnl is empty then a valid stylesheet was found in XSLBASE_AUTO so we |
|---|
| 159 | dnl should use that. Otherwise just continue silently with a blank XSLBASE |
|---|
| 160 | dnl variable which will trigger the error message in the documentation Makefile |
|---|
| 161 | dnl |
|---|
| 162 | |
|---|
| 163 | if test "x$XSLBASE" = "x"; then |
|---|
| 164 | if test ! "x$XSLBASE_AUTO" = "x"; then |
|---|
| 165 | XSLBASE="$XSLBASE_AUTO" |
|---|
| 166 | fi |
|---|
| 167 | fi |
|---|
| 168 | |
|---|
| 169 | AC_SUBST([XSLBASE]) |
|---|
| 170 | |
|---|
| 171 | dnl =========================================================================== |
|---|
| 172 | dnl Detect if various RT DEBUG modes requested |
|---|
| 173 | dnl =========================================================================== |
|---|
| 174 | |
|---|
| 175 | POSTGIS_RASTER_API_DEBUG_CFLAGS="" |
|---|
| 176 | POSTGIS_RASTER_PG_DEBUG_CFLAGS="" |
|---|
| 177 | rt_debug_msg="" |
|---|
| 178 | |
|---|
| 179 | AC_MSG_CHECKING([for low-level RASTER API debug mode]) |
|---|
| 180 | AC_ARG_ENABLE([rtapi-debug], |
|---|
| 181 | AC_HELP_STRING([--enable-rtapi-debug=@<:@yes|no@:>@], |
|---|
| 182 | [enable to debug low-level RASTER API @<:@default=no@:>@] |
|---|
| 183 | ), |
|---|
| 184 | [ |
|---|
| 185 | if test "x$enableval" = "xyes"; then |
|---|
| 186 | rt_api_debug=1 |
|---|
| 187 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_API_DEBUG], [$rt_api_debug], [debug low-level RASTER API]) |
|---|
| 188 | POSTGIS_RASTER_API_DEBUG_CFLAGS="-DPOSTGIS_RASTER_API_DEBUG=$rt_api_debug" |
|---|
| 189 | rt_debug_msg="enabled" |
|---|
| 190 | else |
|---|
| 191 | rt_debug_msg="disabled" |
|---|
| 192 | fi |
|---|
| 193 | ], |
|---|
| 194 | [rt_debug_msg="disabled"] |
|---|
| 195 | ) |
|---|
| 196 | AC_MSG_RESULT([$rt_debug_msg]) |
|---|
| 197 | |
|---|
| 198 | AC_MSG_CHECKING([for PostGIS RASTER activity debug mode]) |
|---|
| 199 | AC_ARG_ENABLE([rtpg-debug], |
|---|
| 200 | AC_HELP_STRING([--enable-rtpg-debug=@<:@yes|no@:>@], |
|---|
| 201 | [enable to debug PostGIS RASTER activity @<:@default=no@:>@] |
|---|
| 202 | ), |
|---|
| 203 | [ |
|---|
| 204 | if test "x$enableval" = "xyes"; then |
|---|
| 205 | rt_pg_debug=1 |
|---|
| 206 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_PG_DEBUG], [$rt_pg_debug], [debug PostGIS RASTER activity]) |
|---|
| 207 | POSTGIS_RASTER_PG_DEBUG_CFLAGS="$POSTGIS_RASTER_PG_DEBUG_CFLAGS -DPOSTGIS_RASTER_PG_DEBUG=$rt_pg_debug" |
|---|
| 208 | rt_debug_msg="enabled" |
|---|
| 209 | else |
|---|
| 210 | rt_debug_msg="disabled" |
|---|
| 211 | fi |
|---|
| 212 | ], |
|---|
| 213 | [rt_debug_msg="disabled"] |
|---|
| 214 | ) |
|---|
| 215 | AC_MSG_RESULT([$rt_debug_msg]) |
|---|
| 216 | |
|---|
| 217 | AC_MSG_CHECKING([for PostGIS RASTER memory activity debug mode]) |
|---|
| 218 | AC_ARG_ENABLE([rtpgmem-debug], |
|---|
| 219 | AC_HELP_STRING([--enable-rtpgmem-debug=@<:@yes|no@:>@], |
|---|
| 220 | [enable to debug PostGIS RASTER memory activity @<:@default=no@:>@] |
|---|
| 221 | ), |
|---|
| 222 | [ |
|---|
| 223 | if test "x$enableval" = "xyes"; then |
|---|
| 224 | rt_pgmem_debug=1 |
|---|
| 225 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_PG_DEBUG_MEM], [$POSTGIS_RASTER_PG_DEBUG_MEM], [debug PostGIS RASTER memory activity]) |
|---|
| 226 | POSTGIS_RASTER_PG_DEBUG_CFLAGS="$POSTGIS_RASTER_PG_DEBUG_CFLAGS -DPOSTGIS_RASTER_PG_DEBUG_MEM=$rt_pgmem_debug" |
|---|
| 227 | rt_debug_msg="enabled" |
|---|
| 228 | else |
|---|
| 229 | rt_debug_msg="disabled" |
|---|
| 230 | fi |
|---|
| 231 | ], |
|---|
| 232 | [rt_debug_msg="disabled"] |
|---|
| 233 | ) |
|---|
| 234 | AC_MSG_RESULT([$rt_debug_msg]) |
|---|
| 235 | |
|---|
| 236 | AC_SUBST([POSTGIS_RASTER_API_DEBUG_CFLAGS]) |
|---|
| 237 | AC_SUBST([POSTGIS_RASTER_PG_DEBUG_CFLAGS]) |
|---|
| 238 | |
|---|
| 239 | dnl =========================================================================== |
|---|
| 240 | dnl Detect CUnit if it is installed (used for unit testing) |
|---|
| 241 | dnl |
|---|
| 242 | dnl Note that we pass any specified CPPFLAGS and LDFLAGS into the Makefile |
|---|
| 243 | dnl as CUnit is the only compile-time dependency that cannot obtain any |
|---|
| 244 | dnl specialised flags using a --with-X parameter, and so we allow this |
|---|
| 245 | dnl information to be passed in if required. |
|---|
| 246 | dnl =========================================================================== |
|---|
| 247 | |
|---|
| 248 | CUNIT_LDFLAGS="" |
|---|
| 249 | AC_CHECK_HEADER([CUnit/CUnit.h], [ |
|---|
| 250 | CUNIT_CPPFLAGS="$CPPFLAGS" |
|---|
| 251 | AC_CHECK_LIB([cunit], [CU_initialize_registry], [CUNIT_LDFLAGS="$LDFLAGS -lcunit"], [AC_MSG_WARN([could not locate CUnit required for liblwgeom unit tests])]) |
|---|
| 252 | ], |
|---|
| 253 | [ |
|---|
| 254 | AC_MSG_WARN([could not locate CUnit required for liblwgeom unit tests]) |
|---|
| 255 | ]) |
|---|
| 256 | |
|---|
| 257 | AC_SUBST([CUNIT_CPPFLAGS]) |
|---|
| 258 | AC_SUBST([CUNIT_LDFLAGS]) |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | dnl =========================================================================== |
|---|
| 262 | dnl Detect iconv if it is installed (used for shp2pgsql encoding conversion |
|---|
| 263 | dnl if available) |
|---|
| 264 | dnl =========================================================================== |
|---|
| 265 | |
|---|
| 266 | HAVE_ICONV_H=0 |
|---|
| 267 | AC_CHECK_HEADER([iconv.h], [HAVE_ICONV_H=1], []) |
|---|
| 268 | |
|---|
| 269 | dnl If we find the header file, try and link against the library |
|---|
| 270 | if test "x$HAVE_ICONV_H" != "x0"; then |
|---|
| 271 | dnl Check for iconv includes as part of libc |
|---|
| 272 | AC_CHECK_LIB([c], [iconv_open], [ICONV_LDFLAGS=-lc HAVE_ICONV=1], []) |
|---|
| 273 | if test "x$HAVE_ICONV" = "x"; then |
|---|
| 274 | dnl If not found, check for iconv included as part of libiconv |
|---|
| 275 | AC_CHECK_LIB([iconv], [iconv_open], [ICONV_LDFLAGS=-liconv HAVE_ICONV=1], []) |
|---|
| 276 | if test "x$HAVE_ICONV" = "x"; then |
|---|
| 277 | dnl If not found, check for Win32 iconv (some of them use a lib prefix for functions within the iconv DLLs) |
|---|
| 278 | AC_CHECK_LIB([iconv], [libiconv_open], [ICONV_LDFLAGS=-liconv HAVE_ICONV=1], []) |
|---|
| 279 | if test "x$HAVE_ICONV" = "x"; then |
|---|
| 280 | dnl No iconv library was found; issue a warning to the console |
|---|
| 281 | AC_MSG_WARN([could not find iconv library: no support for encoding conversion will be included]) |
|---|
| 282 | fi |
|---|
| 283 | fi |
|---|
| 284 | fi |
|---|
| 285 | else |
|---|
| 286 | dnl No iconv header was found; issue a warning to the console |
|---|
| 287 | AC_MSG_WARN([could not find iconv.h header: no support for encoding conversion will be included]) |
|---|
| 288 | fi |
|---|
| 289 | |
|---|
| 290 | |
|---|
| 291 | dnl Only define HAVE_ICONV in postgis_config.h if we detect iconv sucessfully |
|---|
| 292 | if test "x$HAVE_ICONV" != "x"; then |
|---|
| 293 | AC_DEFINE_UNQUOTED([HAVE_ICONV], [$HAVE_ICONV], [Defined if libiconv headers and library are present]) |
|---|
| 294 | fi |
|---|
| 295 | |
|---|
| 296 | AC_SUBST([ICONV_LDFLAGS]) |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | dnl =========================================================================== |
|---|
| 300 | dnl Detect the version of PostgreSQL installed on the system |
|---|
| 301 | dnl =========================================================================== |
|---|
| 302 | |
|---|
| 303 | AC_ARG_WITH([pgconfig], |
|---|
| 304 | [AS_HELP_STRING([--with-pgconfig=FILE], [specify an alternative pg_config file])], |
|---|
| 305 | [PGCONFIG="$withval"], [PGCONFIG=""]) |
|---|
| 306 | |
|---|
| 307 | if test "x$PGCONFIG" = "x"; then |
|---|
| 308 | dnl PGCONFIG was not specified, so search within the current path |
|---|
| 309 | AC_PATH_PROG([PGCONFIG], [pg_config]) |
|---|
| 310 | |
|---|
| 311 | dnl If we couldn't find pg_config, display an error |
|---|
| 312 | if test "x$PGCONFIG" = "x"; then |
|---|
| 313 | 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.]) |
|---|
| 314 | fi |
|---|
| 315 | else |
|---|
| 316 | dnl PGCONFIG was specified; display a message to the user |
|---|
| 317 | if test "x$PGCONFIG" = "xyes"; then |
|---|
| 318 | AC_MSG_ERROR([you must specify a parameter to --with-pgconfig, e.g. --with-pgconfig=/path/to/pg_config]) |
|---|
| 319 | else |
|---|
| 320 | if test -f $PGCONFIG; then |
|---|
| 321 | AC_MSG_RESULT([Using user-specified pg_config file: $PGCONFIG]) |
|---|
| 322 | else |
|---|
| 323 | AC_MSG_ERROR([the user-specified pg_config file $PGCONFIG does not exist]) |
|---|
| 324 | fi |
|---|
| 325 | fi |
|---|
| 326 | fi |
|---|
| 327 | |
|---|
| 328 | |
|---|
| 329 | dnl =========================================================================== |
|---|
| 330 | dnl Ensure that $PG_CONFIG --pgxs points to a valid file. This is because some |
|---|
| 331 | dnl distributions such as Debian also include pg_config as part of libpq-dev |
|---|
| 332 | dnl packages, but don't install the Makefile it points to unless |
|---|
| 333 | dnl the postgresql-server-dev packages are installed :) |
|---|
| 334 | dnl =========================================================================== |
|---|
| 335 | |
|---|
| 336 | PGXS=`$PGCONFIG --pgxs` |
|---|
| 337 | if test ! -f $PGXS; then |
|---|
| 338 | AC_MSG_ERROR([the PGXS Makefile $PGXS cannot be found. Please install the PostgreSQL server development packages and re-run configure.]) |
|---|
| 339 | fi |
|---|
| 340 | |
|---|
| 341 | AC_SUBST([PGXS]) |
|---|
| 342 | |
|---|
| 343 | |
|---|
| 344 | dnl Extract the version information from pg_config |
|---|
| 345 | dnl Note: we extract the major & minor separately, ensure they are numeric, and then combine to give |
|---|
| 346 | dnl the final version. This is to guard against user error... |
|---|
| 347 | PGSQL_MAJOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f1 | sed 's/[[^0-9]]//g'` |
|---|
| 348 | PGSQL_MINOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f2 | sed 's/[[^0-9]]//g'` |
|---|
| 349 | POSTGIS_RASTER_PGSQL_VERSION="$PGSQL_MAJOR_VERSION$PGSQL_MINOR_VERSION" |
|---|
| 350 | |
|---|
| 351 | dnl Ensure that we are using PostgreSQL >= 8.3 |
|---|
| 352 | if test ! "$PGSQL_MAJOR_VERSION" -ge 8; then |
|---|
| 353 | AC_MSG_ERROR([WKTRaster requires PostgreSQL >= 8.3]) |
|---|
| 354 | else |
|---|
| 355 | if test "$PGSQL_MAJOR_VERSION" -eq 8; then |
|---|
| 356 | if test ! "$PGSQL_MINOR_VERSION" -ge 3; then |
|---|
| 357 | AC_MSG_ERROR([WKTRaster requires PostgreSQL >= 8.3]) |
|---|
| 358 | fi |
|---|
| 359 | fi |
|---|
| 360 | fi |
|---|
| 361 | |
|---|
| 362 | dnl Note: We don't need the server-side LDFLAGS or CPPFLAGS because we get these from PGXS |
|---|
| 363 | |
|---|
| 364 | dnl Extract the linker and include flags for the frontend (for programs that use libpq) |
|---|
| 365 | PGSQL_FE_LDFLAGS=-L`$PGCONFIG --libdir`" -lpq" |
|---|
| 366 | PGSQL_FE_CPPFLAGS=-I`$PGCONFIG --includedir` |
|---|
| 367 | |
|---|
| 368 | AC_SUBST([PGSQL_FE_LDFLAGS]) |
|---|
| 369 | AC_SUBST([PGSQL_FE_CPPFLAGS]) |
|---|
| 370 | |
|---|
| 371 | dnl Extract the documentation and man page directories |
|---|
| 372 | PGSQL_DOCDIR=`$PGCONFIG --docdir` |
|---|
| 373 | PGSQL_MANDIR=`$PGCONFIG --mandir` |
|---|
| 374 | |
|---|
| 375 | AC_SUBST([PGSQL_DOCDIR]) |
|---|
| 376 | AC_SUBST([PGSQL_MANDIR]) |
|---|
| 377 | |
|---|
| 378 | dnl Extract the executable directory |
|---|
| 379 | PGSQL_BINDIR=`$PGCONFIG --bindir` |
|---|
| 380 | |
|---|
| 381 | AC_SUBST([PGSQL_BINDIR]) |
|---|
| 382 | |
|---|
| 383 | |
|---|
| 384 | dnl Ensure that we can parse libpq-fe.h |
|---|
| 385 | CPPFLAGS_SAVE="$CPPFLAGS" |
|---|
| 386 | CPPFLAGS="$PGSQL_FE_CPPFLAGS" |
|---|
| 387 | AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([could not find libpq-fe.h])]) |
|---|
| 388 | CPPFLAGS="$CPPFLAGS_SAVE" |
|---|
| 389 | |
|---|
| 390 | dnl Ensure we can link against libpq |
|---|
| 391 | LIBS_SAVE="$LIBS" |
|---|
| 392 | LIBS="$PGSQL_FE_LDFLAGS" |
|---|
| 393 | AC_CHECK_LIB([pq], [PQserverVersion], |
|---|
| 394 | [], |
|---|
| 395 | [AC_MSG_ERROR([could not find libpq])], |
|---|
| 396 | []) |
|---|
| 397 | LIBS="$LIBS_SAVE" |
|---|
| 398 | |
|---|
| 399 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_PGSQL_VERSION], [$POSTGIS_RASTER_PGSQL_VERSION], [PostgreSQL server version]) |
|---|
| 400 | AC_SUBST([POSTGIS_RASTER_PGSQL_VERSION]) |
|---|
| 401 | |
|---|
| 402 | dnl ======================================================================== |
|---|
| 403 | dnl Determine in ENABLE_DEVELOPMENT must be set or not. This enviroment |
|---|
| 404 | dnl var activates the build of some experimental functions. |
|---|
| 405 | dnl |
|---|
| 406 | dnl Another good way of doing this is creating an experimental branch in |
|---|
| 407 | dnl repository... |
|---|
| 408 | dnl ======================================================================== |
|---|
| 409 | ENABLE_DEVELOPMENT_CFLAGS="" |
|---|
| 410 | enable_development_msg="" |
|---|
| 411 | |
|---|
| 412 | AC_MSG_CHECKING([for development mode]) |
|---|
| 413 | AC_ARG_ENABLE([development], |
|---|
| 414 | AC_HELP_STRING([--enable-development=@<:@yes|no@:>@], |
|---|
| 415 | [enable to allow development options @<:@default=no@:>@] |
|---|
| 416 | ), |
|---|
| 417 | [ |
|---|
| 418 | if test "x$enableval" = "xyes"; then |
|---|
| 419 | enable_development=1 |
|---|
| 420 | AC_DEFINE_UNQUOTED([ENABLE_DEVELOPMENT], [$enable_development], [Enable development variable]) |
|---|
| 421 | ENABLE_DEVELOPMENT_CFLAGS="-g -O0" |
|---|
| 422 | enable_development_msg="enabled" |
|---|
| 423 | else |
|---|
| 424 | enable_development_msg="disabled" |
|---|
| 425 | fi |
|---|
| 426 | ], |
|---|
| 427 | [enable_development_msg="disabled"] |
|---|
| 428 | ) |
|---|
| 429 | AC_MSG_RESULT([$enable_development_msg] |
|---|
| 430 | AC_SUBST([ENABLE_DEVELOPMENT_CFLAGS])) |
|---|
| 431 | |
|---|
| 432 | dnl ======================================================================== |
|---|
| 433 | dnl Determine GDAL Support |
|---|
| 434 | dnl |
|---|
| 435 | dnl TODO: Now, --with-gdal can have only 1 value: path to gdal-config. It |
|---|
| 436 | dnl could be useful to allow path to GDAL tree, because the cflags and the |
|---|
| 437 | dnl libs can be obtained from GDAL tree too, apart from gdal-config |
|---|
| 438 | dnl How to get cflags and libs from GDAL tree? |
|---|
| 439 | dnl |
|---|
| 440 | dnl LIBGDAL_CFLAGS="-I$with_gdal/port -I$with_gdal/ogr -I$with_gdal/alg -I$with_gdal/gcore -I$with_gdal/frmts " |
|---|
| 441 | dnl LIBGDAL_LDFLAGS="-L${with_gdal}/.libs -lgdal -L${with_gdal}/ -lgdal" |
|---|
| 442 | dnl ======================================================================== |
|---|
| 443 | dnl not used right now |
|---|
| 444 | USE_GDAL_SOURCE_TREE="no" |
|---|
| 445 | LIBGDAL_CFLAGS="" |
|---|
| 446 | LIBGDAL_LDFLAGS="" |
|---|
| 447 | |
|---|
| 448 | AC_MSG_CHECKING([for GDAL]) |
|---|
| 449 | AC_ARG_WITH([gdal], |
|---|
| 450 | AC_HELP_STRING([--with-gdal=@<:@ARG@:>@],[specify location of gdal-config (ARG=path)]), |
|---|
| 451 | [GDAL_CONFIG="$withval"], [GDAL_CONFIG=""]) |
|---|
| 452 | |
|---|
| 453 | dnl If GDAL_CONFIG path not provided, try to find it |
|---|
| 454 | if test "$GDAL_CONFIG" = ""; then |
|---|
| 455 | GDAL_CONFIG_TMP=`which gdal-config` |
|---|
| 456 | if test "`basename xx/${GDAL_CONFIG_TMP}`" = "gdal-config" ; then |
|---|
| 457 | AC_MSG_RESULT([yes]) |
|---|
| 458 | GDAL_CONFIG=${GDAL_CONFIG_TMP} |
|---|
| 459 | else |
|---|
| 460 | AC_MSG_ERROR([gdal-config not found. Try --with-gdal=<path to gdal-config>]) |
|---|
| 461 | fi |
|---|
| 462 | fi |
|---|
| 463 | |
|---|
| 464 | dnl Check for GDAL options |
|---|
| 465 | AC_MSG_CHECKING([for GDAL version]) |
|---|
| 466 | GDAL_VERSION=`$GDAL_CONFIG --version` |
|---|
| 467 | AC_MSG_RESULT([$GDAL_VERSION]) |
|---|
| 468 | LIBGDAL_CFLAGS=`$GDAL_CONFIG --cflags` |
|---|
| 469 | LIBGDAL_LDFLAGS=`$GDAL_CONFIG --libs` |
|---|
| 470 | AC_SUBST([LIBGDAL_CFLAGS]) |
|---|
| 471 | AC_SUBST([LIBGDAL_LDFLAGS]) |
|---|
| 472 | |
|---|
| 473 | dnl =========================================================================== |
|---|
| 474 | dnl Find postgis sources, as we rely on liblwgeom |
|---|
| 475 | dnl =========================================================================== |
|---|
| 476 | |
|---|
| 477 | POSTGIS_SRCDIR="" |
|---|
| 478 | LIBLWGEOM_CFLAGS="" |
|---|
| 479 | LIBLWGEOM_LDFLAGS="" |
|---|
| 480 | AC_ARG_WITH([postgis-sources], |
|---|
| 481 | AC_HELP_STRING([--with-postgis-sources=DIR], |
|---|
| 482 | [specify location of postgis sources]), |
|---|
| 483 | [POSTGIS_SRCDIR="$withval"], [POSTGIS_SRCDIR=""]) |
|---|
| 484 | |
|---|
| 485 | if test -f "$POSTGIS_SRCDIR/liblwgeom/liblwgeom.h"; then |
|---|
| 486 | LIBLWGEOM_CFLAGS="-I${POSTGIS_SRCDIR}/liblwgeom" |
|---|
| 487 | LIBLWGEOM_LDFLAGS="${POSTGIS_SRCDIR}/liblwgeom/liblwgeom.a" |
|---|
| 488 | else |
|---|
| 489 | AC_MSG_ERROR([${POSTGIS_SRCDIR} does not contain liblwgeom/liblwgeom.h or lwgeom/liblwgeom.h, try --with-postgis-sources=DIR (requires postgis svn version)]) |
|---|
| 490 | fi |
|---|
| 491 | |
|---|
| 492 | AC_SUBST([LIBLWGEOM_CFLAGS]) |
|---|
| 493 | AC_SUBST([LIBLWGEOM_LDFLAGS]) |
|---|
| 494 | AC_SUBST([POSTGIS_SRCDIR]) |
|---|
| 495 | |
|---|
| 496 | |
|---|
| 497 | dnl =========================================================================== |
|---|
| 498 | dnl Detect the version of GEOS installed on the system |
|---|
| 499 | dnl =========================================================================== |
|---|
| 500 | |
|---|
| 501 | AC_ARG_WITH([geos], |
|---|
| 502 | AS_HELP_STRING([--with-geos=@<:@ARG@:>@], |
|---|
| 503 | [specify location of geos-config (ARG=path)]), |
|---|
| 504 | [GEOS_CONFIG="$withval"], [GEOS_CONFIG=""]) |
|---|
| 505 | |
|---|
| 506 | if test "x$GEOS_CONFIG" = "x"; then |
|---|
| 507 | dnl GEOS_CONFIG was not specified, so search within the current path |
|---|
| 508 | AC_PATH_PROG([GEOS_CONFIG], [geos-config]) |
|---|
| 509 | |
|---|
| 510 | dnl If we couldn't find geos-config, display an error |
|---|
| 511 | if test "x$GEOS_CONFIG" = "x"; then |
|---|
| 512 | 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.]) |
|---|
| 513 | fi |
|---|
| 514 | else |
|---|
| 515 | dnl GEOS_CONFIG was specified; display a message to the user |
|---|
| 516 | if test "x$GEOS_CONFIG" = "xyes"; then |
|---|
| 517 | AC_MSG_ERROR([you must specify a parameter to --with-geos, e.g. --with-geos=/path/to/geos-config]) |
|---|
| 518 | else |
|---|
| 519 | if test -f $GEOS_CONFIG; then |
|---|
| 520 | AC_MSG_RESULT([Using user-specified geos-config file: $GEOS_CONFIG]) |
|---|
| 521 | else |
|---|
| 522 | AC_MSG_ERROR([the user-specified geos-config file $GEOS_CONFIG does not exist]) |
|---|
| 523 | fi |
|---|
| 524 | fi |
|---|
| 525 | fi |
|---|
| 526 | |
|---|
| 527 | dnl =========================================================================== |
|---|
| 528 | dnl Define version macros |
|---|
| 529 | dnl |
|---|
| 530 | |
|---|
| 531 | POSTGIS_RASTER_VERSION="$POSTGIS_RASTER_MAJOR_VERSION.$POSTGIS_RASTER_MINOR_VERSION" |
|---|
| 532 | POSTGIS_RASTER_LIB_VERSION="$POSTGIS_RASTER_MAJOR_VERSION.$POSTGIS_RASTER_MINOR_VERSION.$POSTGIS_RASTER_MICRO_VERSION" |
|---|
| 533 | POSTGIS_RASTER_BUILD_DATE=`date -u "+%Y-%m-%d %H:%M:%S"` |
|---|
| 534 | POSTGIS_RASTER_SCRIPTS_VERSION="$POSTGIS_RASTER_LIB_VERSION" |
|---|
| 535 | |
|---|
| 536 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_VERSION], ["$POSTGIS_RASTER_VERSION"], [WKTRaster version]) |
|---|
| 537 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_LIB_VERSION], ["$POSTGIS_RASTER_LIB_VERSION"], [WKTRaster library version]) |
|---|
| 538 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_BUILD_DATE], ["$POSTGIS_RASTER_BUILD_DATE"], [WKTRaster build date]) |
|---|
| 539 | AC_DEFINE_UNQUOTED([POSTGIS_RASTER_SCRIPTS_VERSION], ["$POSTGIS_RASTER_SCRIPTS_VERSION"], [WKTRaster scripts version]) |
|---|
| 540 | |
|---|
| 541 | AC_SUBST([POSTGIS_RASTER_VERSION]) |
|---|
| 542 | AC_SUBST([POSTGIS_RASTER_LIB_VERSION]) |
|---|
| 543 | AC_SUBST([POSTGIS_RASTER_BUILD_DATE]) |
|---|
| 544 | AC_SUBST([POSTGIS_RASTER_SCRIPTS_VERSION]) |
|---|
| 545 | |
|---|
| 546 | |
|---|
| 547 | dnl =========================================================================== |
|---|
| 548 | dnl Other parameters |
|---|
| 549 | dnl |
|---|
| 550 | |
|---|
| 551 | CPPFLAGS="$PGSQL_CPPFLAGS $GEOS_CPPFLAGS $PROJ_CPPFLAGS" |
|---|
| 552 | dnl AC_MSG_RESULT([CPPFLAGS: $CPPFLAGS]) |
|---|
| 553 | |
|---|
| 554 | SHLIB_LINK="$PGSQL_LDFLAGS" |
|---|
| 555 | AC_SUBST([SHLIB_LINK]) |
|---|
| 556 | dnl AC_MSG_RESULT([SHLIB_LINK: $SHLIB_LINK]) |
|---|
| 557 | |
|---|
| 558 | dnl Output the relevant files |
|---|
| 559 | AC_OUTPUT([ |
|---|
| 560 | rt_core/Makefile |
|---|
| 561 | rt_pg/Makefile |
|---|
| 562 | test/Makefile |
|---|
| 563 | test/core/Makefile |
|---|
| 564 | test/regress/Makefile |
|---|
| 565 | scripts/Makefile |
|---|
| 566 | ]) |
|---|
| 567 | |
|---|
| 568 | dnl =========================================================================== |
|---|
| 569 | echo |
|---|
| 570 | echo "Version: ${POSTGIS_RASTER_LIB_VERSION}" |
|---|
| 571 | echo "Build date: ${POSTGIS_RASTER_BUILD_DATE}" |
|---|
| 572 | echo |
|---|
| 573 | echo "Run make to build WKT Raster extension" |
|---|