]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Make ESI parser modules expat and libxml2 dependent on their libraries
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Sat, 26 Sep 2009 22:15:12 +0000 (00:15 +0200)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Sat, 26 Sep 2009 22:15:12 +0000 (00:15 +0200)
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.

configure.in
src/esi/Makefile.am
src/esi/Module.cc

index b111b425d9a9635460a3fdfbd2462063c4521da8..0457d7c6a5709e8de9eb1927f9d182f515e3e042 100644 (file)
@@ -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])
index bbd58b7ed6c87ae6e5a4bd0ab8c5c183d6027850..8158a45b8d222cda1905e128debae329efb88fc9 100644 (file)
@@ -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 \
index 5d7b71875e4bce4ce25f2d2895fb27b5943041d3..df2638cbaecd4a8f9d448513d8af5679dfffd32f 100644 (file)
@@ -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;
 }