source: trunk/configure.ac @ 5148

Last change on this file since 5148 was 5148, checked in by nicklas, 6 years ago

Fix for make check on MingW #389

File size: 24.3 KB
Line 
1dnl **********************************************************************
2dnl * $Id: configure.ac 2797 2008-05-31 09:56:44Z mcayland $
3dnl *
4dnl * PostGIS - Spatial Types for PostgreSQL
5dnl * http://postgis.refractions.net
6dnl * Copyright 2008 Mark Cave-Ayland
7dnl *
8dnl * This is free software; you can redistribute and/or modify it under
9dnl * the terms of the GNU General Public Licence. See the COPYING file.
10dnl *
11dnl **********************************************************************
12
13AC_INIT()
14AC_CONFIG_HEADERS([postgis_config.h])
15AC_CONFIG_MACRO_DIR([macros])
16
17
18dnl Invoke libtool: we do this as it is the easiest way to find the PIC
19dnl flags required to build liblwgeom
20AC_PROG_LIBTOOL
21
22dnl
23dnl Compilers
24dnl
25AC_PROG_CC
26AC_PROG_CPP
27AC_PROG_CXX
28
29dnl
30dnl Define PIC flags in PICFLAGS (note: this variable is set as part of libtool initialisation above)
31dnl
32PICFLAGS="$lt_prog_compiler_pic"
33AC_SUBST([PICFLAGS])
34
35dnl
36dnl For GCC enable additional warning flags -Wall and -Wmissing-prototypes (using macro included with libtool)
37dnl
38WARNFLAGS=""
39AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -Wall], [_cv_wall], [-Wall], [], [WARNFLAGS="$WARNFLAGS -Wall"], [])
40AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -Wmissing-prototypes], [_cv_misprot], [-Wmissing-prototypes], [], [WARNFLAGS="$WARNFLAGS -Wmissing-prototypes"], [])
41AC_SUBST([WARNFLAGS])
42
43dnl
44dnl Define executable suffix for use with the loader Makefiles
45dnl
46EXESUFFIX="$ac_cv_exeext"
47AC_SUBST([EXESUFFIX])
48
49dnl
50dnl Version Information imported from Version.config
51dnl
52POSTGIS_MAJOR_VERSION=`cat Version.config | grep POSTGIS_MAJOR_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'`
53POSTGIS_MINOR_VERSION=`cat Version.config | grep POSTGIS_MINOR_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'`
54POSTGIS_MICRO_VERSION=`cat Version.config | grep POSTGIS_MICRO_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'`
55
56AC_DEFINE_UNQUOTED([POSTGIS_MAJOR_VERSION], ["$POSTGIS_MAJOR_VERSION"], [PostGIS major version])
57AC_DEFINE_UNQUOTED([POSTGIS_MINOR_VERSION], ["$POSTGIS_MINOR_VERSION"], [PostGIS minor version])
58AC_DEFINE_UNQUOTED([POSTGIS_MICRO_VERSION], ["$POSTGIS_MICRO_VERSION"], [PostGIS micro version])
59
60AC_SUBST([POSTGIS_MAJOR_VERSION])
61AC_SUBST([POSTGIS_MINOR_VERSION])
62AC_SUBST([POSTGIS_MICRO_VERSION])
63
64dnl
65dnl Search for flex/bison to build the parser
66dnl
67
68AC_PROG_LEX
69AC_PROG_YACC
70AC_SUBST([LEX])
71AC_SUBST([YACC])
72
73dnl
74dnl Search for OS-specific headers
75dnl
76AC_CHECK_HEADER([ieeefp.h], [HAVE_IEEEFP_H=1], [HAVE_IEEEFP_H=0])
77AC_DEFINE_UNQUOTED([HAVE_IEEEFP_H], [$HAVE_IEEEFP_H], [ieeefp.h header])
78
79case $host_os in
80         *mingw*)
81                 PWDREGRESS="pwd -W"
82                 ;;
83         *)
84                 PWDREGRESS="pwd"
85                 ;;
86esac
87AC_DEFINE_UNQUOTED([PWDREGRESS])
88AC_SUBST([PWDREGRESS])
89
90dnl ===========================================================================
91dnl Find components needed to build documentation
92dnl ===========================================================================
93dnl
94dnl Search for xsltproc which is required for building documentation
95dnl
96
97AC_PATH_PROG([IMAGEMAGICK], [convert], [])
98if test "x$IMAGEMAGICK" = "x"; then
99        AC_MSG_WARN([ImageMagick does not seem to be installed. Documentation cannot be built])
100fi
101
102AC_PATH_PROG([XSLTPROC], [xsltproc], [])
103if test "x$XSLTPROC" = "x"; then
104        AC_MSG_WARN([xsltproc is not installed so documentation cannot be built])
105fi
106
107AC_PATH_PROG([DBLATEX], [dblatex], [])
108if test "x$DBLATEX" = "x"; then
109        AC_MSG_WARN([dblatex is not installed so PDF documentation cannot be built])
110fi
111
112dnl
113dnl Allow the user to specify the location of the html/docbook.xsl stylesheet
114dnl
115
116AC_ARG_WITH([xsldir],
117        [AS_HELP_STRING([--with-xsldir=PATH], [specify the directory containing the docbook.xsl stylesheet])],
118        [XSLBASE="$withval"], [XSLBASE=""])
119
120XSLBASE_AUTO=""
121if test "x$XSLBASE" = "x"; then
122        dnl If the user did not specify a directory for the docbook
123        dnl stylesheet, choose the first directory
124        dnl that matches from the following list
125        SEARCHPATH="
126                /usr/share/sgml/docbook/xsl-stylesheets
127                /usr/share/xml/docbook/stylesheet/nwalsh
128                /usr/share/sgml/docbook/stylesheet/xsl/nwalsh
129                /opt/local/share/xsl/docbook-xsl
130                /usr/local/share/xsl/docbook-xsl
131                /usr/share/xsl/docbook-xsl
132                "
133        for p in ${SEARCHPATH}; do
134                if test -r "${p}"/html/docbook.xsl; then
135                        XSLBASE_AUTO="${p}"
136                        break
137                fi
138        done
139
140        dnl Check to see if the automatically searched paths above located a
141        dnl valid Docbook stylesheet
142        if test "x$XSLBASE_AUTO" = "x"; then
143                AC_MSG_WARN([could not locate Docbook stylesheets required to build the documentation])
144        fi
145else
146        dnl The user specified an alternate directory so make sure everything
147        dnl looks sensible
148        if test ! -d "$XSLBASE"; then
149                AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not exist])
150        fi
151
152        if test ! -f "$XSLBASE/html/docbook.xsl"; then
153                AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not contain the html/docbook.xsl file])
154        fi
155fi
156
157dnl
158dnl If XSLBASE has been set then at this point we know it must be
159dnl valid and so we can just use it. If XSLBASE_AUTO has been set, and XSLBASE
160dnl is empty then a valid stylesheet was found in XSLBASE_AUTO so we
161dnl should use that. Otherwise just continue silently with a blank XSLBASE
162dnl variable which will trigger the error message in the documentation Makefile
163dnl
164
165if test "x$XSLBASE" = "x"; then
166        if test ! "x$XSLBASE_AUTO" = "x"; then
167                XSLBASE="$XSLBASE_AUTO"
168        fi
169fi
170
171AC_SUBST([XSLBASE])
172
173
174dnl ===========================================================================
175dnl Detect CUnit if it is installed (used for unit testing)
176dnl
177dnl Note that we pass any specified CPPFLAGS and LDFLAGS into the Makefile
178dnl as CUnit is the only compile-time dependency that cannot obtain any
179dnl specialised flags using a --with-X parameter, and so we allow this
180dnl information to be passed in if required.
181dnl ===========================================================================
182
183CUNIT_LDFLAGS=""
184AC_CHECK_HEADER([CUnit/CUnit.h], [
185        CUNIT_CPPFLAGS="$CPPFLAGS"
186        AC_CHECK_LIB([cunit], [CU_initialize_registry], [CUNIT_LDFLAGS="$LDFLAGS -lcunit"], [AC_MSG_WARN([could not locate CUnit required for liblwgeom unit tests])])
187        ],
188        [
189        AC_MSG_WARN([could not locate CUnit required for liblwgeom unit tests])
190        ])
191       
192AC_SUBST([CUNIT_CPPFLAGS])
193AC_SUBST([CUNIT_LDFLAGS])
194
195
196dnl ===========================================================================
197dnl Detect iconv if it is installed (used for shp2pgsql encoding conversion
198dnl if available)
199dnl ===========================================================================
200
201ICONV_CFLAGS=""
202ICONV_LDFLAGS=""
203
204AC_ARG_WITH([libiconv],
205        [AS_HELP_STRING([--with-libiconv=PATH], [specify a path to non-default libiconv installation])],
206        [LIBICONV_PATH="$withval"], [LIBICONV_PATH=""])
207
208LDFLAGS_SAVE="$LDFLAGS"
209CFLAGS_SAVE="$CFLAGS"
210
211if test "x$LIBICONV_PATH" != "x"; then
212        AC_MSG_RESULT([checking user-specified libiconv location: $LIBICONV_PATH])
213        ICONV_CFLAGS="-I$LIBICONV_PATH/include"
214        ICONV_LDFLAGS="-L$LIBICONV_PATH/lib"
215        LDFLAGS="$ICONV_LDFLAGS $LDFLAGS"
216        CFLAGS="$ICONV_CFLAGS $CFLAGS"
217fi
218
219HAVE_ICONV_H=0
220AC_CHECK_HEADER([iconv.h], [HAVE_ICONV_H=1], [])
221
222dnl If we find the header file, try and link against the library
223if test "x$HAVE_ICONV_H" = "x1"; then
224        dnl libconv defines iconv_open to libiconv_open, so we'll check that directly
225        AC_CHECK_LIB([iconv], [libiconv_open], [ICONV_LDFLAGS="$ICONV_LDFLAGS -liconv" HAVE_ICONV=1], [])
226        if test "x$HAVE_ICONV" = "x"; then
227                dnl Check for iconv included as part of libc, using iconv_open
228                AC_CHECK_LIB([c], [iconv_open], [ICONV_LDFLAGS="$ICONV_LDFLAGS -lc" HAVE_ICONV=1], [])
229                if test "x$HAVE_ICONV" = "x"; then
230                        dnl But it's possible this implementation of libiconv doesn't have a libiconv_* define
231                        AC_CHECK_LIB([iconv], [iconv_open], [ICONV_LDFLAGS="$ICONV_LDFLAGS -liconv" HAVE_ICONV=1], [])
232                        if test "x$HAVE_ICONV" = "x"; then
233                                dnl No iconv library was found; issue a warning to the console
234                                AC_MSG_ERROR([Could not find libiconv. Please install libiconv and libiconv-devel.])
235                        fi
236                fi     
237        fi
238else
239        dnl No iconv header was found; issue a warning to the console
240        AC_MSG_ERROR([Could not find iconv.h header. Please install libiconv and libiconv-devel.])
241fi
242
243LDFLAGS="$LDFLAGS_SAVE"
244CFLAGS="$CFLAGS_SAVE"
245
246dnl Only define HAVE_ICONV in postgis_config.h if we detect iconv sucessfully
247if test "x$HAVE_ICONV" != "x"; then
248        AC_DEFINE_UNQUOTED([HAVE_ICONV], [$HAVE_ICONV], [Defined if libiconv headers and library are present])
249fi
250
251AC_SUBST([ICONV_LDFLAGS])
252AC_SUBST([ICONV_CFLAGS])
253
254
255dnl ===========================================================================
256dnl Detect the version of PostgreSQL installed on the system
257dnl ===========================================================================
258
259AC_ARG_WITH([pgconfig],
260        [AS_HELP_STRING([--with-pgconfig=FILE], [specify an alternative pg_config file])],
261        [PGCONFIG="$withval"], [PGCONFIG=""])
262
263if test "x$PGCONFIG" = "x"; then
264        dnl PGCONFIG was not specified, so search within the current path
265        AC_PATH_PROG([PGCONFIG], [pg_config])
266
267        dnl If we couldn't find pg_config, display an error
268        if test "x$PGCONFIG" = "x"; then
269                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.])
270        fi
271else
272        dnl PGCONFIG was specified; display a message to the user
273        if test "x$PGCONFIG" = "xyes"; then
274                AC_MSG_ERROR([you must specify a parameter to --with-pgconfig, e.g. --with-pgconfig=/path/to/pg_config])
275        else
276                if test -f $PGCONFIG; then
277                        AC_MSG_RESULT([Using user-specified pg_config file: $PGCONFIG])
278                else
279                        AC_MSG_ERROR([the user-specified pg_config file $PGCONFIG does not exist])
280                fi
281        fi
282fi
283
284
285dnl ===========================================================================
286dnl Ensure that $PG_CONFIG --pgxs points to a valid file. This is because some
287dnl distributions such as Debian also include pg_config as part of libpq-dev
288dnl packages, but don't install the Makefile it points to unless
289dnl the postgresql-server-dev packages are installed :)
290dnl ===========================================================================
291
292PGXS=`$PGCONFIG --pgxs`
293if test ! -f $PGXS; then
294        AC_MSG_ERROR([the PGXS Makefile $PGXS cannot be found. Please install the PostgreSQL server development packages and re-run configure.])
295fi
296
297AC_SUBST([PGXS])
298
299
300dnl Extract the version information from pg_config
301dnl Note: we extract the major & minor separately, ensure they are numeric, and then combine to give
302dnl the final version. This is to guard against user error...
303PGSQL_MAJOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f1 | sed 's/[[^0-9]]//g'` 
304PGSQL_MINOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f2 | sed 's/[[^0-9]]//g'` 
305PGSQL_FULL_VERSION=`$PGCONFIG --version`
306POSTGIS_PGSQL_VERSION="$PGSQL_MAJOR_VERSION$PGSQL_MINOR_VERSION"
307
308AC_MSG_RESULT([checking PostgreSQL version... $PGSQL_FULL_VERSION])
309dnl Ensure that we are using PostgreSQL >= 8.3
310if test ! "$PGSQL_MAJOR_VERSION" -ge 8; then
311        AC_MSG_ERROR([PostGIS requires PostgreSQL >= 8.3])
312else
313        if test "$PGSQL_MAJOR_VERSION" -eq 8; then
314                if test ! "$PGSQL_MINOR_VERSION" -ge 3; then
315                        AC_MSG_ERROR([PostGIS requires PostgreSQL >= 8.3])
316                fi     
317        fi
318fi     
319
320dnl Temporary hack until minimum PostgreSQL version is 8.5:
321dnl If PostgreSQL < 8.5 is detected, trigger the inclusion of the new versioned PGXS targets
322PGXSOVERRIDE=0
323if test ! "$PGSQL_MINOR_VERSION" -ge 5; then
324        PGXSOVERRIDE=1
325fi
326
327AC_SUBST([PGXSOVERRIDE])
328
329dnl Note: We don't need the server-side LDFLAGS or CPPFLAGS because we get these from PGXS
330
331dnl Extract the linker and include flags for the frontend (for programs that use libpq)
332PGSQL_FE_LDFLAGS=-L`$PGCONFIG --libdir`" -lpq"
333PGSQL_FE_CPPFLAGS=-I`$PGCONFIG --includedir`
334
335AC_SUBST([PGSQL_FE_LDFLAGS])
336AC_SUBST([PGSQL_FE_CPPFLAGS])
337
338dnl Extract the documentation and man page directories
339PGSQL_DOCDIR=`$PGCONFIG --docdir`
340PGSQL_MANDIR=`$PGCONFIG --mandir`
341
342AC_SUBST([PGSQL_DOCDIR])
343AC_SUBST([PGSQL_MANDIR])
344
345dnl Extract the executable directory
346PGSQL_BINDIR=`$PGCONFIG --bindir`
347
348AC_SUBST([PGSQL_BINDIR])
349
350dnl Extract the share directory
351PGSQL_SHAREDIR=`$PGCONFIG --sharedir`
352
353AC_SUBST([PGSQL_SHAREDIR])
354
355dnl Ensure that we can parse libpq-fe.h
356CPPFLAGS_SAVE="$CPPFLAGS"
357CPPFLAGS="$PGSQL_FE_CPPFLAGS"
358AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([could not find libpq-fe.h])])
359CPPFLAGS="$CPPFLAGS_SAVE"
360
361dnl Ensure we can link against libpq
362LIBS_SAVE="$LIBS"
363LIBS="$PGSQL_FE_LDFLAGS"
364AC_CHECK_LIB([pq], [PQserverVersion],
365        [],
366        [AC_MSG_ERROR([could not find libpq])],
367        [])
368LIBS="$LIBS_SAVE"
369
370AC_DEFINE_UNQUOTED([POSTGIS_PGSQL_VERSION], [$POSTGIS_PGSQL_VERSION], [PostgreSQL server version])     
371AC_SUBST([POSTGIS_PGSQL_VERSION])
372
373
374dnl ===========================================================================
375dnl Detect libxml2 if it is installed
376dnl (needed to GeomFromGML and GeomFromKML functions)
377dnl ===========================================================================
378
379AC_ARG_WITH([xml2config],
380        [AS_HELP_STRING([--with-xml2config=FILE], [specify an alternative xml2-config file])],
381        [XML2CONFIG="$withval"], [XML2CONFIG=""])
382
383if test "x$XML2CONFIG" = "x"; then
384        dnl XML2CONFIG was not specified, so search within the current path
385        AC_PATH_PROG([XML2CONFIG], [xml2-config])
386
387        dnl If we couldn't find xml2-config, display a warning
388        if test "x$XML2CONFIG" = "x"; then
389                AC_MSG_ERROR([could not find xml2-config from libxml2 within the current path. You may need to try re-running configure with a --with-xml2config parameter.])
390        fi
391else
392        dnl XML2CONFIG was specified; display a message to the user
393        if test "x$XML2CONFIG" = "xyes"; then
394                AC_MSG_ERROR([you must specify a parameter to --with-xml2config, e.g. --with-xml2config=/path/to/xml2-config])
395        else
396                if test -f $XML2CONFIG; then
397                        AC_MSG_RESULT([Using user-specified xml2-config file: $XML2CONFIG])
398                else
399                        AC_MSG_ERROR([the user-specified xml2-config file $XML2CONFIG does not exist])
400                fi     
401        fi
402fi
403
404
405dnl Extract the linker and include flags
406XML2_LDFLAGS=`$XML2CONFIG --libs`
407XML2_CPPFLAGS=`$XML2CONFIG --cflags`
408
409dnl Extract the version
410POSTGIS_LIBXML2_VERSION=`$XML2CONFIG --version`
411
412dnl Check headers file
413CPPFLAGS_SAVE="$CPPFLAGS"
414CPPFLAGS="$XML2_CPPFLAGS"
415AC_CHECK_HEADERS([libxml/tree.h libxml/parser.h libxml/xpath.h libxml/xpathInternals.h],
416                 [], [AC_MSG_ERROR([could not find headers include related to libxml2])])
417
418dnl Ensure we can link against libxml2
419LIBS_SAVE="$LIBS"
420LIBS="$XML2_LDFLAGS"
421AC_CHECK_LIB([xml2], [xmlInitParser], [], [AC_MSG_ERROR([could not find libxml2])], [])
422
423AC_DEFINE_UNQUOTED([POSTGIS_LIBXML2_VERSION], ["$POSTGIS_LIBXML2_VERSION"], [PostGIS libxml2 version])
424AC_SUBST([POSTGIS_LIBXML2_VERSION])
425
426
427
428dnl ===========================================================================
429dnl Detect the version of GEOS installed on the system
430dnl ===========================================================================
431
432AC_ARG_WITH([geosconfig],
433        [AS_HELP_STRING([--with-geosconfig=FILE], [specify an alternative geos-config file])],
434        [GEOSCONFIG="$withval"], [GEOSCONFIG=""])
435
436if test "x$GEOSCONFIG" = "x"; then
437        dnl GEOSCONFIG was not specified, so search within the current path
438        AC_PATH_PROG([GEOSCONFIG], [geos-config])
439
440        dnl If we couldn't find geos-config, display an error
441        if test "x$GEOSCONFIG" = "x"; then
442                AC_MSG_ERROR([could not find geos-config within the current path. You may need to try re-running configure with a --with-geosconfig parameter.])
443        fi
444else
445        dnl GEOSCONFIG was specified; display a message to the user
446        if test "x$GEOSCONFIG" = "xyes"; then
447                AC_MSG_ERROR([you must specify a parameter to --with-geosconfig, e.g. --with-geosconfig=/path/to/geos-config])
448        else
449                if test -f $GEOSCONFIG; then
450                        AC_MSG_RESULT([Using user-specified geos-config file: $GEOSCONFIG])
451                else
452                        AC_MSG_ERROR([the user-specified geos-config file $GEOSCONFIG does not exist])
453                fi     
454        fi
455fi
456
457dnl Extract the version information from geos_config
458dnl Note: we extract the major & minor separately, ensure they are numeric,
459dnl and then combine to give the final version.
460dnl This is to guard against user error...
461GEOS_MAJOR_VERSION=`$GEOSCONFIG --version | cut -d. -f1 | sed 's/[[^0-9]]//g'`
462GEOS_MINOR_VERSION=`$GEOSCONFIG --version | cut -d. -f2 | sed 's/[[^0-9]]//g'`
463GEOS_FULL_VERSION=`$GEOSCONFIG --version`
464POSTGIS_GEOS_VERSION="$GEOS_MAJOR_VERSION$GEOS_MINOR_VERSION"
465
466dnl Ensure that we are using GEOS >= 3.1.0
467AC_MSG_RESULT([checking GEOS version... $GEOS_FULL_VERSION])
468if test ! "$POSTGIS_GEOS_VERSION" -ge 31; then
469        AC_MSG_ERROR([PostGIS requires GEOS >= 3.1])
470fi
471
472dnl Extract the linker and include flags
473GEOS_LDFLAGS=`$GEOSCONFIG --ldflags`
474GEOS_CPPFLAGS=-I`$GEOSCONFIG --includes`
475
476dnl Ensure that we can parse geos_c.h
477CPPFLAGS_SAVE="$CPPFLAGS"
478CPPFLAGS="$GEOS_CPPFLAGS"
479AC_CHECK_HEADER([geos_c.h], [], [AC_MSG_ERROR([could not find geos_c.h - you may need to specify the directory of a geos-config file using --with-geosconfig])])
480CPPFLAGS="$CPPFLAGS_SAVE"
481
482dnl Ensure we can link against libgeos_c
483LIBS_SAVE="$LIBS"
484LIBS="$GEOS_LDFLAGS"
485AC_CHECK_LIB([geos_c], [initGEOS],
486        [],
487        [AC_MSG_ERROR([could not find libgeos_c - you may need to specify the directory of a geos-config file using --with-geosconfig])],
488        [])
489LIBS="$LIBS_SAVE"
490
491AC_DEFINE_UNQUOTED([POSTGIS_GEOS_VERSION], [$POSTGIS_GEOS_VERSION], [GEOS library version])     
492AC_SUBST([POSTGIS_GEOS_VERSION])
493
494
495dnl ===========================================================================
496dnl Detect the version of PROJ.4 installed
497dnl ===========================================================================
498
499AC_ARG_WITH([projdir],
500        [AS_HELP_STRING([--with-projdir=PATH], [specify the PROJ.4 installation directory])],
501        [PROJDIR="$withval"], [PROJDIR=""])
502
503if test ! "x$PROJDIR" = "x"; then
504        dnl Make sure that the directory exists
505        if test "x$PROJDIR" = "xyes"; then
506                AC_MSG_ERROR([you must specifiy a parameter to --with-projdir, e.g. --with-projdir=/path/to])
507        else
508                if test -d "$PROJDIR"; then
509                        AC_MSG_RESULT([Using user-specified proj directory: $PROJDIR])
510
511                        dnl Add the include directory to PROJ_CPPFLAGS 
512                        PROJ_CPPFLAGS="-I$PROJDIR/include"     
513                        PROJ_LDFLAGS="-L$PROJDIR/lib"
514                else
515                        AC_MSG_ERROR([the --with-projdir directory "$PROJDIR" cannot be found])
516                fi
517        fi
518fi
519
520
521dnl Check that we can find the proj_api.h header file
522CPPFLAGS_SAVE="$CPPFLAGS"
523CPPFLAGS="$PROJ_CPPFLAGS"
524AC_CHECK_HEADER([proj_api.h], [], [AC_MSG_ERROR([could not find proj_api.h - you may need to specify the directory of a PROJ.4 installation using --with-projdir])])   
525
526dnl Return the PROJ.4 version number
527AC_PROJ_VERSION([POSTGIS_PROJ_VERSION])
528AC_DEFINE_UNQUOTED([POSTGIS_PROJ_VERSION], [$POSTGIS_PROJ_VERSION], [PROJ library version])
529AC_SUBST([POSTGIS_PROJ_VERSION])
530CPPFLAGS="$CPPFLAGS_SAVE"
531
532dnl Ensure that we are using PROJ >= 4.5.0 (requires pj_set_searchpath)
533if test ! "$POSTGIS_PROJ_VERSION" -ge 45; then
534        AC_MSG_ERROR([PostGIS requires PROJ >= 4.5.0])
535fi
536
537dnl Ensure we can link against libproj
538LIBS_SAVE="$LIBS"
539LIBS="$PROJ_LDFLAGS"
540AC_CHECK_LIB([proj], [pj_get_release],
541        [],
542        [AC_MSG_ERROR([could not find libproj - you may need to specify the directory of a PROJ.4 installation using --with-projdir])],
543        [])
544LIBS="$LIBS_SAVE"
545
546dnl ===========================================================================
547dnl Detect GTK+2.0 for GUI
548dnl ===========================================================================
549
550AC_ARG_WITH([gui],
551        [AS_HELP_STRING([--with-gui], [compile the data import GUI (requires GTK+2.0)])],
552        [GUI="yes"], [GUI="no"])
553
554if test "x$GUI" = "xyes"; then
555        AC_MSG_RESULT([GUI: Build requested, checking for dependencies (GKT+2.0)])
556        case $host in
557                *darwin10.1*)
558                        for frmwrk [ in Cairo GLib Gtk ]; do
559                                if test -d /Library/Frameworks/${frmwrk}.framework; then
560                                        GTK_CFLAGS="$GTK_CFLAGS -I/Library/Frameworks/${frmwrk}.framework/Headers"
561                                        GTK_LIBS="$GTK_LIBS -framework $frmwrk"
562                                        AC_MSG_RESULT([GUI: Found /Library/Frameworks/${frmwrk}.framework])
563                                else
564                                        AC_MSG_ERROR([GUI: Mac OS/X build requires the GTK+2.0 frameworks available from http://www.gtk-osx.org])
565                                fi
566                        done
567                        GTK_BUILD="gui"
568                        ;;
569                *)
570                        dnl Try to find the GTK libs with pkgconfig
571                        AM_PATH_GTK_2_0([2.8.0], [GTK_BUILD="gui"], [GTK_BUILD=""])
572        esac
573
574        dnl Add -mwindows to MinGW GUI build
575        case $host in
576                *mingw32*)
577                        GTK_WIN32_FLAGS=-mwindows
578                        GTK_WIN32_RES=shp2pgsql-gui.res
579                        GTK_WIN32_BUILD=gui-win32
580                        ;;
581        esac
582fi
583
584
585
586AC_SUBST([GTK_CFLAGS])
587AC_SUBST([GTK_LIBS])
588AC_SUBST([GTK_WIN32_FLAGS])
589AC_SUBST([GTK_WIN32_RES])
590AC_SUBST([GTK_BUILD])
591
592
593
594dnl ===========================================================================
595dnl Allow the user to enable debugging with --enable-debug
596dnl
597dnl Currently we default to debug level 4. See DEBUG for more information.
598dnl
599
600AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable verbose debugging messages]),
601        [POSTGIS_DEBUG_LEVEL=4], [POSTGIS_DEBUG_LEVEL=0])
602
603AC_DEFINE_UNQUOTED([POSTGIS_DEBUG_LEVEL], [$POSTGIS_DEBUG_LEVEL], [PostGIS library debug level (0=disabled)])
604
605dnl ===========================================================================
606dnl Allow the user to enable GEOS profiling with --enable-profile
607dnl
608
609AC_ARG_ENABLE([profile], AC_HELP_STRING([--enable-profile], [Enable GEOS profiling messages]),
610        [POSTGIS_PROFILE=1], [POSTGIS_PROFILE=0])
611
612AC_DEFINE_UNQUOTED([POSTGIS_PROFILE], [$POSTGIS_PROFILE], [Enable GEOS profiling (0=disabled)])
613
614dnl ===========================================================================
615dnl Define version macros
616dnl
617
618POSTGIS_VERSION="$POSTGIS_MAJOR_VERSION.$POSTGIS_MINOR_VERSION USE_GEOS=1 USE_PROJ=1 USE_STATS=1"
619if test "$HAVE_LIBXML2" = "1"; then
620        POSTGIS_VERSION="$POSTGIS_VERSION USE_LIBXML2=1"
621fi
622
623POSTGIS_LIB_VERSION="$POSTGIS_MAJOR_VERSION.$POSTGIS_MINOR_VERSION.$POSTGIS_MICRO_VERSION"
624POSTGIS_BUILD_DATE=`date -u "+%Y-%m-%d %H:%M:%S"`
625POSTGIS_SCRIPTS_SVNREV=`perl utils/read_scripts_version.pl`
626POSTGIS_SCRIPTS_VERSION="$POSTGIS_MAJOR_VERSION.$POSTGIS_MINOR_VERSION r$POSTGIS_SCRIPTS_SVNREV"
627
628AC_DEFINE_UNQUOTED([POSTGIS_VERSION], ["$POSTGIS_VERSION"], [PostGIS version])
629AC_DEFINE_UNQUOTED([POSTGIS_LIB_VERSION], ["$POSTGIS_LIB_VERSION"], [PostGIS library version])
630AC_DEFINE_UNQUOTED([POSTGIS_BUILD_DATE], ["$POSTGIS_BUILD_DATE"], [PostGIS build date])
631AC_DEFINE_UNQUOTED([POSTGIS_SCRIPTS_VERSION], ["$POSTGIS_SCRIPTS_VERSION"], [PostGIS scripts version])
632
633AC_SUBST([POSTGIS_VERSION])
634AC_SUBST([POSTGIS_LIB_VERSION])
635AC_SUBST([POSTGIS_BUILD_DATE])
636AC_SUBST([POSTGIS_SCRIPTS_VERSION])
637
638
639dnl ===========================================================================
640dnl Other parameters
641dnl
642
643dnl Always enable BBOX caching by default
644AC_DEFINE_UNQUOTED([POSTGIS_AUTOCACHE_BBOX], [1], [Enable caching of bounding box within geometries])
645
646dnl Always enable use of ANALYZE statistics by default
647AC_DEFINE_UNQUOTED([POSTGIS_USE_STATS], [1], [Enable use of ANALYZE statistics])
648
649
650CPPFLAGS="$PGSQL_CPPFLAGS $GEOS_CPPFLAGS $PROJ_CPPFLAGS $XML2_CPPFLAGS"
651dnl AC_MSG_RESULT([CPPFLAGS: $CPPFLAGS])
652
653SHLIB_LINK="$PGSQL_LDFLAGS $GEOS_LDFLAGS $PROJ_LDFLAGS -lgeos_c -lproj $XML2_LDFLAGS"
654AC_SUBST([SHLIB_LINK])
655dnl AC_MSG_RESULT([SHLIB_LINK: $SHLIB_LINK])
656
657dnl Output the relevant files
658AC_OUTPUT([liblwgeom/Makefile liblwgeom/cunit/Makefile postgis/Makefile postgis/sqldefines.h loader/Makefile topology/Makefile regress/Makefile doc/Makefile doc/html/image_src/Makefile])
659
660dnl ===========================================================================
661dnl Display the configuration status information
662dnl ===========================================================================
663
664AC_MSG_RESULT()
665AC_MSG_RESULT([  PostGIS is now configured for ${host}])
666AC_MSG_RESULT()
667AC_MSG_RESULT([ -------------- Compiler Info ------------- ])
668AC_MSG_RESULT([  C compiler:           ${CC} ${CFLAGS}])
669AC_MSG_RESULT([  C++ compiler:         ${CXX} ${CXXFLAGS}])
670AC_MSG_RESULT()
671AC_MSG_RESULT([ -------------- Dependencies -------------- ])
672AC_MSG_RESULT([  GEOS config:          ${GEOSCONFIG}])
673AC_MSG_RESULT([  GEOS version:         ${GEOS_FULL_VERSION}])
674AC_MSG_RESULT([  PostgreSQL config:    ${PGCONFIG}])
675AC_MSG_RESULT([  PostgreSQL version:   ${PGSQL_FULL_VERSION}])
676AC_MSG_RESULT([  PROJ4 version:        ${POSTGIS_PROJ_VERSION}])
677AC_MSG_RESULT([  Libxml2 config:       ${XML2CONFIG}])
678AC_MSG_RESULT([  Libxml2 version:      ${POSTGIS_LIBXML2_VERSION}])
679AC_MSG_RESULT([  PostGIS debug level:  ${POSTGIS_DEBUG_LEVEL}])
680AC_MSG_RESULT()
681AC_MSG_RESULT([ -------- Documentation Generation -------- ])
682AC_MSG_RESULT([  xsltproc:             ${XSLTPROC}])
683AC_MSG_RESULT([  xsl style sheets:     ${XSLBASE}])
684AC_MSG_RESULT([  dblatex:              ${DBLATEX}])
685AC_MSG_RESULT([  convert:              ${IMAGEMAGICK}])
686AC_MSG_RESULT()
687
688
Note: See TracBrowser for help on using the repository browser.