{"thread":{"id":"10697","subject":"[REPLACEMENT PATCH] Improve accuracy of check for presence of deflateBound.","startedAt":"2007-11-07T03:24:28Z","lastAt":"2007-11-07T03:24:28Z","messageCount":1,"participants":["David Symonds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"58634","messageId":"11944058682845-git-send-email-dsymonds@gmail.com","threadId":"10697","inReplyTo":null,"subject":"[REPLACEMENT PATCH] Improve accuracy of check for presence of deflateBound.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-07T03:24:28Z","receivedAt":"2007-11-07T03:24:28Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"ZLIB_VERNUM isn't defined in some zlib versions, so this patch does a proper\nlinking test in autoconf to see whether deflateBound exists in zlib. Also,\nsetting NO_DEFLATE_BOUND will also work for folk not using autoconf.\n\nSigned-off-by: David Symonds <dsymonds@gmail.com>\n---\n\tThis resend keeps the ZLIB_VERNUM test in place for people who don't\n\tuse autoconf (thanks spearce).\n\n Makefile      |    6 ++++++\n cache.h       |    2 +-\n config.mak.in |    1 +\n configure.ac  |   20 ++++++++++++++++++++\n 4 files changed, 28 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 1a81ef1..c8bcd1d 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -98,6 +98,8 @@ all::\n # Define OLD_ICONV if your library has an old iconv(), where the second\n # (input buffer pointer) parameter is declared with type (const char **).\n #\n+# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.\n+#\n # Define NO_R_TO_GCC_LINKER if your gcc does not like \"-R/path/lib\"\n # that tells runtime paths to dynamic libraries;\n # \"-Wl,-rpath=/path/lib\" is used instead.\n@@ -663,6 +665,10 @@ ifdef OLD_ICONV\n \tBASIC_CFLAGS += -DOLD_ICONV\n endif\n \n+ifdef NO_DEFLATE_BOUND\n+\tBASIC_CFLAGS += -DNO_DEFLATE_BOUND\n+endif\n+\n ifdef PPC_SHA1\n \tSHA1_HEADER = \"ppc/sha1.h\"\n \tLIB_OBJS += ppc/sha1.o ppc/sha1ppc.o\ndiff --git a/cache.h b/cache.h\nindex 830d2e0..ae66de1 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -7,7 +7,7 @@\n #include SHA1_HEADER\n #include <zlib.h>\n \n-#if ZLIB_VERNUM < 0x1200\n+#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200\n #define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n #endif\n \ndiff --git a/config.mak.in b/config.mak.in\nindex a3032e3..776b805 100644\n--- a/config.mak.in\n+++ b/config.mak.in\n@@ -38,3 +38,4 @@ NO_STRCASESTR=@NO_STRCASESTR@\n NO_STRLCPY=@NO_STRLCPY@\n NO_SETENV=@NO_SETENV@\n NO_ICONV=@NO_ICONV@\n+NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@\ndiff --git a/configure.ac b/configure.ac\nindex ed7cc89..ab516db 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -182,6 +182,26 @@ AC_SUBST(NEEDS_LIBICONV)\n AC_SUBST(NO_ICONV)\n test -n \"$NEEDS_LIBICONV\" && LIBS=\"$LIBS -liconv\"\n #\n+# Define NO_DEFLATE_BOUND if deflateBound is missing from zlib.\n+AC_DEFUN([ZLIBTEST_SRC], [\n+#include <zlib.h>\n+\n+int main(void)\n+{\n+\tdeflateBound(0, 0);\n+\treturn 0;\n+}\n+])\n+AC_MSG_CHECKING([for deflateBound in -lz])\n+old_LIBS=\"$LIBS\"\n+LIBS=\"$LIBS -lz\"\n+AC_LINK_IFELSE(ZLIBTEST_SRC,\n+\t[AC_MSG_RESULT([yes])],\n+\t[AC_MSG_RESULT([no])\n+\tNO_DEFLATE_BOUND=yes])\n+LIBS=\"$old_LIBS\"\n+AC_SUBST(NO_DEFLATE_BOUND)\n+#\n # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,\n # Patrick Mauritz).\n AC_CHECK_LIB([c], [socket],\n-- \n1.5.3.1\n"}]}