Index: trunk/Makefile.in
===================================================================
--- trunk/Makefile.in	(revision 167)
+++ trunk/Makefile.in	(revision 168)
@@ -1698,3 +1698,3 @@
 sh_portcheck.o: $(srcsrc)/sh_portcheck.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_mem.h $(srcinc)/sh_calls.h $(srcinc)/sh_utils.h $(srcinc)/sh_modules.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h $(srcinc)/CuTest.h 
 sh_pthread.o: $(srcsrc)/sh_pthread.c Makefile config_xor.h $(srcinc)/sh_pthread.h $(srcinc)/sh_calls.h $(srcinc)/sh_modules.h 
-sh_string.o: $(srcsrc)/sh_string.c Makefile $(srcinc)/sh_string.h $(srcinc)/sh_mem.h 
+sh_string.o: $(srcsrc)/sh_string.c Makefile $(srcinc)/sh_string.h $(srcinc)/sh_mem.h $(srcinc)/CuTest.h 
Index: trunk/aclocal.m4
===================================================================
--- trunk/aclocal.m4	(revision 167)
+++ trunk/aclocal.m4	(revision 168)
@@ -1860,4 +1860,64 @@
 ])dnl ACX_PTHREAD
 
+
+
+
+dnl Copyright Â© 2004 Loic Dachary <loic@senga.org>
+dnl
+dnl This program is free software; you can redistribute it and/or modify 
+dnl it under the terms of the GNU General Public License as published by 
+dnl the Free Software Foundation; either version 2 of the License, or (at 
+dnl your option) any later version.
+dnl
+dnl Use ZLIB_HOME instead of option
+
+AC_DEFUN([CHECK_ZLIB],[
+
+if test "x${ZLIB_HOME}" = "x"; then 
+	ZLIB_HOME=/usr/local
+	if test ! -f "${ZLIB_HOME}/include/zlib.h"
+	then
+        	ZLIB_HOME=/usr
+	fi
+fi
+
+zlib_found=no
+
+ZLIB_OLD_LDFLAGS=$LDFLAGS
+ZLIB_OLD_CPPFLAGS=$LDFLAGS
+if test "x${ZLIB_HOME}" = "x/usr"; then
+	:
+else
+	LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
+	CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
+fi
+AC_LANG_SAVE
+AC_LANG_C
+AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no])
+AC_CHECK_HEADER(zlib.h, [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
+AC_LANG_RESTORE
+if test "$zlib_cv_libz" = "yes" -a "$zlib_cv_zlib_h" = "yes"
+then
+        #
+        # If both library and header were found, use them
+        #
+        AC_CHECK_LIB(z, inflateEnd)
+        AC_MSG_CHECKING([zlib in ${ZLIB_HOME}])
+        AC_MSG_RESULT(ok)
+	zlib_found=yes
+else
+        #
+        # If either header or library was not found, revert and bomb
+        #
+        AC_MSG_CHECKING(zlib in ${ZLIB_HOME})
+        LDFLAGS="$ZLIB_OLD_LDFLAGS"
+        CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
+        AC_MSG_RESULT(failed)
+        AC_MSG_ERROR([zlib not found in ZLIB_HOME, /usr/local, or /usr])
+fi
+
+])
+
+
 dnl *-*wedit:notab*-*  Please keep this as the last line.
 
Index: trunk/configure.ac
===================================================================
--- trunk/configure.ac	(revision 167)
+++ trunk/configure.ac	(revision 168)
@@ -875,4 +875,5 @@
 if test x"${mytclient}" = x-DSH_STANDALONE -o x"${mytclient}" = x-DSH_WITH_CLIENT;
 then
+dnl For threaded modules
 	ACX_PTHREAD
 	CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
@@ -880,4 +881,6 @@
 	LDFLAGS="$PTHREAD_CFLAGS $LDFLAGS"
 	CC="$PTHREAD_CC"
+dnl For MODI_TXT
+	CHECK_ZLIB()
 fi
 	
@@ -969,23 +972,18 @@
         fi
         if test "x${withval}" = "xmysql"; then
