Browse code

improve zlib test

git-svn: trunk@1065

Tomasz Kojm authored on 2004/11/05 21:12:30
Showing 4 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Nov  5 13:08:24 CET 2004 (tk)
2
+---------------------------------
3
+  * configure: improve zlib test
4
+
1 5
 Fri Nov  5 11:04:45 CET 2004 (tk)
2 6
 ---------------------------------
3 7
   * freshclam: add support for AllowSupplementaryGroups (patch by Ales Casar
... ...
@@ -46,7 +46,7 @@ while test $# -gt 0; do
46 46
 	;;
47 47
 
48 48
     --version)
49
-	echo devel-20041102
49
+	echo devel-20041105
50 50
 	exit 0
51 51
 	;;
52 52
 
... ...
@@ -59,7 +59,7 @@ while test $# -gt 0; do
59 59
        	;;
60 60
 
61 61
     --libs)
62
-       	echo -L${exec_prefix}/lib  -lz -lbz2 -lgmp -L/usr/lib -lcurl -lssl -lcrypto -ldl -lssl -lcrypto -ldl -lz -lpthread
62
+       	echo -L${exec_prefix}/lib  -L/usr/lib -lz -lbz2 -lgmp -L/usr/lib -lcurl -lssl -lcrypto -ldl -lssl -lcrypto -ldl -lz -lpthread
63 63
        	;;
64 64
 
65 65
     *)
... ...
@@ -1036,6 +1036,8 @@ Optional Packages:
1036 1036
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
1037 1037
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
1038 1038
   --with-pic              try to use only PIC/non-PIC objects default=use both
1039
+  --with-zlib=DIR	  path to directory containing zlib library (default=
1040
+			  /usr/local or /usr if not found in /usr/local)
1039 1041
   --with-libcurl	  support URLs downloading with libcurl (default=auto)
1040 1042
   --with-user=uid	  name of the clamav user (default=clamav)
1041 1043
   --with-group=gid	  name of the clamav group (default=clamav)
... ...
@@ -5018,7 +5020,7 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
5018 5018
 case $host in
5019 5019
 *-*-irix6*)
5020 5020
   # Find out which ABI we are using.
5021
-  echo '#line 5021 "configure"' > conftest.$ac_ext
5021
+  echo '#line 5023 "configure"' > conftest.$ac_ext
5022 5022
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5023 5023
   (eval $ac_compile) 2>&5
5024 5024
   ac_status=$?
... ...
@@ -5591,7 +5593,7 @@ chmod -w .
5591 5591
 save_CFLAGS="$CFLAGS"
5592 5592
 CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
5593 5593
 compiler_c_o=no
