2 dnl GEOS_INIT (MINIMUM_VERSION)
4 dnl Test for GEOS: define HAVE_GEOS, GEOS_LIBS, GEOS_C_LIBS, GEOS_CFLAGS, GEOS_VERSION
6 dnl Call as GEOS_INIT or GEOS_INIT(minimum version) in configure.in. Test
7 dnl HAVE_GEOS (yes|no) afterwards. If yes, all other vars above can be
11 dnl Now, --with-geos takes values: yes or no, or full path to the geos-config
12 dnl utility. Note that the utility can have different name,
13 dnl e.g. geos-config-cvs.
14 dnl Example: --with-geos=/home/foo/usr/bin/geos-config-cvs
16 AC_DEFUN([GEOS_INIT],[
20 AC_SUBST(GEOS_C_CFLAGS)
22 AC_SUBST(GEOS_VERSION)
24 if test x"$with_geos" = x"no" ; then
25 AC_MSG_RESULT([GEOS support disabled])
28 elif test x"$with_geos" = x"yes" -o x"$with_geos" = x"" ; then
29 AC_PATH_PROG([GEOS_CONFIG], [geos-config], [no])
31 ac_geos_config=`basename $with_geos`
32 ac_geos_config_dir=`dirname $with_geos`
39 [$ac_geos_config_dir],
44 min_geos_version=ifelse([$1], ,0.0.1,$1)
46 if test "$GEOS_CONFIG" = "no"; then
49 AC_MSG_CHECKING(for GEOS version >= $min_geos_version)
51 geos_major_version=`$GEOS_CONFIG --version | \
52 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
53 geos_minor_version=`$GEOS_CONFIG --version | \
54 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
55 geos_micro_version=`$GEOS_CONFIG --version | \
56 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
58 req_major=`echo $min_geos_version | \
59 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
60 req_minor=`echo $min_geos_version | \
61 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
62 req_micro=`echo $min_geos_version | \
63 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
66 ac_req_version=`expr $req_major \* 100000 \+ $req_minor \* 100 \+ $req_micro`
67 ac_geos_version=`expr $geos_major_version \* 100000 \+ $geos_minor_version \* 100 \+ $geos_micro_version`
69 if test $ac_req_version -le $ac_geos_version; then
73 if test $version_ok = "no"; then
76 if $GEOS_CONFIG --libs >/dev/null 2>&1; then
79 GEOS_LIBS="`$GEOS_CONFIG --libs`"
80 GEOS_C_LIBS="`$GEOS_CONFIG --ldflags` -lgeos_c"
81 GEOS_CFLAGS="`$GEOS_CONFIG --cflags`"
82 GEOS_VERSION="`$GEOS_CONFIG --version`"