apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r1085350 - in /apr/apr/trunk: build/apu-conf.m4 build/xml.m4 configure.in include/apr.h.in xml/apr_xml_expat.c xml/apr_xml_libxml2.c
Date Fri, 25 Mar 2011 12:42:53 GMT
Author: niq
Date: Fri Mar 25 12:42:53 2011
New Revision: 1085350

URL: http://svn.apache.org/viewvc?rev=1085350&view=rev
Log:
Support selection of libxml2 vs expat in autoconf build.

Added:
    apr/apr/trunk/build/xml.m4
Modified:
    apr/apr/trunk/build/apu-conf.m4
    apr/apr/trunk/configure.in
    apr/apr/trunk/include/apr.h.in
    apr/apr/trunk/xml/apr_xml_expat.c
    apr/apr/trunk/xml/apr_xml_libxml2.c

Modified: apr/apr/trunk/build/apu-conf.m4
URL: http://svn.apache.org/viewvc/apr/apr/trunk/build/apu-conf.m4?rev=1085350&r1=1085349&r2=1085350&view=diff
==============================================================================
--- apr/apr/trunk/build/apu-conf.m4 (original)
+++ apr/apr/trunk/build/apu-conf.m4 Fri Mar 25 12:42:53 2011
@@ -46,117 +46,6 @@ AC_DEFUN([APU_FIND_APR], [
   AC_SUBST(APR_BUILD_DIR)
 ])
 
-dnl
-dnl APU_TRY_EXPAT_LINK(
-dnl      test-message, cache-var-name, hdrs, libs,
-dnl      [actions-on-success], [actions-on-failure])
-dnl         
-dnl Tests linking against expat with libraries 'libs' and includes
-dnl 'hdrs', passing message + cache-var-name to AC_CACHE_CHECK.
-dnl On success, sets $expat_libs to libs, sets $apu_have_expat to 1, 
-dnl and runs actions-on-success; on failure runs actions-on-failure.
-dnl
-AC_DEFUN([APU_TRY_EXPAT_LINK], [
-AC_CACHE_CHECK([$1], [$2], [
-  apu_expat_LIBS=$LIBS
-  apu_expat_CPPFLAGS=$CPPFLAGS
-  LIBS="$LIBS $4"
-  CPPFLAGS="$CPPFLAGS $INCLUDES"
-  AC_TRY_LINK([#include <stdlib.h>
-#include <$3>], [XML_ParserCreate(NULL);],
-    [$2=yes], [$2=no])
-  LIBS=$apu_expat_LIBS
-  CPPFLAGS=$apu_expat_CPPFLAGS
-])
-
-if test $[$2] = yes; then
-   AC_DEFINE([HAVE_]translit([$3], [a-z./], [A-Z__]), 1,
-             [Define if $3 is available])
-   apu_expat_libs="$4"
-   apu_has_expat=1
-   $5
-else
-   apu_has_expat=0
-   $6
-fi
-])
-
-dnl
-dnl APU_SYSTEM_EXPAT: tests for a system expat installation
-dnl If present, sets $apu_has_expat to 1 and adjusts LDFLAGS/CPPFLAGS
-dnl appropriately.  This is mostly for compatibility with existing
-dnl expat releases; all but the first APU_TRY_EXPAT_LINK call could
-dnl be dropped later.
-dnl
-AC_DEFUN([APU_SYSTEM_EXPAT], [
- 
-  APU_TRY_EXPAT_LINK([Expat 1.95.x], apu_cv_expat_system, 
-    [expat.h], [-lexpat])
-
-  if test $apu_has_expat = 0; then
-    APU_TRY_EXPAT_LINK([old Debian-packaged expat], apu_cv_expat_debian,
-       [xmltok/xmlparse.h], [-lxmlparse -lxmltok])
-  fi
-
-  if test $apu_has_expat = 0; then
-    APU_TRY_EXPAT_LINK([old FreeBSD-packaged expat], apu_cv_expat_freebsd,
-       [xml/xmlparse.h], [-lexpat])
-  fi
-
-  if test $apu_has_expat = 0; then
-    APU_TRY_EXPAT_LINK([Expat 1.0/1.1], apu_cv_expat_1011,
-       [xmlparse/xmlparse.h], [-lexpat])
-  fi
-
-  if test $apu_has_expat = 0; then
-    APR_ADDTO(LDFLAGS, [-L/usr/local/lib])
-    APR_ADDTO(INCLUDES, [-I/usr/local/include])
- 
-    APU_TRY_EXPAT_LINK([Expat 1.95.x in /usr/local], 
-       apu_cv_expat_usrlocal, [expat.h], [-lexpat], [], [
-       APR_REMOVEFROM(LDFLAGS, [-L/usr/local/lib])
-       APR_REMOVEFROM(INCLUDES, [-I/usr/local/include])
-      ])
-  fi
-])
-
-
-dnl
-dnl APU_FIND_EXPAT: figure out where EXPAT is located (or use bundled)
-dnl
-AC_DEFUN([APU_FIND_EXPAT], [
-
-save_cppflags="$CPPFLAGS"
-
-apu_has_expat=0
-
-AC_ARG_WITH([expat],
-[  --with-expat=DIR        specify Expat location], [
-  if test "$withval" = "yes"; then
-    AC_MSG_ERROR([a directory must be specified for --with-expat])
-  elif test "$withval" = "no"; then
-    AC_MSG_ERROR([Expat cannot be disabled (at this time)])
-  else
-    # Add given path to standard search paths if appropriate:
-    if test "$withval" != "/usr"; then
-      APR_ADDTO(INCLUDES, [-I$withval/include])
-      APR_ADDTO(LDFLAGS, [-L$withval/lib])
-    fi
-  fi
-])
-
-APU_SYSTEM_EXPAT
-test ${apu_has_expat} != "1" && AC_MSG_ERROR(could not find Expat)
-
-APR_ADDTO(APRUTIL_EXPORT_LIBS, [$apu_expat_libs])
-APR_ADDTO(LIBS, [$apu_expat_libs])
-
-APR_XML_DIR=$bundled_subdir
-AC_SUBST(APR_XML_DIR)
-
-CPPFLAGS=$save_cppflags
-])
-
 
 dnl 
 dnl Find a particular LDAP library

Added: apr/apr/trunk/build/xml.m4
URL: http://svn.apache.org/viewvc/apr/apr/trunk/build/xml.m4?rev=1085350&view=auto
==============================================================================
--- apr/apr/trunk/build/xml.m4 (added)
+++ apr/apr/trunk/build/xml.m4 Fri Mar 25 12:42:53 2011
@@ -0,0 +1,211 @@
+dnl -------------------------------------------------------- -*- autoconf -*-
+dnl Licensed to the Apache Software Foundation (ASF) under one or more
+dnl contributor license agreements.  See the NOTICE file distributed with
+dnl this work for additional information regarding copyright ownership.
+dnl The ASF licenses this file to You under the Apache License, Version 2.0
+dnl (the "License"); you may not use this file except in compliance with
+dnl the License.  You may obtain a copy of the License at
+dnl
+dnl     http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+
+
+dnl
+dnl APU_TRY_EXPAT_LINK(
+dnl      test-message, cache-var-name, hdrs, libs,
+dnl      [actions-on-success], [actions-on-failure])
+dnl         
+dnl Tests linking against expat with libraries 'libs' and includes
+dnl 'hdrs', passing message + cache-var-name to AC_CACHE_CHECK.
+dnl On success, sets $expat_libs to libs, sets $apu_has_expat to 1, 
+dnl and runs actions-on-success; on failure runs actions-on-failure.
+dnl
+AC_DEFUN([APU_TRY_EXPAT_LINK], [
+AC_CACHE_CHECK([$1], [$2], [
+  apu_expat_LIBS=$LIBS
+  apu_expat_CPPFLAGS=$CPPFLAGS
+  LIBS="$LIBS $4"
+  CPPFLAGS="$CPPFLAGS $INCLUDES"
+  AC_TRY_LINK([#include <stdlib.h>
+#include <$3>], [XML_ParserCreate(NULL);],
+    [$2=yes], [$2=no])
+  LIBS=$apu_expat_LIBS
+  CPPFLAGS=$apu_expat_CPPFLAGS
+])
+
+if test $[$2] = yes; then
+   AC_DEFINE([HAVE_]translit([$3], [a-z./], [A-Z__]), 1,
+             [Define if $3 is available])
+   apu_expat_libs="$4"
+   apu_has_expat=1
+   $5
+   AC_SUBST(apu_has_expat)
+else
+   apu_has_expat=0
+   $6
+fi
+])
+
+dnl
+dnl APU_SYSTEM_EXPAT: tests for a system expat installation
+dnl If present, sets $apu_has_expat to 1 and adjusts LDFLAGS/CPPFLAGS
+dnl appropriately.  This is mostly for compatibility with existing
+dnl expat releases; all but the first APU_TRY_EXPAT_LINK call could
+dnl be dropped later.
+dnl
+AC_DEFUN([APU_SYSTEM_EXPAT], [
+ 
+  APU_TRY_EXPAT_LINK([Expat 1.95.x], apu_cv_expat_system, 
+    [expat.h], [-lexpat])
+
+  if test $apu_has_expat = 0; then
+    APU_TRY_EXPAT_LINK([old Debian-packaged expat], apu_cv_expat_debian,
+       [xmltok/xmlparse.h], [-lxmlparse -lxmltok])
+  fi
+
+  if test $apu_has_expat = 0; then
+    APU_TRY_EXPAT_LINK([old FreeBSD-packaged expat], apu_cv_expat_freebsd,
+       [xml/xmlparse.h], [-lexpat])
+  fi
+
+  if test $apu_has_expat = 0; then
+    APU_TRY_EXPAT_LINK([Expat 1.0/1.1], apu_cv_expat_1011,
+       [xmlparse/xmlparse.h], [-lexpat])
+  fi
+
+  if test $apu_has_expat = 0; then
+    APR_ADDTO(LDFLAGS, [-L/usr/local/lib])
+    APR_ADDTO(INCLUDES, [-I/usr/local/include])
+ 
+    APU_TRY_EXPAT_LINK([Expat 1.95.x in /usr/local], 
+       apu_cv_expat_usrlocal, [expat.h], [-lexpat], [], [
+       APR_REMOVEFROM(LDFLAGS, [-L/usr/local/lib])
+       APR_REMOVEFROM(INCLUDES, [-I/usr/local/include])
+      ])
+  fi
+])
+
+
+dnl
+dnl APU_FIND_EXPAT: figure out where EXPAT is located (or use bundled)
+dnl
+AC_DEFUN([APU_FIND_EXPAT], [
+
+save_cppflags="$CPPFLAGS"
+
+apu_has_expat=0
+
+AC_ARG_WITH([expat],
+[  --with-expat=DIR        specify Expat location], [
+  if test "$withval" = "yes"; then
+    AC_MSG_ERROR([a directory must be specified for --with-expat])
+  elif test "$withval" = "no"; then
+    if test "$apu_has_libxml2" != "1"; then
+      AC_MSG_ERROR([An XML parser is required!  If you disable expat, you must select --with-libxml2])
+    fi
+  else
+    # Add given path to standard search paths if appropriate:
+    if test "$apu_has_libxml2" = "1"; then
+      AC_MSG_ERROR(Cannot build with both expat and libxml2 - please select one)
+    fi
+    if test "$withval" != "/usr"; then
+      APR_ADDTO(INCLUDES, [-I$withval/include])
+      APR_ADDTO(LDFLAGS, [-L$withval/lib])
+    fi
+  fi
+])
+
+if test "$apu_has_libxml2" != "1"; then
+  APU_SYSTEM_EXPAT
+
+  APR_ADDTO(APRUTIL_EXPORT_LIBS, [$apu_expat_libs])
+  APR_ADDTO(LIBS, [$apu_expat_libs])
+
+  APR_XML_DIR=$bundled_subdir
+  AC_SUBST(APR_XML_DIR)
+fi
+
+CPPFLAGS=$save_cppflags
+])
+
+
+dnl
+dnl APU_FIND_LIBXML2: figure out where LIBXML2 is located (or use bundled)
+dnl
+AC_DEFUN([APU_FIND_LIBXML2], [
+
+save_cppflags="$CPPFLAGS"
+
+apu_has_libxml2=0
+apu_try_libxml2=0
+
+AC_ARG_WITH([libxml2],
+[  --with-libxml2=DIR      specify libxml2 location], [
+  if test "$withval" = "yes"; then
+    apu_try_libxml2=1
+    APR_ADDTO(INCLUDES, [-I/usr/include/libxml2])
+  elif test "$withval" != "no"; then
+    apu_try_libxml2=1
+    APR_ADDTO(INCLUDES, [-I$withval/include/libxml2])
+    if test "$withval" != "/usr"; then
+      APR_ADDTO(LDFLAGS, [-L$withval/lib])
+    fi
+  fi
+  if test ${apu_try_libxml2} = "1" ; then
+
+    #test for libxml2
+    AC_CACHE_CHECK([libxml2], [apu_cv_libxml2], [
+      apu_libxml2_CPPFLAGS=$CPPFLAGS
+      apu_libxml2_LIBS="$LIBS -lxml2"
+      CPPFLAGS="$CPPFLAGS $INCLUDES"
+      LIBS="$LIBS -lxml2"
+      AC_TRY_LINK(
+        [#include <libxml/parser.h>],
+        [xmlSAXHandler sax; xmlCreatePushParserCtxt(&sax, NULL, NULL, 0, NULL);],
+        [apu_cv_libxml2=yes],
+        [apu_cv_libxml2=no],
+      )
+      CPPFLAGS=$apu_libxml2_CPPFLAGS
+      LIBS=$apu_libxml2_LIBS
+    ])
+    if test $apu_cv_libxml2 = yes ; then
+      AC_DEFINE([HAVE_LIBXML2_H], 1, [libxml2 found])
+      apu_has_libxml2=1
+    else
+      apu_has_libxml2=0
+    fi
+  fi
+])
+AC_SUBST(apu_has_libxml2)
+
+if test ${apu_has_libxml2} = "1" ; then
+  APR_ADDTO(APRUTIL_EXPORT_LIBS, [-lxml2])
+  APR_ADDTO(LIBS, [-lxml2])
+fi
+
+CPPFLAGS=$save_cppflags
+])
+
+dnl
+dnl APU_FIND_XML: Find an XML library
+dnl
+dnl Logic: we need exactly one but not both XML libraries
+dnl        Make expat the default for back-compatibility.
+dnl        Use libxml2 if a --with-libxml2 is specified (and works),
+dnl        otherwise expat.
+dnl
+AC_DEFUN([APU_FIND_XML], [
+APU_FIND_LIBXML2
+APU_FIND_EXPAT
+
+if test ${apu_has_expat} = "1" && test ${apu_has_libxml2} = "1" ; then
+  AC_MSG_ERROR(Cannot build with both expat and libxml2 - please select one)
+elif test ${apu_has_expat} != "1" && test ${apu_has_libxml2} != "1" ; then
+  AC_MSG_ERROR(No XML parser found!  Please specify --with-expat or --with-libxml2)
+fi
+])

Modified: apr/apr/trunk/configure.in
URL: http://svn.apache.org/viewvc/apr/apr/trunk/configure.in?rev=1085350&r1=1085349&r2=1085350&view=diff
==============================================================================
--- apr/apr/trunk/configure.in (original)
+++ apr/apr/trunk/configure.in Fri Mar 25 12:42:53 2011
@@ -27,6 +27,7 @@ sinclude(build/ltversion.m4)
 sinclude(build/lt~obsolete.m4)
 
 sinclude(build/apu-conf.m4)
+sinclude(build/xml.m4)
 sinclude(build/apu-hints.m4)
 sinclude(build/crypto.m4)
 sinclude(build/dbm.m4)
@@ -2598,8 +2599,8 @@ APU_CHECK_DBD_ORACLE
 APU_CHECK_DBD_FREETDS
 APU_CHECK_DBD_ODBC
 
-dnl Find Expat
-APU_FIND_EXPAT
+dnl select an XML parser
+APU_FIND_XML
 
 dnl Find iconv implementations
 APU_FIND_ICONV

Modified: apr/apr/trunk/include/apr.h.in
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr.h.in?rev=1085350&r1=1085349&r2=1085350&view=diff
==============================================================================
--- apr/apr/trunk/include/apr.h.in (original)
+++ apr/apr/trunk/include/apr.h.in Fri Mar 25 12:42:53 2011
@@ -667,6 +667,9 @@ typedef int apr_wait_t;
 #define APU_HAVE_ICONV         @have_iconv@
 #define APR_HAS_XLATE          (APU_HAVE_ICONV)
 
+#define APU_USE_EXPAT          @apu_has_expat@
+#define APU_USE_LIBXML2	       @apu_has_libxml2@
+
 /* Definitions that only Win32 programs need to compile properly. */
 
 /* XXX These simply don't belong here, perhaps in apr_portable.h

Modified: apr/apr/trunk/xml/apr_xml_expat.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/xml/apr_xml_expat.c?rev=1085350&r1=1085349&r2=1085350&view=diff
==============================================================================
--- apr/apr/trunk/xml/apr_xml_expat.c (original)
+++ apr/apr/trunk/xml/apr_xml_expat.c Fri Mar 25 12:42:53 2011
@@ -15,6 +15,8 @@
  */
 
 #include "apr.h"
+
+#if APU_USE_EXPAT
 #include "apr_xml.h"
 
 #if defined(HAVE_XMLPARSE_XMLPARSE_H)
@@ -132,3 +134,4 @@ APR_DECLARE(apr_xml_parser *) apr_xml_pa
 
     return parser;
 }
+#endif

Modified: apr/apr/trunk/xml/apr_xml_libxml2.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/xml/apr_xml_libxml2.c?rev=1085350&r1=1085349&r2=1085350&view=diff
==============================================================================
--- apr/apr/trunk/xml/apr_xml_libxml2.c (original)
+++ apr/apr/trunk/xml/apr_xml_libxml2.c Fri Mar 25 12:42:53 2011
@@ -15,6 +15,8 @@
  */
 
 #include "apr.h"
+
+#if APU_USE_LIBXML2
 #include "apr_xml.h"
 
 #include <libxml/parser.h>
@@ -94,3 +96,4 @@ APR_DECLARE(apr_xml_parser *) apr_xml_pa
 
     return parser;
 }
+#endif



Mime
View raw message