5594
-if { (eval echo configure:5594: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
5594
+if { (eval echo configure:5596: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
5595 5595
   # The compiler can only warn and ignore the option if not recognized
5596 5596
   # So say no if there are warnings
5597 5597
   if test -s out/conftest.err; then
... ...
@@ -7518,7 +7520,7 @@ else
7518 7518
     lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
7519 7519
   lt_status=$lt_dlunknown
7520 7520
   cat > conftest.$ac_ext <<EOF
7521
-#line 7521 "configure"
7521
+#line 7523 "configure"
7522 7522
 #include "confdefs.h"
7523 7523
 
7524 7524
 #if HAVE_DLFCN_H
... ...
@@ -7616,7 +7618,7 @@ else
7616 7616
     lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
7617 7617
   lt_status=$lt_dlunknown
7618 7618
   cat > conftest.$ac_ext <<EOF
7619
-#line 7619 "configure"
7619
+#line 7621 "configure"
7620 7620
 #include "confdefs.h"
7621 7621
 
7622 7622
 #if HAVE_DLFCN_H
... ...
@@ -10160,30 +10162,82 @@ fi
10160 10160
 
10161 10161
 
10162 10162
 
10163
-if test "${ac_cv_header_zlib_h+set}" = set; then
10164
-  echo "$as_me:$LINENO: checking for zlib.h" >&5
10165
-echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6
10166
-if test "${ac_cv_header_zlib_h+set}" = set; then
10167
-  echo $ECHO_N "(cached) $ECHO_C" >&6
10163
+echo "$as_me:$LINENO: checking for zlib installation" >&5
10164
+echo $ECHO_N "checking for zlib installation... $ECHO_C" >&6
10165
+
10166
+# Check whether --with-zlib or --without-zlib was given.
10167
+if test "${with_zlib+set}" = set; then
10168
+  withval="$with_zlib"
10169
+
10170
+if test "$withval"; then
10171
+  ZLIB_HOME="$withval"
10172
+  echo "$as_me:$LINENO: result: using $ZLIB_HOME" >&5
10173
+echo "${ECHO_T}using $ZLIB_HOME" >&6
10168 10174
 fi
10169
-echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5
10170
-echo "${ECHO_T}$ac_cv_header_zlib_h" >&6
10175
+
10171 10176
 else
10172
-  # Is the header compilable?
10173
-echo "$as_me:$LINENO: checking zlib.h usability" >&5
10174
-echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6
10177
+
10178
+ZLIB_HOME=/usr/local
10179
+if test ! -f "$ZLIB_HOME/include/zlib.h"
10180
+then
10181
+  ZLIB_HOME=/usr
10182
+fi
10183
+echo "$as_me:$LINENO: result: $ZLIB_HOME" >&5
10184
+echo "${ECHO_T}$ZLIB_HOME" >&6
10185
+
10186
+fi;
10187
+
10188
+if test ! -f "$ZLIB_HOME/include/zlib.h"
10189
+then
10190
+    { { echo "$as_me:$LINENO: error: Please install zlib and zlib-devel packages" >&5
10191
+echo "$as_me: error: Please install zlib and zlib-devel packages" >&2;}
10192
+   { (exit 1); exit 1; }; }
10193
+else
10194
+    vuln=`grep "ZLIB_VERSION \"1.2.0" $ZLIB_HOME/include/zlib.h`
10195
+    if test -z "$vuln"; then
10196
+	vuln=`grep "ZLIB_VERSION \"1.2.1" $ZLIB_HOME/include/zlib.h`
10197
+    fi
10198
+
10199
+    if test -n "$vuln"; then
10200
+	{ { echo "$as_me:$LINENO: error: Installed zlib version contains a security bug. Please install version 1.2.2 or later." >&5
10201
+echo "$as_me: error: Installed zlib version contains a security bug. Please install version 1.2.2 or later." >&2;}
10202
+   { (exit 1); exit 1; }; }
10203
+    fi
10204
+
10205
+    LDFLAGS="$LDFLAGS -L$ZLIB_HOME/lib"
10206
+    CPPFLAGS="$CPPFLAGS -I$ZLIB_HOME/include"
10207
+    echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5
10208
+echo $ECHO_N "checking for inflateEnd in -lz... $ECHO_C" >&6
10209
+if test "${ac_cv_lib_z_inflateEnd+set}" = set; then
10210
+  echo $ECHO_N "(cached) $ECHO_C" >&6
10211
+else
10212
+  ac_check_lib_save_LIBS=$LIBS
10213
+LIBS="-lz  $LIBS"
10175 10214
 cat >conftest.$ac_ext <<_ACEOF
10176 10215
 /* confdefs.h.  */
10177 10216
 _ACEOF
10178 10217
 cat confdefs.h >>conftest.$ac_ext
10179 10218
 cat >>conftest.$ac_ext <<_ACEOF
10180 10219
 /* end confdefs.h.  */
10181
-$ac_includes_default
10182
-#include <zlib.h>
10220
+
10221
+/* Override any gcc2 internal prototype to avoid an error.  */
10222
+#ifdef __cplusplus
10223
+extern "C"
10224
+#endif
10225
+/* We use char because int might match the return type of a gcc2
10226
+   builtin and then its argument prototype would still apply.  */
10227
+char inflateEnd ();
10228
+int
10229
+main ()
10230
+{
10231
+inflateEnd ();
10232
+  ;
10233
+  return 0;
10234
+}
10183 10235
 _ACEOF
10184
-rm -f conftest.$ac_objext
10185
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
10186
-  (eval $ac_compile) 2>conftest.er1
10236
+rm -f conftest.$ac_objext conftest$ac_exeext
10237
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
10238
+  (eval $ac_link) 2>conftest.er1
10187 10239
   ac_status=$?
10188 10240
   grep -v '^ *+' conftest.er1 >conftest.err
10189 10241
   rm -f conftest.er1
... ...
@@ -10196,108 +10250,27 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
10196 10196
   ac_status=$?
10197 10197
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
10198 10198
   (exit $ac_status); }; } &&
10199
-	 { ac_try='test -s conftest.$ac_objext'
10199
+	 { ac_try='test -s conftest$ac_exeext'
10200 10200
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
10201 10201
   (eval $ac_try) 2>&5
10202 10202
   ac_status=$?
10203 10203
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
10204 10204
   (exit $ac_status); }; }; then
10205
-  ac_header_compiler=yes
10205
+  ac_cv_lib_z_inflateEnd=yes
10206 10206
 else
10207 10207
   echo "$as_me: failed program was:" >&5
10208 10208
 sed 's/^/| /' conftest.$ac_ext >&5
10209 10209
 
10210
-ac_header_compiler=no
10210
+ac_cv_lib_z_inflateEnd=no
10211 10211
 fi
10212
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
10213
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
10214
-echo "${ECHO_T}$ac_header_compiler" >&6
10215
-
10216
-# Is the header present?
10217
-echo "$as_me:$LINENO: checking zlib.h presence" >&5
10218
-echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6
10219
-cat >conftest.$ac_ext <<_ACEOF
10220
-/* confdefs.h.  */
10221
-_ACEOF
10222
-cat confdefs.h >>conftest.$ac_ext
10223
-cat >>conftest.$ac_ext <<_ACEOF
10224
-/* end confdefs.h.  */
10225
-#include <zlib.h>
10226
-_ACEOF
10227
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
10228
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
10229
-  ac_status=$?
10230
-  grep -v '^ *+' conftest.er1 >conftest.err
10231
-  rm -f conftest.er1
10232
-  cat conftest.err >&5
10233
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
10234
-  (exit $ac_status); } >/dev/null; then
10235
-  if test -s conftest.err; then
10236
-    ac_cpp_err=$ac_c_preproc_warn_flag
10237
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
10238
-  else
10239
-    ac_cpp_err=
10240
-  fi
10241
-else
10242
-  ac_cpp_err=yes
10243
-fi
10244
-if test -z "$ac_cpp_err"; then
10245
-  ac_header_preproc=yes
10246
-else
10247
-  echo "$as_me: failed program was:" >&5
10248
-sed 's/^/| /' conftest.$ac_ext >&5
10249
-
10250
-  ac_header_preproc=no
10251
-fi
10252
-rm -f conftest.err conftest.$ac_ext
10253
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
10254
-echo "${ECHO_T}$ac_header_preproc" >&6
10255
-
10256
-# So?  What about this header?
10257
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
10258
-  yes:no: )
10259
-    { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5
10260
-echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
10261
-    { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5
10262
-echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;}
10263
-    ac_header_preproc=yes
10264
-    ;;
10265
-  no:yes:* )
10266
-    { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5
10267
-echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;}
10268
-    { echo "$as_me:$LINENO: WARNING: zlib.h:     check for missing prerequisite headers?" >&5
10269
-echo "$as_me: WARNING: zlib.h:     check for missing prerequisite headers?" >&2;}
10270
-    { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5
10271
-echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;}
10272
-    { echo "$as_me:$LINENO: WARNING: zlib.h:     section \"Present But Cannot Be Compiled\"" >&5
10273
-echo "$as_me: WARNING: zlib.h:     section \"Present But Cannot Be Compiled\"" >&2;}
10274
-    { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5
10275
-echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;}
10276
-    { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5
10277
-echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;}
10278
-    (
10279
-      cat <<\_ASBOX
10280
-## ------------------------------------------ ##
10281
-## Report this to the AC_PACKAGE_NAME lists.  ##
10282
-## ------------------------------------------ ##
10283
-_ASBOX
10284
-    ) |
10285
-      sed "s/^/$as_me: WARNING:     /" >&2
10286
-    ;;
10287
-esac
10288
-echo "$as_me:$LINENO: checking for zlib.h" >&5
10289
-echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6
10290
-if test "${ac_cv_header_zlib_h+set}" = set; then
10291
-  echo $ECHO_N "(cached) $ECHO_C" >&6
10292
-else
10293
-  ac_cv_header_zlib_h=$ac_header_preproc
10294
-fi
10295
-echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5
10296
-echo "${ECHO_T}$ac_cv_header_zlib_h" >&6
10297
-
10212
+rm -f conftest.err conftest.$ac_objext \
10213
+      conftest$ac_exeext conftest.$ac_ext
10214
+LIBS=$ac_check_lib_save_LIBS
10298 10215
 fi
10299
-if test $ac_cv_header_zlib_h = yes; then
10300
-  LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lz";
10216
+echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5
10217
+echo "${ECHO_T}$ac_cv_lib_z_inflateEnd" >&6
10218
+if test $ac_cv_lib_z_inflateEnd = yes; then
10219
+  LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -L$ZLIB_HOME/lib -lz";
10301 10220
 cat >>confdefs.h <<\_ACEOF
10302 10221
 #define HAVE_ZLIB_H 1
10303 10222
 _ACEOF
... ...
@@ -10308,7 +10281,7 @@ echo "$as_me: error: Please install zlib and zlib-devel packages" >&2;}
10308 10308
    { (exit 1); exit 1; }; }
10309 10309
 fi
10310 10310
 
10311
-
10311
+fi
10312 10312
 
10313 10313
 want_bzip2="yes"
10314 10314
 # Check whether --enable-bzip2 or --disable-bzip2 was given.
... ...
@@ -73,7 +73,42 @@ fi
73 73
 have_pthreads=no
74 74
 AC_CHECK_HEADER(pthread.h,[have_pthreads=yes],)
75 75
 
76
-AC_CHECK_HEADER(zlib.h,[LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lz"; AC_DEFINE(HAVE_ZLIB_H,1,zlib installed)],AC_MSG_ERROR(Please install zlib and zlib-devel packages))
76
+dnl Check for zlib
77
+AC_MSG_CHECKING(for zlib installation)
78
+AC_ARG_WITH(zlib,
79
+[  --with-zlib=DIR	  path to directory containing zlib library (default=
80
+			  /usr/local or /usr if not found in /usr/local)],
81
+[
82
+if test "$withval"; then
83
+  ZLIB_HOME="$withval"
84
+  AC_MSG_RESULT(using $ZLIB_HOME)
85
+fi
86
+], [
87
+ZLIB_HOME=/usr/local
88
+if test ! -f "$ZLIB_HOME/include/zlib.h"
89
+then
90
+  ZLIB_HOME=/usr
91
+fi
92
+AC_MSG_RESULT($ZLIB_HOME)
93
+])
94
+
95
+if test ! -f "$ZLIB_HOME/include/zlib.h"
96
+then
97
+    AC_MSG_ERROR(Please install zlib and zlib-devel packages)
98
+else
99
+    vuln=`grep "ZLIB_VERSION \"1.2.0" $ZLIB_HOME/include/zlib.h`
100
+    if test -z "$vuln"; then
101
+	vuln=`grep "ZLIB_VERSION \"1.2.1" $ZLIB_HOME/include/zlib.h`
102
+    fi
103
+
104
+    if test -n "$vuln"; then
105
+	AC_MSG_ERROR(Installed zlib version contains a security bug. Please install version 1.2.2 or later.)
106
+    fi
107
+
108
+    LDFLAGS="$LDFLAGS -L$ZLIB_HOME/lib"
109
+    CPPFLAGS="$CPPFLAGS -I$ZLIB_HOME/include"
110
+    AC_CHECK_LIB(z, inflateEnd, [LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -L$ZLIB_HOME/lib -lz"; AC_DEFINE(HAVE_ZLIB_H,1,zlib installed)], AC_MSG_ERROR(Please install zlib and zlib-devel packages))
111
+fi
77 112
 
78 113
 want_bzip2="yes"
79 114
 AC_ARG_ENABLE(bzip2,