]> granicus.if.org Git - postgis/commitdiff
Add libxml2 support (needed by GeomFromGML)
authorOlivier Courtin <olivier.courtin@camptocamp.com>
Tue, 20 Oct 2009 12:51:40 +0000 (12:51 +0000)
committerOlivier Courtin <olivier.courtin@camptocamp.com>
Tue, 20 Oct 2009 12:51:40 +0000 (12:51 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@4666 b70326c6-7e19-0410-871a-916f4a2858ee

configure.ac
postgis/sqldefines.h.in

index c2370b5c7e9a1e23b467db83feb84b0c69ab5fbe..672b1b012fe258a068ff811ebeec3d3b7dc0f40c 100644 (file)
@@ -330,6 +330,67 @@ AC_DEFINE_UNQUOTED([POSTGIS_PGSQL_VERSION], [$POSTGIS_PGSQL_VERSION], [PostgreSQ
 AC_SUBST([POSTGIS_PGSQL_VERSION])
 
 
+dnl ===========================================================================
+dnl Detect libxml2 if it is installed
+dnl (needed to GeomFromGML function, but not required to PostGIS build)
+dnl ===========================================================================
+
+AC_ARG_WITH([xml2config], 
+       [AS_HELP_STRING([--with-xml2config=FILE], [specify an alternative xml2-config file])], 
+       [XML2CONFIG="$withval"], [XML2CONFIG=""])
+
+if test "x$XML2CONFIG" = "x"; then
+       dnl XML2CONFIG was not specified, so search within the current path
+       AC_PATH_PROG([XML2CONFIG], [xml2-config])
+
+       dnl If we couldn't find xml2-config, display a warning
+       if test "x$XML2CONFIG" = "x"; then
+               AC_MSG_WARN([could not find xml2-config from libxml2, some imports functions will be desactivated])
+       else
+               FOUND_LIBXML2=1
+       fi
+else
+       dnl XML2CONFIG was specified; display a message to the user
+       if test "x$XML2CONFIG" = "xyes"; then
+               AC_MSG_ERROR([you must specify a parameter to --with-xml2config, e.g. --with-xml2config=/path/to/xml2-config])
+       else
+               if test -f $XML2CONFIG; then
+                       AC_MSG_RESULT([Using user-specified xml2-config file: $XML2CONFIG])
+                       FOUND_LIBXML2=1
+               else
+                       AC_MSG_ERROR([the user-specified xml2-config file $XML2CONFIG does not exist])
+               fi      
+       fi
+fi
+
+dnl xml2-config founded, retrieve flags and version
+if test "$FOUND_LIBXML2" = "1"; then
+
+       dnl Extract the linker and include flags 
+       XML2_LDFLAGS=`$XML2CONFIG --libs`
+       XML2_CPPFLAGS=`$XML2CONFIG --cflags`
+
+       dnl Extract the version
+       XML2_VERSION=`$XML2CONFIG --version`
+
+       dnl Check headers file
+       CPPFLAGS_SAVE="$CPPFLAGS"
+       CPPFLAGS="$XML2_CPPFLAGS"
+       AC_CHECK_HEADERS([libxml/tree.h libxml/parser.h], [HAVE_LIBXML2=1], [AC_MSG_ERROR([could not find libxml/tree.h and/or libxml/parser.h related to libxml2])])
+
+       dnl Ensure we can link against libxml2
+       LIBS_SAVE="$LIBS"
+       LIBS="$XML2_LDFLAGS"
+       AC_CHECK_LIB([xml2], [xmlInitParser], [], [AC_MSG_ERROR([could not find libxml2])], [])
+
+       AC_DEFINE_UNQUOTED([HAVE_LIBXML2], [$HAVE_LIBXML2], [libxml/tree.h libxml/parser.h header])
+       AC_SUBST([HAVE_LIBXML2])
+fi
+
+
+
+
+
 
 dnl ===========================================================================
 dnl Detect the version of GEOS installed on the system
@@ -532,10 +593,10 @@ dnl Always enable use of ANALYZE statistics by default
 AC_DEFINE_UNQUOTED([POSTGIS_USE_STATS], [1], [Enable use of ANALYZE statistics])
 
 
-CPPFLAGS="$PGSQL_CPPFLAGS $GEOS_CPPFLAGS $PROJ_CPPFLAGS"
+CPPFLAGS="$PGSQL_CPPFLAGS $GEOS_CPPFLAGS $PROJ_CPPFLAGS $XML2_CPPFLAGS"
 dnl AC_MSG_RESULT([CPPFLAGS: $CPPFLAGS])
 
-SHLIB_LINK="$PGSQL_LDFLAGS $GEOS_LDFLAGS $PROJ_LDFLAGS -lgeos_c -lproj"
+SHLIB_LINK="$PGSQL_LDFLAGS $GEOS_LDFLAGS $PROJ_LDFLAGS -lgeos_c -lproj $XML2_LDFLAGS"
 AC_SUBST([SHLIB_LINK])
 dnl AC_MSG_RESULT([SHLIB_LINK: $SHLIB_LINK])
 
@@ -559,6 +620,8 @@ AC_MSG_RESULT([  GEOS version:         ${GEOS_MAJOR_VERSION}.${GEOS_MINOR_VERSIO
 AC_MSG_RESULT([  PostgreSQL config:    ${PGCONFIG}])
 AC_MSG_RESULT([  PostgreSQL version:   ${PGSQL_MAJOR_VERSION}.${PGSQL_MINOR_VERSION}])
 AC_MSG_RESULT([  PROJ4 version:        ${POSTGIS_PROJ_VERSION}])
+AC_MSG_RESULT([  Libxml2 config:       ${XML2CONFIG}])
+AC_MSG_RESULT([  Libxml2 version:      ${XML2_VERSION}])
 AC_MSG_RESULT([  PostGIS debug level:  ${POSTGIS_DEBUG_LEVEL}])
 AC_MSG_RESULT()
 AC_MSG_RESULT([ -------- Documentation Generation -------- ])
index 81dbd079172c026625b3067247450fbfd0603a36..2dc1f5cf0be30940694776815db464a484dc774b 100644 (file)
@@ -17,4 +17,9 @@
 #define _POSTGIS_SQL_SELECT_POSTGIS_BUILD_DATE 'SELECT ''@POSTGIS_BUILD_DATE@''::text AS version'
 #define _POSTGIS_SQL_SELECT_POSTGIS_SCRIPTS_VERSION 'SELECT ''@POSTGIS_SCRIPTS_VERSION@''::text AS version'
 
+/* 
+ * libxml2 support
+ */
+#define HAVE_LIBXML2 @HAVE_LIBXML2@
+
 #endif /* _LWPGIS_DEFINES */