source: trunk/configure.ac @ 2815

Last change on this file since 2815 was 2815, checked in by mcayland, 8 years ago

Split the basic geometry accessors into a separate static library liblwgeom.a; this potentially allows re-use of the liblwgeom functions from within PostGIS, or could be extended at a later date to include databases other than MySQL. This patch includes a change to the liblwgeom handler functions; instead of sprinkling init_pg_func()s around the source, I have changed the default liblwgeom handlers to make use of a callback to allow linked libraries to set their own handlers the first time any of them are called. I have also tidied up the parser API a little in liblwgeom.h, which means wktparse.h can be removed from all of the headers in the lwgeom/ directory, plus renamed wktunparse.c to lwgunparse.c to keep things similar to lwgparse.c. Finally, I renamed liblwgeom.c to lwutil.c to avoid confusion within the new interface. TODO: the liblwgeom Makefile has some gcc-specific options, but these can be fixed later - it seemed more important to make the warnings visible to developers.

File size: 12.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])
15
16dnl
17dnl Compilers
18dnl
19AC_PROG_CC
20AC_PROG_CPP
21AC_PROG_CXX
22
23
24dnl
25dnl Version Information imported from Version.config
26dnl
27POSTGIS_MAJOR_VERSION=`cat Version.config | grep POSTGIS_MAJOR_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'`
28POSTGIS_MINOR_VERSION=`cat Version.config | grep POSTGIS_MINOR_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'`
29POSTGIS_MICRO_VERSION=`cat Version.config | grep POSTGIS_MICRO_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'`
30
31
32dnl
33dnl Search for xsltproc which is required for building documentation
34dnl
35
36AC_PATH_PROG([XSLTPROC], [xsltproc], [])
37if test "x$XSLTPROC" = "x"; then
38        AC_MSG_WARN([xsltproc is not installed so documentation cannot be built])
39fi
40
41
42dnl
43dnl Allow the user to specify the location of the html/docbook.xsl stylesheet
44dnl
45
46AC_ARG_WITH([xsldir], [Specify the path to the directory containing the docbook.xsl stylesheet], [XSLBASE="$withval"], [XSLBASE=""])
47if test "x$XSLBASE" = "x"; then
48        dnl If the user did not specify a directory for the docbook stylesheet, choose the first directory
49        dnl that matches from the following list
50        SEARCHPATH="
51                /usr/share/sgml/docbook/xsl-stylesheets
52                /usr/share/xml/docbook/stylesheet/nwalsh
53                /usr/share/sgml/docbook/stylesheet/xsl/nwalsh
54                "
55        for p in ${SEARCHPATH}; do
56                if test -r "${p}"/html/docbook.xsl; then
57                        XSLBASE="${p}"
58                        break
59                fi
60        done
61fi
62
63
64dnl For XSLBASE, make sure the directory exists and that it contains html/docbook.xsl
65if test ! -d "$XSLBASE"; then
66        AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not exist])
67fi
68
69if test ! -f "$XSLBASE/html/docbook.xsl"; then
70        AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not contain the html/docbook.xsl file])
71fi
72
73AC_SUBST([XSLBASE])
74
75
76dnl
77dnl Detect iconv if it is installed (used for shp2pgsql encoding conversion if available)
78dnl
79
80LIBS_SAVE="$LIBS"
81HAVE_ICONV_H=0
82AC_CHECK_HEADER([iconv.h], [HAVE_ICONV_H=1], [])
83
84dnl If we find the header file, try and link against the library
85if test "x$HAVE_ICONV_H" != "x0"; then
86        dnl Check for iconv includes as part of libc
87        AC_CHECK_LIB([c], [iconv_open], [HAVE_ICONV=1], [])
88        if test "x$HAVE_ICONV" = "x"; then
89                dnl If not found, check for iconv included as part of libiconv
90                AC_CHECK_LIB([iconv], [iconv_open], [HAVE_ICONV=1], [])
91                if test "x$HAVE_ICONV" = "x"; then
92                        dnl If not found, check for Win32 iconv (some of them use a lib prefix for functions within the iconv DLLs)
93                        AC_CHECK_LIB([iconv], [libiconv_open], [HAVE_ICONV=1], [])
94                        if test "x$HAVE_ICONV" = "x"; then
95                                dnl No iconv library was found; issue a warning to the console
96                                AC_MSG_WARN([could not find iconv library: no support for encoding conversion will be included])
97                        else
98                                ICONV_LDFLAGS="$LIBS"
99                        fi
100                else
101                        ICONV_LDFLAGS="$LIBS"
102                fi     
103        fi
104else
105        dnl No iconv header was found; issue a warning to the console
106        AC_MSG_WARN([could not find iconv.h header: no support for encoding conversion will be included])
107fi
108
109LIBS="$LIBS_SAVE"
110
111dnl Only define HAVE_ICONV in postgis_config.h if we detect iconv sucessfully
112if test "x$HAVE_ICONV" != "x"; then
113        AC_DEFINE_UNQUOTED([HAVE_ICONV], [$HAVE_ICONV], [Defined if libiconv headers and library are present])
114fi
115
116AC_SUBST([ICONV_LDFLAGS])
117
118
119dnl
120dnl Detect the version of PostgreSQL installed on the system
121dnl
122
123AC_ARG_WITH([pgconfig], [Specify the path to an alternative pg_config], [PGCONFIG="$withval"], [PGCONFIG=""])
124if test "x$PGCONFIG" = "x"; then
125        dnl PGCONFIG was not specified, so search within the current path
126        AC_PATH_PROG([PGCONFIG], [pg_config])
127
128        dnl If we couldn't find pg_config, display an error
129        if test "x$PGCONFIG" = "x"; then
130                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.])
131        fi
132else
133        dnl PGCONFIG was specified; display a message to the user
134        if test "x$PGCONFIG" = "xyes"; then
135                AC_MSG_ERROR([you must specify a parameter to --with-pgconfig, e.g. --with-pgconfig=/path/to/pg_config])
136        else
137                if test -f $PGCONFIG; then
138                        AC_MSG_RESULT([Using user-specified pg_config file: $PGCONFIG])
139                else
140                        AC_MSG_ERROR([the user-specified pg_config file $PGCONFIG does not exist])
141                fi
142        fi
143fi
144
145dnl Extract the version information from pg_config
146dnl Note: we extract the major & minor separately, ensure they are numeric, and then combine to give
147dnl the final version. This is to guard against user error...
148PGSQL_MAJOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f1 | sed 's/[[^0-9]]//g'` 
149PGSQL_MINOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f2 | sed 's/[[^0-9]]//g'` 
150POSTGIS_PGSQL_VERSION="$PGSQL_MAJOR_VERSION$PGSQL_MINOR_VERSION"
151
152dnl Ensure that we are using PostgreSQL >= 8.1
153if test ! "$PGSQL_MAJOR_VERSION" -ge 8; then
154        AC_MSG_ERROR([PostGIS requires PostgreSQL >= 8.1])
155else
156        if test "$PGSQL_MAJOR_VERSION" -eq 8; then
157                if test ! "$PGSQL_MINOR_VERSION" -ge 1; then
158                        AC_MSG_ERROR([PostGIS requires PostgreSQL >= 8.1])
159                fi     
160        fi
161fi     
162
163dnl Note: We don't need the server-side LDFLAGS or CPPFLAGS because we get these from PGXS
164
165dnl Extract the linker and include flags for the frontend (for programs that use libpq)
166PGSQL_FE_LDFLAGS=-L`$PGCONFIG --libdir`
167PGSQL_FE_CPPFLAGS=-I`$PGCONFIG --includedir`
168
169AC_SUBST([PGSQL_FE_LDFLAGS])
170AC_SUBST([PGSQL_FE_CPPFLAGS])
171
172dnl Extract the documentation and man page directories
173PGSQL_DOCDIR=`$PGCONFIG --docdir`
174PGSQL_MANDIR=`$PGCONFIG --mandir`
175
176AC_SUBST([PGSQL_DOCDIR])
177AC_SUBST([PGSQL_MANDIR])
178
179
180dnl Ensure that we can parse libpq-fe.h
181CPPFLAGS_SAVE="$CPPFLAGS"
182CPPFLAGS="$PGSQL_FE_CPPFLAGS"
183AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([could not find libpq-fe.h])])
184CPPFLAGS="$CPPFLAGS_SAVE"
185
186dnl Ensure we can link against libpq
187LIBS_SAVE="$LIBS"
188LIBS="$PGSQL_FE_LDFLAGS"
189AC_CHECK_LIB([pq], [PQserverVersion],
190        [],
191        [AC_MSG_ERROR([could not find libpq])],
192        [])
193LIBS="$LIBS_SAVE"
194
195AC_DEFINE_UNQUOTED([POSTGIS_PGSQL_VERSION], [$POSTGIS_PGSQL_VERSION], [PostgreSQL server version])     
196AC_SUBST([POSTGIS_PGSQL_VERSION])
197
198
199dnl
200dnl Detect the version of GEOS installed on the system
201dnl
202
203AC_ARG_WITH([geosconfig], [Specify the path to an alternative geos-config], [GEOSCONFIG="$withval"], [GEOSCONFIG=""])
204if test "x$GEOSCONFIG" = "x"; then
205        dnl GEOSCONFIG was not specified, so search within the current path
206        AC_PATH_PROG([GEOSCONFIG], [geos-config])
207
208        dnl If we couldn't find geos-config, display an error
209        if test "x$GEOSCONFIG" = "x"; then
210                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.])
211        fi
212else
213        dnl GEOSCONFIG was specified; display a message to the user
214        if test "x$GEOSCONFIG" = "xyes"; then
215                AC_MSG_ERROR([you must specify a parameter to --with-geosconfig, e.g. --with-geosconfig=/path/to/geos-config])
216        else
217                if test -f $GEOSCONFIG; then
218                        AC_MSG_RESULT([Using user-specified geos-config file: $GEOSCONFIG])
219                else
220                        AC_MSG_ERROR([the user-specified geos-config file $GEOSCONFIG does not exist])
221                fi     
222        fi
223fi
224
225dnl Extract the version information from pg_config
226dnl Note: we extract the major & minor separately, ensure they are numeric, and then combine to give
227dnl the final version. This is to guard against user error...
228GEOS_MAJOR_VERSION=`$GEOSCONFIG --version | cut -d. -f1 | sed 's/[[^0-9]]//g'`
229GEOS_MINOR_VERSION=`$GEOSCONFIG --version | cut -d. -f2 | sed 's/[[^0-9]]//g'`
230POSTGIS_GEOS_VERSION="$GEOS_MAJOR_VERSION$GEOS_MINOR_VERSION"
231
232dnl Ensure that we are using GEOS >= 2.2.0 (requires CAPI)
233if test ! "$GEOS_MAJOR_VERSION" -ge 2; then
234        AC_MSG_ERROR([PostGIS requires GEOS >= 2.2])
235else
236        if test "$GEOS_MAJOR_VERSION" -eq 2; then
237                if test ! "$GEOS_MINOR_VERSION" -ge 2; then
238                        AC_MSG_ERROR([PostGIS requires GEOS >= 2.2])
239                fi
240        fi
241fi     
242
243dnl Extract the linker and include flags
244GEOS_LDFLAGS=`$GEOSCONFIG --ldflags`
245GEOS_CPPFLAGS=-I`$GEOSCONFIG --includes`
246
247dnl Ensure that we can parse geos_c.h
248CPPFLAGS_SAVE="$CPPFLAGS"
249CPPFLAGS="$GEOS_CPPFLAGS"
250AC_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])])
251CPPFLAGS="$CPPFLAGS_SAVE"
252
253dnl Ensure we can link against libgeos_c
254LIBS_SAVE="$LIBS"
255LIBS="$GEOS_LDFLAGS"
256AC_CHECK_LIB([geos_c], [initGEOS],
257        [],
258        [AC_MSG_ERROR([could not find libgeos_c - you may need to specify the directory of a geos-config file using --with-geosconfig])],
259        [])
260LIBS="$LIBS_SAVE"
261
262AC_DEFINE_UNQUOTED([POSTGIS_GEOS_VERSION], [$POSTGIS_GEOS_VERSION], [GEOS library version])     
263AC_SUBST([POSTGIS_GEOS_VERSION])
264
265
266dnl
267dnl Detect the version of PROJ.4 installed
268dnl
269
270AC_ARG_WITH([projdir], [Specify the directory to an alternative PROJ installation], [PROJDIR="$withval"], [PROJDIR=""])
271if test ! "x$PROJDIR" = "x"; then
272        dnl Make sure that the directory exists
273        if test "x$PROJDIR" = "xyes"; then
274                AC_MSG_ERROR([you must specifiy a parameter to --with-projdir, e.g. --with-projdir=/path/to])
275        else
276                if test -d "$PROJDIR"; then
277                        AC_MSG_RESULT([Using user-specified proj directory: $PROJDIR])
278
279                        dnl Add the include directory to PROJ_CPPFLAGS 
280                        PROJ_CPPFLAGS="-I$PROJDIR/include"     
281                        PROJ_LDFLAGS="-L$PROJDIR/lib"
282                else
283                        AC_MSG_ERROR([the --with-projdir directory "$PROJDIR" cannot be found])
284                fi
285        fi
286fi
287
288dnl Check that we can find the proj_api.h header file
289CPPFLAGS_SAVE="$CPPFLAGS"
290CPPFLAGS="$PROJ_CPPFLAGS"
291AC_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])])   
292
293dnl Return the PROJ.4 version number
294AC_PROJ_VERSION([POSTGIS_PROJ_VERSION])
295AC_DEFINE_UNQUOTED([POSTGIS_PROJ_VERSION], [$POSTGIS_PROJ_VERSION], [PROJ library version])
296AC_SUBST([POSTGIS_PROJ_VERSION])
297CPPFLAGS="$CPPFLAGS_SAVE"
298
299dnl Ensure we can link against libproj
300LIBS_SAVE="$LIBS"
301LIBS="$PROJ_LDFLAGS"
302AC_CHECK_LIB([proj], [pj_get_release],
303        [],
304        [AC_MSG_ERROR([could not find libproj - you may need to specify the directory of a PROJ.4 installation using --with-projdir])],
305        [])
306LIBS="$LIBS_SAVE"
307
308
309dnl
310dnl Allow the user to enable debugging with --enable-debug
311dnl
312dnl Currently we default to debug level 4. See DEBUG for more information.
313dnl
314
315AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable verbose debugging messages]),
316        [POSTGIS_DEBUG_LEVEL=4], [POSTGIS_DEBUG_LEVEL=0])
317
318AC_DEFINE_UNQUOTED([POSTGIS_DEBUG_LEVEL], [$POSTGIS_DEBUG_LEVEL], [PostGIS library debug level (0=disabled)])
319
320
321dnl
322dnl Define version macros
323dnl
324
325POSTGIS_VERSION="$POSTGIS_MAJOR_VERSION.$POSTGIS_MINOR_VERSION USE_GEOS=1 USE_PROJ=1 USE_STATS=1"
326POSTGIS_LIB_VERSION="$POSTGIS_MAJOR_VERSION.$POSTGIS_MINOR_VERSION.$POSTGIS_MICRO_VERSION"
327POSTGIS_BUILD_DATE=`date -u "+%Y-%m-%d %H:%M:%S"`
328POSTGIS_SCRIPTS_VERSION="$POSTGIS_LIB_VERSION"
329
330AC_DEFINE_UNQUOTED([POSTGIS_VERSION], ["$POSTGIS_VERSION"], [PostGIS version])
331AC_DEFINE_UNQUOTED([POSTGIS_LIB_VERSION], ["$POSTGIS_LIB_VERSION"], [PostGIS library version])
332AC_DEFINE_UNQUOTED([POSTGIS_BUILD_DATE], ["$POSTGIS_BUILD_DATE"], [PostGIS build date])
333AC_DEFINE_UNQUOTED([POSTGIS_SCRIPTS_VERSION], ["$POSTGIS_SCRIPTS_VERSION"], [PostGIS scripts version])
334
335AC_SUBST([POSTGIS_VERSION])
336AC_SUBST([POSTGIS_LIB_VERSION])
337AC_SUBST([POSTGIS_BUILD_DATE])
338AC_SUBST([POSTGIS_SCRIPTS_VERSION])
339
340
341dnl
342dnl Other parameters
343dnl
344
345dnl Always enable BBOX caching by default
346AC_DEFINE_UNQUOTED([POSTGIS_AUTOCACHE_BBOX], [1], [Enable caching of bounding box within geometries])
347
348dnl Always enable use of ANALYZE statistics by default
349AC_DEFINE_UNQUOTED([POSTGIS_USE_STATS], [1], [Enable use of ANALYZE statistics])
350
351
352CPPFLAGS="$PGSQL_CPPFLAGS $GEOS_CPPFLAGS $PROJ_CPPFLAGS"
353dnl AC_MSG_RESULT([CPPFLAGS: $CPPFLAGS])
354
355SHLIB_LINK="$PGSQL_LDFLAGS $GEOS_LDFLAGS $PROJ_LDFLAGS -lgeos_c -lproj"
356AC_SUBST([SHLIB_LINK])
357dnl AC_MSG_RESULT([SHLIB_LINK: $SHLIB_LINK])
358
359dnl Output the relevant files
360AC_OUTPUT([liblwgeom/Makefile lwgeom/Makefile lwgeom/sqldefines.h loader/Makefile.pgsql2shp loader/Makefile.shp2pgsql regress/Makefile doc/Makefile])
361
Note: See TracBrowser for help on using the repository browser.