Improve accuracy of check for presence of deflateBound.
ZLIB_VERNUM isn't defined in some zlib versions, so this patch does a proper linking test in autoconf to see whether deflateBound exists in zlib. Also, setting NO_DEFLATE_BOUND will also work for folk not using autoconf. Signed-off-by: David Symonds <dsymonds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Symonds committed
Nov 7, 2007 at 14:24 UTC
609a2289d76fd9a7dddceabc63d1654fe61e0ffb
4 files changed
+28
-1
Makefile
+6
@@ -94,6 +94,8 @@ all::
94
# Define OLD_ICONV if your library has an old iconv(), where the second
95
# (input buffer pointer) parameter is declared with type (const char **).
96
#
97
+# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
98
+#
99
# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
100
# that tells runtime paths to dynamic libraries;
101
# "-Wl,-rpath=/path/lib" is used instead.
@@ -637,6 +639,10 @@ ifdef OLD_ICONV
639
BASIC_CFLAGS += -DOLD_ICONV
640
endif
641
642
+ifdef NO_DEFLATE_BOUND
643
+ BASIC_CFLAGS += -DNO_DEFLATE_BOUND
644
+endif
645
+
646
ifdef PPC_SHA1
647
SHA1_HEADER = "ppc/sha1.h"
648
LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
cache.h
+1
-1
@@ -6,7 +6,7 @@
6
#include SHA1_HEADER
7
#include <zlib.h>
8
9
-#if ZLIB_VERNUM < 0x1200
9
+#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
10
#define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
11
#endif
12
config.mak.in
+1
@@ -38,3 +38,4 @@ NO_STRCASESTR=@NO_STRCASESTR@
38
NO_STRLCPY=@NO_STRLCPY@
39
NO_SETENV=@NO_SETENV@
40
NO_ICONV=@NO_ICONV@
41
+NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
configure.ac
+20
@@ -182,6 +182,26 @@ AC_SUBST(NEEDS_LIBICONV)
182
AC_SUBST(NO_ICONV)
183
test -n "$NEEDS_LIBICONV" && LIBS="$LIBS -liconv"
184
#
185
+# Define NO_DEFLATE_BOUND if deflateBound is missing from zlib.
186
+AC_DEFUN([ZLIBTEST_SRC], [
187
+#include <zlib.h>
188
+
189
+int main(void)
190
+{
191
+ deflateBound(0, 0);
192
+ return 0;
193
+}
194
+])
195
+AC_MSG_CHECKING([for deflateBound in -lz])
196
+old_LIBS="$LIBS"
197
+LIBS="$LIBS -lz"
198
+AC_LINK_IFELSE(ZLIBTEST_SRC,
199
+ [AC_MSG_RESULT([yes])],
200
+ [AC_MSG_RESULT([no])
201
+ NO_DEFLATE_BOUND=yes])
202
+LIBS="$old_LIBS"
203
+AC_SUBST(NO_DEFLATE_BOUND)
204
+#
205
# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
206
# Patrick Mauritz).
207
AC_CHECK_LIB([c], [socket],