Commit cb5541c9 authored by Nick Wellnhofer's avatar Nick Wellnhofer
Browse files

Fix libz and liblzma detection

If libz or liblzma are detected with pkg-config, AC_CHECK_HEADERS must
not be run because the correct CPPFLAGS aren't set. It is actually not
required have separate checks for LIBXML_ZLIB_ENABLED and HAVE_ZLIB_H.
Only check for LIBXML_ZLIB_ENABLED and remove HAVE_ZLIB_H macro.

Fixes bug 764657, bug 787041.
parent ddbb075b
......@@ -26,7 +26,7 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
......
......@@ -406,7 +406,6 @@
<!-- some other conditional defines -->
<set var="ZLIB_DEF"><if cond="WITH_ZLIB=='1'">HAVE_ZLIB_H</if></set>
<set var="DEBUG_DEF"><if cond="BUILD=='debug'">_DEBUG</if></set>
<set var="DEBUG_DEF"><if cond="BUILD=='release'">NDEBUG</if></set>
......
......@@ -2089,7 +2089,7 @@ xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
xmlC14NErrParam("saving doc");
return (-1);
}
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if (compression < 0)
compression = xmlGetCompressMode();
#endif
......
......@@ -389,18 +389,20 @@ dnl Checks for zlib library.
WITH_ZLIB=0
if test "$with_zlib" = "no"; then
echo "Disabling compression support"
echo "Disabling zlib compression support"
else
# Try pkg-config first so that static linking works.
# If this succeeeds, we ignore the WITH_ZLIB directory.
PKG_CHECK_MODULES([Z],[zlib],
[have_libz=yes],
[have_libz=no])
# Don't run pkg-config if with_zlib contains a path.
if test "x$Z_DIR" = "x"; then
# Try pkg-config first so that static linking works.
PKG_CHECK_MODULES([Z],[zlib],
[WITH_ZLIB=1],
[ ])
fi
if test "x$have_libz" = "xno"; then
if test "$WITH_ZLIB" = "0"; then
AC_CHECK_HEADERS(zlib.h,
AC_CHECK_LIB(z, gzread,[
have_libz=yes
WITH_ZLIB=1
if test "x${Z_DIR}" != "x"; then
Z_CFLAGS="-I${Z_DIR}/include"
Z_LIBS="-L${Z_DIR}/lib -lz"
......@@ -411,18 +413,8 @@ else
esac]
else
Z_LIBS="-lz"
fi],
[have_libz=no])
)
else
# we still need to check for zlib.h header
AC_CHECK_HEADERS([zlib.h])
fi
# Found the library via either method?
if test "x$have_libz" = "xyes"; then
AC_DEFINE([HAVE_LIBZ], [1], [Have compression library])
WITH_ZLIB=1
fi])
)
fi
fi
......@@ -436,38 +428,30 @@ dnl Checks for lzma library.
WITH_LZMA=0
if test "$with_lzma" = "no"; then
echo "Disabling compression support"
echo "Disabling lzma compression support"
else
# Try pkg-config first so that static linking works.
# If this succeeeds, we ignore the WITH_LZMA directory.
PKG_CHECK_MODULES([LZMA],[liblzma],
[have_liblzma=yes],
[have_liblzma=no])
# If pkg-config failed, fall back to AC_CHECK_LIB. This
# will not pick up the necessary LIBS flags for liblzma's
# private dependencies, though, so static linking may fail.
if test "x$have_liblzma" = "xno"; then
AC_CHECK_HEADERS(lzma.h,
# Don't run pkg-config if with_lzma contains a path.
if test "x$LZMA_DIR" = "x"; then
# Try pkg-config first so that static linking works.
PKG_CHECK_MODULES([LZMA],[liblzma],
[WITH_LZMA=1],
[ ])
fi
# If pkg-config failed, fall back to AC_CHECK_LIB. This
# will not pick up the necessary LIBS flags for liblzma's
# private dependencies, though, so static linking may fail.
if test "$WITH_LZMA" = "0"; then
AC_CHECK_HEADERS(lzma.h,
AC_CHECK_LIB(lzma, lzma_code,[
have_liblzma=yes
WITH_LZMA=1
if test "x${LZMA_DIR}" != "x"; then
LZMA_CFLAGS="-I${LZMA_DIR}/include"
LZMA_LIBS="-L${LZMA_DIR}/lib -llzma"
else
LZMA_LIBS="-llzma"
fi],
[have_liblzma=no])
)
else
# we still need to check for lzma,h header
AC_CHECK_HEADERS([lzma.h])
fi
# Found the library via either method?
if test "x$have_liblzma" = "xyes"; then
AC_DEFINE([HAVE_LIBLZMA], [1], [Have compression library])
WITH_LZMA=1
fi])
)
fi
fi
......
......@@ -174,9 +174,6 @@
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H
/* Define if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H
/* Name of package */
#define PACKAGE
......
......@@ -63,7 +63,7 @@
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
......@@ -145,7 +145,7 @@ typedef struct xmlNanoHTTPCtxt {
char *authHeader; /* contents of {WWW,Proxy}-Authenticate header */
char *encoding; /* encoding extracted from the contentType */
char *mimeType; /* Mime-Type extracted from the contentType */
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
z_stream *strm; /* Zlib stream object */
int usesGzip; /* "Content-Encoding: gzip" was detected */
#endif
......@@ -434,7 +434,7 @@ xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) {
if (ctxt->mimeType != NULL) xmlFree(ctxt->mimeType);
if (ctxt->location != NULL) xmlFree(ctxt->location);
if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader);
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if (ctxt->strm != NULL) {
inflateEnd(ctxt->strm);
xmlFree(ctxt->strm);
......@@ -817,7 +817,7 @@ xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) {
if (ctxt->authHeader != NULL)
xmlFree(ctxt->authHeader);
ctxt->authHeader = xmlMemStrdup(cur);
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
} else if ( !xmlStrncasecmp( BAD_CAST line, BAD_CAST"Content-Encoding:", 17) ) {
cur += 17;
while ((*cur == ' ') || (*cur == '\t')) cur++;
......@@ -1273,7 +1273,7 @@ xmlNanoHTTPOpenRedir(const char *URL, char **contentType, char **redir) {
int
xmlNanoHTTPRead(void *ctx, void *dest, int len) {
xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx;
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
int bytes_read = 0;
int orig_avail_in;
int z_ret;
......@@ -1283,7 +1283,7 @@ xmlNanoHTTPRead(void *ctx, void *dest, int len) {
if (dest == NULL) return(-1);
if (len <= 0) return(0);
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if (ctxt->usesGzip == 1) {
if (ctxt->strm == NULL) return(0);
......@@ -1424,7 +1424,7 @@ retry:
/* 1 for '?' */
blen += strlen(ctxt->query) + 1;
blen += strlen(method) + strlen(ctxt->path) + 24;
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
/* reserve for possible 'Accept-Encoding: gzip' string */
blen += 23;
#endif
......@@ -1468,7 +1468,7 @@ retry:
ctxt->hostname, ctxt->port);
}
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
p += snprintf(p, blen - (p - bp), "Accept-Encoding: gzip\r\n");
#endif
......
......@@ -90,9 +90,6 @@
/* Define if history library is there (-lhistory) */
#undef HAVE_LIBHISTORY
/* Have compression library */
#undef HAVE_LIBLZMA
/* Define if pthread library is there (-lpthread) */
#undef HAVE_LIBPTHREAD
......@@ -108,9 +105,6 @@
/* Define to 1 if you have the `localtime' function. */
#define HAVE_LOCALTIME 1
/* Define to 1 if you have the <lzma.h> header file. */
#undef HAVE_LZMA_H
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
......@@ -274,14 +268,6 @@
/* Define to 1 if you have the `vsprintf' function. */
#undef HAVE_VSPRINTF /* Use trio. */
/* Define to 1 if you have the <zlib.h> header file. */
/* Actually dependent on the compilation script. */
#if @WITH_ZLIB@
#define HAVE_ZLIB_H 1
#else
#undef HAVE_ZLIB_H
#endif
/* Define to 1 if you have the `_stat' function. */
#undef HAVE__STAT
......
......@@ -110,7 +110,7 @@ _lx_dlerror(void)
}
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
gzFile
......
......@@ -43,7 +43,7 @@ extern void * _lx_dlsym(void * handle, const char * symbol);
extern char * _lx_dlerror(void);
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
......
......@@ -83,12 +83,6 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
#ifdef HAVE_LZMA_H
#include <lzma.h>
#endif
#include "buf.h"
#include "enc.h"
......
......@@ -32,7 +32,7 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
......
......@@ -27,7 +27,7 @@
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
......
......@@ -150,9 +150,6 @@
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H
/* Name of package */
#undef PACKAGE
......
......@@ -65,12 +65,6 @@ CFLAGS = $(CFLAGS) -DHAVE_WIN32_THREADS
!else if "$(WITH_THREADS)" == "posix"
CFLAGS = $(CFLAGS) -DHAVE_PTHREAD_H
!endif
!if "$(WITH_ZLIB)" == "1"
CFLAGS = $(CFLAGS) -DHAVE_ZLIB_H
!endif
!if "$(WITH_LZMA)" == "1"
CFLAGS = $(CFLAGS) -DHAVE_LZMA_H
!endif
# The linker and its options.
LD = ilink32.exe
......
......@@ -57,12 +57,6 @@ endif
ifeq ($(WITH_THREADS),posix)
CFLAGS += -DHAVE_PTHREAD_H
endif
ifeq ($(WITH_ZLIB),1)
CFLAGS += -DHAVE_ZLIB_H
endif
ifeq ($(WITH_LZMA),1)
CFLAGS += -DHAVE_LZMA_H
endif
# The linker and its options.
LD = gcc.exe
......
......@@ -55,12 +55,6 @@ CFLAGS = $(CFLAGS) /D "HAVE_WIN32_THREADS"
!else if "$(WITH_THREADS)" == "posix"
CFLAGS = $(CFLAGS) /D "HAVE_PTHREAD_H"
!endif
!if "$(WITH_ZLIB)" == "1"
CFLAGS = $(CFLAGS) /D "HAVE_ZLIB_H"
!endif
!if "$(WITH_LZMA)" == "1"
CFLAGS = $(CFLAGS) /D "HAVE_LZMA_H"
!endif
CFLAGS = $(CFLAGS) /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE
# The linker and its options.
......
......@@ -28,7 +28,7 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
......
......@@ -33,10 +33,10 @@
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
#ifdef HAVE_LZMA_H
#ifdef LIBXML_LZMA_ENABLED
#include <lzma.h>
#endif
......@@ -597,7 +597,7 @@ xmlWrapOpenUtf8(const char *path,int mode)
return fd;
}
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
static gzFile
xmlWrapGzOpenUtf8(const char *path, const char *mode)
{
......@@ -1038,7 +1038,7 @@ xmlBufferWrite (void * context, const char * buffer, int len) {
}
#endif
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
/************************************************************************
* *
* I/O for compressed file accesses *
......@@ -1241,7 +1241,7 @@ xmlGzfileClose (void * context) {
if (ret < 0) xmlIOErr(0, "gzclose()");
return(ret);
}
#endif /* HAVE_ZLIB_H */
#endif /* LIBXML_ZLIB_ENABLED */
#ifdef LIBXML_LZMA_ENABLED
/************************************************************************
......@@ -1380,7 +1380,7 @@ typedef struct xmlIOHTTPWriteCtxt_
} xmlIOHTTPWriteCtxt, *xmlIOHTTPWriteCtxtPtr;
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
#define DFLT_WBITS ( -15 )
#define DFLT_MEM_LVL ( 8 )
......@@ -1708,7 +1708,7 @@ xmlZMemBuffGetContent( xmlZMemBuffPtr buff, char ** data_ref ) {
return ( zlgth );
}
#endif /* LIBXML_OUTPUT_ENABLED */
#endif /* HAVE_ZLIB_H */
#endif /* LIBXML_ZLIB_ENABLED */
#ifdef LIBXML_OUTPUT_ENABLED
/**
......@@ -1727,7 +1727,7 @@ xmlFreeHTTPWriteCtxt( xmlIOHTTPWriteCtxtPtr ctxt )
if ( ctxt->doc_buff != NULL ) {
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if ( ctxt->compression > 0 ) {
xmlFreeZMemBuff( ctxt->doc_buff );
}
......@@ -1814,7 +1814,7 @@ xmlIOHTTPOpenW(const char *post_uri, int compression ATTRIBUTE_UNUSED)
* ** is being used to avoid pushing the data to disk and back.
*/
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if ((compression > 0) && (compression <= 9)) {
ctxt->compression = compression;
......@@ -1894,7 +1894,7 @@ xmlIOHTTPWrite( void * context, const char * buffer, int len ) {
/* Use gzwrite or fwrite as previously setup in the open call */
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if ( ctxt->compression > 0 )
len = xmlZMemBuffAppend( ctxt->doc_buff, buffer, len );
......@@ -1958,7 +1958,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
/* Retrieve the content from the appropriate buffer */
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if ( ctxt->compression > 0 ) {
content_lgth = xmlZMemBuffGetContent( ctxt->doc_buff, &http_content );
......@@ -2229,10 +2229,10 @@ xmlRegisterDefaultInputCallbacks(void) {
xmlRegisterInputCallbacks(xmlFileMatch, xmlFileOpen,
xmlFileRead, xmlFileClose);
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
xmlRegisterInputCallbacks(xmlGzfileMatch, xmlGzfileOpen,
xmlGzfileRead, xmlGzfileClose);
#endif /* HAVE_ZLIB_H */
#endif /* LIBXML_ZLIB_ENABLED */
#ifdef LIBXML_LZMA_ENABLED
xmlRegisterInputCallbacks(xmlXzfileMatch, xmlXzfileOpen,
xmlXzfileRead, xmlXzfileClose);
......@@ -2274,7 +2274,7 @@ xmlRegisterDefaultOutputCallbacks (void) {
uncompressed ones except opening if existing then closing
and saving with same compression ratio ... a pain.
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
xmlRegisterOutputCallbacks(xmlGzfileMatch, xmlGzfileOpen,
xmlGzfileWrite, xmlGzfileClose);
#endif
......@@ -2564,7 +2564,7 @@ __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
ret->context = context;
ret->readcallback = xmlInputCallbackTable[i].readcallback;
ret->closecallback = xmlInputCallbackTable[i].closecallback;
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if ((xmlInputCallbackTable[i].opencallback == xmlGzfileOpen) &&
(strcmp(URI, "-") != 0)) {
#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1230
......@@ -2628,7 +2628,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
int i = 0;
void *context = NULL;
char *unescaped = NULL;
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
int is_file_uri = 1;
#endif
......@@ -2639,7 +2639,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
puri = xmlParseURI(URI);
if (puri != NULL) {
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if ((puri->scheme != NULL) &&
(!xmlStrEqual(BAD_CAST puri->scheme, BAD_CAST "file")))
is_file_uri = 0;
......@@ -2659,7 +2659,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
* try with an unescaped version of the URI
*/
if (unescaped != NULL) {
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if ((compression > 0) && (compression <= 9) && (is_file_uri == 1)) {
context = xmlGzfileOpenW(unescaped, compression);
if (context != NULL) {
......@@ -2677,7 +2677,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
for (i = xmlOutputCallbackNr - 1;i >= 0;i--) {
if ((xmlOutputCallbackTable[i].matchcallback != NULL) &&
(xmlOutputCallbackTable[i].matchcallback(unescaped) != 0)) {
#if defined(LIBXML_HTTP_ENABLED) && defined(HAVE_ZLIB_H)
#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_ZLIB_ENABLED)
/* Need to pass compression parameter into HTTP open calls */
if (xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch)
context = xmlIOHTTPOpenW(unescaped, compression);
......@@ -2696,7 +2696,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
* filename
*/
if (context == NULL) {
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if ((compression > 0) && (compression <= 9) && (is_file_uri == 1)) {
context = xmlGzfileOpenW(URI, compression);
if (context != NULL) {
......@@ -2713,7 +2713,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
for (i = xmlOutputCallbackNr - 1;i >= 0;i--) {
if ((xmlOutputCallbackTable[i].matchcallback != NULL) &&
(xmlOutputCallbackTable[i].matchcallback(URI) != 0)) {
#if defined(LIBXML_HTTP_ENABLED) && defined(HAVE_ZLIB_H)
#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_ZLIB_ENABLED)
/* Need to pass compression parameter into HTTP open calls */
if (xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch)
context = xmlIOHTTPOpenW(URI, compression);
......
......@@ -3015,7 +3015,7 @@ static void usage(FILE *f, const char *name) {
fprintf(f, "\t--repeat : repeat 100 times, for timing or profiling\n");
fprintf(f, "\t--insert : ad-hoc test for valid insertions\n");
#ifdef LIBXML_OUTPUT_ENABLED
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
fprintf(f, "\t--compress : turn on gzip compression of output\n");
#endif
#endif /* LIBXML_OUTPUT_ENABLED */
......@@ -3295,7 +3295,7 @@ main(int argc, char **argv) {
}
#endif
#ifdef LIBXML_OUTPUT_ENABLED
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
else if ((!strcmp(argv[i], "-compress")) ||
(!strcmp(argv[i], "--compress"))) {
compress++;
......
......@@ -2704,7 +2704,7 @@ xmlSaveFormatFileEnc( const char * filename, xmlDocPtr cur,
return(-1);
}
#ifdef HAVE_ZLIB_H
#ifdef LIBXML_ZLIB_ENABLED
if (cur->compression < 0) cur->compression = xmlGetCompressMode();
#endif
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment