]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
ESI: protect build from missing libraries correctly
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 1 Oct 2009 07:59:00 +0000 (19:59 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 1 Oct 2009 07:59:00 +0000 (19:59 +1200)
 - detect the libexpat and libxml2 headers.
 - wraps the code includes according to Squid guidelines
 - wraps the library API modules for build only when library is present

configure.in
src/esi/ExpatParser.cc
src/esi/ExpatParser.h
src/esi/Libxml2Parser.cc
src/esi/Libxml2Parser.h

index b9bd54c7db93f58f0a2fd299f945bcacf1b9d946..d951dc9f2b35031510c3d77e00fdf89f6e6d349f 100644 (file)
@@ -853,6 +853,7 @@ if test "$use_esi" = "yes" ; then
   AC_ARG_WITH(expat, AS_HELP_STRING([--without-libexpat],[Do not use libexpat for ESI. Default: auto-detect]))
   if test "$with_expat" != "no" ; then
     AC_CHECK_LIB([expat], [main], [EXPATLIB="-lexpat"; HAVE_LIBEXPAT=1])
+    AC_CHECK_HEADERS([expat.h])
     AC_DEFINE_UNQUOTED(HAVE_LIBEXPAT, $HAVE_LIBEXPAT, [Define to 1 if you have the expat library])
     if test "$with_expat" = "yes" && test "$HAVE_LIBEXPAT" != "1" ; then
       AC_MSG_ERROR([Required library libexpat is not able to be found.])
@@ -862,6 +863,7 @@ if test "$use_esi" = "yes" ; then
   AC_ARG_WITH(xml2, AS_HELP_STRING([--without-libxml2],[Do not use libxml2 for ESI. Default: auto-detect]))
   if test "$with_xml2" != "no" ; then
     AC_CHECK_LIB([xml2], [main], [XMLLIB="-lxml2"; HAVE_LIBXML2=1])
+    AC_CHECK_HEADERS([libxml/parser.h libxml/HTMLparser.h libxml/HTMLtree.h])
     AC_DEFINE_UNQUOTED(HAVE_LIBXML2, $HAVE_LIBXML2, [Define to 1 if you have the libxml2 library])
     if test "$with_xml2" = "yes" && test "$HAVE_LIBXML2" != "1" ; then
       AC_MSG_ERROR([Required library libxml2 is not able to be found.])
index 6bdb0fd9c182b65a415fc59753f8203fef192063..3019af08ec8d1e55622f4fe6cf042493becc01f0 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "squid.h"
 
-#if USE_SQUID_ESI
+#if USE_SQUID_ESI && HAVE_LIBEXPAT
 
 #include "esi/ExpatParser.h"
 
index dfc5045a514190ce517a5be0206ed2791b17114e..76246d75fb318c8eabb13e8b4bb4ee4356cb5459 100644 (file)
 #ifndef SQUID_ESIEXPATPARSER_H
 #define SQUID_ESIEXPATPARSER_H
 
-#if USE_SQUID_ESI
+#include "config.h"
+
+#if USE_SQUID_ESI && HAVE_LIBEXPAT
 
 #include "esi/Parser.h"
+
+#if HAVE_EXPAT_H
 #include <expat.h>
+#endif
 
 class ESIExpatParser : public ESIParser
 {
index e0fc3562cc4740707d0a0d6134e713970fa43206..8f1a7faa6a861049afcb85d49d0a3453e64e5b52 100644 (file)
@@ -39,7 +39,7 @@
 
 #include "squid.h"
 
-#if USE_SQUID_ESI
+#if USE_SQUID_ESI && HAVE_LIBXML2
 
 #include "esi/Libxml2Parser.h"
 
index c360930bb9589dcfdf1ef33200a789dcf3cce248..1dd093983e81ed2abaaf4a9f185ad79d38dd91e8 100644 (file)
@@ -40,7 +40,9 @@
 #ifndef SQUID_ESILIBXML2PARSER_H
 #define SQUID_ESILIBXML2PARSER_H
 
-#if USE_SQUID_ESI
+#include "config.h"
+
+#if USE_SQUID_ESI && HAVE_LIBXML2
 
 #include "esi/Parser.h"
 // workaround for definition of "free" that prevents include of
 #define OLD_FREE free
 #undef free
 #endif
+#if HAVE_LIBXML_PARSER_H
 #include <libxml/parser.h>
+#endif
+#if HAVE_LIBXML_HTMLPARSER_H
 #include <libxml/HTMLparser.h>
+#endif
+#if HAVE_LIBXML_HTMLTREE_H
 #include <libxml/HTMLtree.h>
+#endif
 
 #ifdef OLD_FREE
 #define free OLD_FREE