From: Amos Jeffries Date: Thu, 1 Oct 2009 07:59:00 +0000 (+1200) Subject: ESI: protect build from missing libraries correctly X-Git-Tag: SQUID_3_2_0_1~681 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=95cd90228fd30b0fa2e4b9014e296f44f93e57b8;p=thirdparty%2Fsquid.git ESI: protect build from missing libraries correctly - 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 --- diff --git a/configure.in b/configure.in index b9bd54c7db..d951dc9f2b 100644 --- a/configure.in +++ b/configure.in @@ -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.]) diff --git a/src/esi/ExpatParser.cc b/src/esi/ExpatParser.cc index 6bdb0fd9c1..3019af08ec 100644 --- a/src/esi/ExpatParser.cc +++ b/src/esi/ExpatParser.cc @@ -35,7 +35,7 @@ #include "squid.h" -#if USE_SQUID_ESI +#if USE_SQUID_ESI && HAVE_LIBEXPAT #include "esi/ExpatParser.h" diff --git a/src/esi/ExpatParser.h b/src/esi/ExpatParser.h index dfc5045a51..76246d75fb 100644 --- a/src/esi/ExpatParser.h +++ b/src/esi/ExpatParser.h @@ -33,10 +33,15 @@ #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 +#endif class ESIExpatParser : public ESIParser { diff --git a/src/esi/Libxml2Parser.cc b/src/esi/Libxml2Parser.cc index e0fc3562cc..8f1a7faa6a 100644 --- a/src/esi/Libxml2Parser.cc +++ b/src/esi/Libxml2Parser.cc @@ -39,7 +39,7 @@ #include "squid.h" -#if USE_SQUID_ESI +#if USE_SQUID_ESI && HAVE_LIBXML2 #include "esi/Libxml2Parser.h" diff --git a/src/esi/Libxml2Parser.h b/src/esi/Libxml2Parser.h index c360930bb9..1dd093983e 100644 --- a/src/esi/Libxml2Parser.h +++ b/src/esi/Libxml2Parser.h @@ -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 @@ -49,9 +51,15 @@ #define OLD_FREE free #undef free #endif +#if HAVE_LIBXML_PARSER_H #include +#endif +#if HAVE_LIBXML_HTMLPARSER_H #include +#endif +#if HAVE_LIBXML_HTMLTREE_H #include +#endif #ifdef OLD_FREE #define free OLD_FREE