+	  if test "x$zlib_found" = "x"
+	  then
+		CHECK_ZLIB()
+	  fi
 	  AC_CHECK_PROG(HAVE_MYSQL_CONFIG, mysql_config, yes, no)
           if test "$HAVE_MYSQL_CONFIG" = "yes"; then
-                # echo "mysql_config found"
 		sh_mysql_libs="`mysql_config --libs`"
-		# echo ${sh_mysql_libs}
 		sh_mysql_libs="`eval echo ${sh_mysql_libs}`"
-		# echo $mysql_libs
-		# save_libs="$LIBS"
-                # LIBS="$LIBS `mysql_config --libs`"
-		# echo $LIBS
 		LIBS="$LIBS ${sh_mysql_libs}"
-		# echo $LIBS
 		sh_mysql_cflags="`mysql_config --cflags`"
 		sh_mysql_cflags="`eval echo ${sh_mysql_cflags}`"
-                # CFLAGS="$CFLAGS `mysql_config --cflags`"
-		# CFLAGS="$CFLAGS ${sh_mysql_cflags}"
 		CPPFLAGS="$CPPFLAGS ${sh_mysql_cflags}"
 	  else
-		AC_MSG_CHECKING(for MySQL in /usr /usr/local /usr/local/mysql MYSQL_HOME)
+		AC_MSG_CHECKING([for MySQL in /usr /usr/local /usr/local/mysql MYSQL_HOME])
 		mysql_directory="/usr /usr/local /usr/local/mysql ${MYSQL_HOME}"
 
@@ -1053,15 +1051,12 @@
           AC_DEFINE(WITH_MYSQL)
           AC_DEFINE(WITH_DATABASE)
-          AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no])
-	  AC_MSG_CHECKING(for zlib)
-          if test "$zlib_cv_libz" = "yes"
+          if test "x$zlib_found" = "xyes"
           then
                 LIBS="$LIBS -lz -lm"
-                AC_MSG_RESULT(ok)
           else
-		AC_MSG_RESULT(failed)
 		echo
-		echo " Either the mysql or the zlib library was not found"
-		echo " or was unusable. Possible reasons include:"
+		
+		echo " Mysql library was not found or not useable."
+		echo " Possible reasons include:"
 		echo "  - an old, incompatible version compiled from source"
 		echo "  - on Solaris, libmysql is compiled with the Solaris"
@@ -1072,8 +1067,7 @@
 		echo " message from the compiler."
 		echo
-		echo " If your mysql and zlib libraries are installed in an"
+		echo " If your mysql libraries are installed in an"
 		echo " unusual place, use --with-libs=-L/path/to/libdirectory"
-		echo " where libdirectory is the directory holding libmysql"
-		echo " or libz."
+		echo " where libdirectory is the directory holding libmysql."
 		if test x"$enable_static" = xyes; then
 		  echo " Note that for compiling a static binary, you need"
@@ -1081,5 +1075,5 @@
 		fi
 		echo
-		AC_MSG_ERROR([libmysql or zlib not found or unuseable]) 
+		AC_MSG_ERROR([libmysql not found or unuseable]) 
           fi
 	  AC_CHECK_HEADERS(mysql/mysql.h)
Index: trunk/depend.dep
===================================================================
--- trunk/depend.dep	(revision 167)
+++ trunk/depend.dep	(revision 168)
@@ -63,3 +63,3 @@
 sh_pthread.o: $(srcsrc)/sh_pthread.c Makefile config_xor.h $(srcinc)/sh_pthread.h $(srcinc)/sh_calls.h $(srcinc)/sh_modules.h 
 kern_head.o: $(srcsrc)/kern_head.c Makefile config.h $(srcinc)/kern_head.h $(srcinc)/kern_head.h 
-sh_string.o: $(srcsrc)/sh_string.c Makefile $(srcinc)/sh_string.h $(srcinc)/sh_mem.h 
+sh_string.o: $(srcsrc)/sh_string.c Makefile $(srcinc)/sh_string.h $(srcinc)/sh_mem.h $(srcinc)/CuTest.h 
Index: trunk/depend.sum
===================================================================
--- trunk/depend.sum	(revision 167)
+++ trunk/depend.sum	(revision 168)
@@ -1,1 +1,1 @@
-3237390887
+2783424603
