From: Henrik Nordstrom Date: Sat, 26 Sep 2009 22:15:12 +0000 (+0200) Subject: Make ESI parser modules expat and libxml2 dependent on their libraries X-Git-Tag: SQUID_3_2_0_1~691 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=23df48fdac57cdca03122a058f98a07a5dfe42a6;p=thirdparty%2Fsquid.git Make ESI parser modules expat and libxml2 dependent on their libraries The ESI parser system is actually pluggable. There is no reason we should require expat and libxml2. Just build what works. Todo: Add an option to force the desired parsers. --- diff --git a/configure.in b/configure.in index b111b425d9..0457d7c6a5 100644 --- a/configure.in +++ b/configure.in @@ -848,18 +848,24 @@ AC_ARG_ENABLE(esi, if test "$use_esi" = "yes" ; then AC_DEFINE(USE_SQUID_ESI,1,[Compile the ESI processor and Surrogate header support]) AM_CONDITIONAL(USE_ESI, true) - - dnl Perform configuration consistency checks for ESI - dnl ESI support requires libexpat - AC_CHECK_LIB([expat], [main], - [ESI_LIBS="-lexpat"], - [AC_MSG_FAILURE([ESI support requires libexpat library, but no usable library was found])] - ) - AC_CHECK_LIB([xml2], [main], - [ESI_LIBS="-lxml2"], - [AC_MSG_FAILURE([ESI support requires libxml2 library, but no usable library was found])] - ) - XTRA_LIBS="$XTRA_LIBS -lexpat -lxml2" + ESI_LIBS= + HAVE_LIBEXPAT=0 + AC_CHECK_LIB([expat], [main], [ESI_LIBS="$ESI_LIBS -lexpat"; HAVE_LIBEXPAT=1]) + AC_DEFINE(HAVE_LIBEXPAT, $HAVE_LIBEXPAT, "Define to 1 if you have the expat library") + if test "$HAVE_LIBEXPAT" = 1; then + AM_CONDITIONAL(HAVE_LIBEXPAT, true) + else + AM_CONDITIONAL(HAVE_LIBEXPAT, false) + fi + HAVE_LIBXML2= + AC_CHECK_LIB([xml2], [main], [ESI_LIBS="$ESI_IBS -lxml2"; HAVE_LIBXML2=1]) + AC_DEFINE(HAVE_LIBXML2, $HAVE_LIBXML2, "Define to 1 if you have the libxml2 library") + if test "$HAVE_LIBXML2" = 1; then + AM_CONDITIONAL(HAVE_LIBXML2, true) + else + AM_CONDITIONAL(HAVE_LIBXML2, false) + fi + XTRA_LIBS="$XTRA_LIBS $ESI_LIBS" else AC_DEFINE(USE_SQUID_ESI,0,[Compile the ESI processor and Surrogate header support]) diff --git a/src/esi/Makefile.am b/src/esi/Makefile.am index bbd58b7ed6..8158a45b8d 100644 --- a/src/esi/Makefile.am +++ b/src/esi/Makefile.am @@ -3,28 +3,39 @@ include $(top_srcdir)/src/TestHeaders.am noinst_LTLIBRARIES = libesi.la +ESI_PARSER_SOURCES = \ + CustomParser.cc \ + CustomParser.h + +if HAVE_LIBEXPAT +ESI_PARSER_SOURCES += \ + ExpatParser.cc \ + ExpatParser.h +endif + +if HAVE_LIBXML2 +ESI_PARSER_SOURCES += \ + Libxml2Parser.cc \ + Libxml2Parser.h +endif + libesi_la_SOURCES = \ Assign.cc \ Assign.h \ Attempt.h \ Context.cc \ Context.h \ - CustomParser.cc \ - CustomParser.h \ + $(ESI_PARSER_SOURCES) \ Element.h \ ElementList.h \ Esi.cc \ Esi.h \ Except.h \ - ExpatParser.cc \ - ExpatParser.h \ Expression.cc \ Expression.h \ Include.cc \ Include.h \ Literal.h \ - Libxml2Parser.cc \ - Libxml2Parser.h \ Module.cc \ Module.h \ Parser.cc \ diff --git a/src/esi/Module.cc b/src/esi/Module.cc index 5d7b71875e..df2638cbae 100644 --- a/src/esi/Module.cc +++ b/src/esi/Module.cc @@ -5,26 +5,42 @@ #include "esi/ExpatParser.h" /* must follow esi/Libxml2Parser.h */ static ESIParser::Register *prCustom = 0; +#if HAVE_LIBXML2 static ESIParser::Register *prLibxml = 0; +#endif +#if HAVE_LIBEXPAT static ESIParser::Register *prExpat = 0; +#endif void Esi::Init() { assert(!prCustom); // we should be called once + prCustom = new ESIParser::Register("custom", &ESICustomParser::NewParser); + +#if HAVE_LIBXML2 prLibxml = new ESIParser::Register("libxml2", &ESILibxml2Parser::NewParser); +#endif + +#if HAVE_LIBEXPAT prExpat = new ESIParser::Register("expat", &ESIExpatParser::NewParser); +#endif } void Esi::Clean() { assert(prCustom); // we should be called once, and only after Init() +#if HAVE_LIBEXPAT delete prExpat; - delete prLibxml; - delete prCustom; - prExpat = NULL; +#endif + +#if HAVE_LIBXML2 + delete prLibxml; prLibxml = NULL; +#endif + + delete prCustom; prCustom = NULL; }