configure.in
468b9e48
 dnl
d119f7a0
 dnl   Copyright (C) 2002 - 2006 Tomasz Kojm <tkojm@clamav.net>
ec748835
 dnl   gethostbyname_r and readdir_r checks (c) COPYRIGHT MIT 1995
8afd932c
 dnl   socklen_t check (c) Alexander V. Lukyanov <lav@yars.free.net>
468b9e48
 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
 dnl   (at your option) any later version.
 dnl
 dnl   This program is distributed in the hope that it will be useful,
 dnl   but WITHOUT ANY WARRANTY; without even the implied warranty of
 dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 dnl   GNU General Public License for more details.
 dnl
 dnl   You should have received a copy of the GNU General Public License
 dnl   along with this program; if not, write to the Free Software
30738099
 dnl   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 dnl   MA 02110-1301, USA.
468b9e48
 
 AC_INIT(clamscan/clamscan.c)
 AC_CREATE_TARGET_H(target.h)
e789ccec
 AM_INIT_AUTOMAKE(clamav, "devel-`date +%Y%m%d`")
8b242bb9
 AM_CONFIG_HEADER(clamav-config.h)
 
468b9e48
 LC_CURRENT=1
030362e3
 LC_REVISION=10
468b9e48
 LC_AGE=0
 LIBCLAMAV_VERSION="$LC_CURRENT":"$LC_REVISION":"$LC_AGE"
 AC_SUBST(LIBCLAMAV_VERSION)
 
 AC_PROG_AWK
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AC_PROG_LIBTOOL
 
8b242bb9
 AC_DEFINE(SCANBUFF, 131072, [scan buffer size])
 AC_DEFINE(FILEBUFF, 8192,   [file i/o buffer size])
468b9e48
 
 AC_HEADER_STDC
052663e7
 AC_CHECK_HEADERS(stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h memory.h ndir.h stdlib.h strings.h string.h sys/mman.h sys/param.h sys/stat.h sys/types.h malloc.h poll.h regex.h limits.h sys/filio.h sys/uio.h termios.h)
9b29874a
 AC_CHECK_HEADER(syslog.h,AC_DEFINE(USE_SYSLOG,1,[use syslog]),)
 
468b9e48
 AC_TYPE_OFF_T
 AC_COMPILE_CHECK_SIZEOF(short)
 AC_COMPILE_CHECK_SIZEOF(int)
 AC_COMPILE_CHECK_SIZEOF(long)
562f9b01
 AC_COMPILE_CHECK_SIZEOF(long long)
71d15a92
 
 AC_CHECK_LIB(socket, bind, [LIBS="$LIBS -lsocket"; CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsocket"; LDFLAGS="$LDFLAGS -lsocket"; FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lsocket"; CLAMD_LIBS="$CLAMD_LIBS -lsocket"])
 AC_CHECK_LIB(nsl, gethostent, [LIBS="$LIBS -lnsl"; CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lnsl"; LDFLAGS="$LDFLAGS -lnsl"; FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lnsl"; CLAMD_LIBS="$CLAMD_LIBS -lnsl"])
 
944631c9
 AC_CHECK_FUNCS(poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat inet_ntop setgroups initgroups ctime_r)
fdbbe9f3
 AC_FUNC_MMAP
1ed6a845
 AC_FUNC_FSEEKO
36f2038b
 
9e8e9b3b
 dnl Check for broken snprintf (code by Phil Oleson <oz*nixil.net>)
36f2038b
 if test "x$ac_cv_func_snprintf" = "xyes" ; then
         AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
         AC_TRY_RUN(
                 [
 #include <stdio.h>
 int main(void){char b[5];snprintf(b,5,"123456789");return(b[4]!='\0');}
                 ],
                 [AC_MSG_RESULT(yes)],
                 [
                         AC_MSG_RESULT(no)
                         AC_DEFINE(BROKEN_SNPRINTF,1,[Define if your snprintf is busted])
                         AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
                 ]
         )
 fi
468b9e48
 
 have_pthreads=no
 AC_CHECK_HEADER(pthread.h,[have_pthreads=yes],)
 
bf22198b
 AM_MAINTAINER_MODE
8d4b8d46
 dnl Check for zlib
 AC_MSG_CHECKING(for zlib installation)
 AC_ARG_WITH(zlib,
 [  --with-zlib=DIR	  path to directory containing zlib library (default=
 			  /usr/local or /usr if not found in /usr/local)],
 [
 if test "$withval"; then
   ZLIB_HOME="$withval"
   AC_MSG_RESULT(using $ZLIB_HOME)
 fi
 ], [
 ZLIB_HOME=/usr/local
 if test ! -f "$ZLIB_HOME/include/zlib.h"
 then
   ZLIB_HOME=/usr
 fi
 AC_MSG_RESULT($ZLIB_HOME)
 ])
 
9c3fd1e7
 AC_ARG_ENABLE(zlib-vcheck,
 [  --disable-zlib-vcheck	  do not check for buggy zlib version ],
aa23f2c0
 zlib_check=$enableval, zlib_check="yes")
9c3fd1e7
 
8d4b8d46
 if test ! -f "$ZLIB_HOME/include/zlib.h"
 then
     AC_MSG_ERROR(Please install zlib and zlib-devel packages)
 else
9c3fd1e7
 
8d4b8d46
     vuln=`grep "ZLIB_VERSION \"1.2.0" $ZLIB_HOME/include/zlib.h`
     if test -z "$vuln"; then
 	vuln=`grep "ZLIB_VERSION \"1.2.1" $ZLIB_HOME/include/zlib.h`
     fi
 
     if test -n "$vuln"; then
9c3fd1e7
 	if test "$zlib_check" = "yes"; then
bf43f458
 	    AC_MSG_ERROR(The installed zlib version may contain a security bug. Please upgrade to 1.2.2 or later: http://www.zlib.net. You can omit this check with --disable-zlib-vcheck but DO NOT REPORT any stability issues then!)
9c3fd1e7
 	else
 	    AC_MSG_WARN([****** This ClamAV installation may be linked against])
 	    AC_MSG_WARN([****** a broken zlib version. Please DO NOT report any])
 	    AC_MSG_WARN([****** stability problems to the ClamAV developers!])
 	fi
8d4b8d46
     fi
 
9d498f2e
     if test "$ZLIB_HOME" != "/usr"; then
 	LDFLAGS="$LDFLAGS -L$ZLIB_HOME/lib"
 	CPPFLAGS="$CPPFLAGS -I$ZLIB_HOME/include"
 	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))
     else
 	AC_CHECK_LIB(z, inflateEnd, [LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lz"; AC_DEFINE(HAVE_ZLIB_H,1,zlib installed)], AC_MSG_ERROR(Please install zlib and zlib-devel packages))
     fi
8d4b8d46
 fi
468b9e48
 
 AC_ARG_ENABLE(bzip2,
9e8e9b3b
 [  --disable-bzip2	  disable bzip2 support],
aa23f2c0
 want_bzip2=$enableval, want_bzip2="yes")
468b9e48
 
67bc1b48
 if test "$want_bzip2" = "yes"
 then
     AC_CHECK_LIB(bz2, bzReadOpen, AC_DEFINE(NOBZ2PREFIX,1,bzip funtions do not have bz2 prefix),)
     AC_CHECK_HEADER(bzlib.h,[LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lbz2"; AC_DEFINE(HAVE_BZLIB_H,1,have bzip2)], AC_MSG_WARN([****** bzip2 support disabled]))
 fi
 
7def75f3
 AC_ARG_ENABLE(ncore,
 [  --disable-ncore	  disable support for NodalCore acceleration (default=auto)],
 want_ncore=$enableval, want_ncore="yes")
67fdff5c
 
7def75f3
 if test "$want_ncore" = "yes"
67fdff5c
 then
d119f7a0
     AC_CHECK_LIB(sn_sigscan, sn_sigscan_initdb, have_sigscan=yes,)
     if test "$have_sigscan" = "yes"
     then
7def75f3
 	AC_CHECK_HEADER(sn_sigscan/sn_sigscan.h,[LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lsn_sigscan"; AC_DEFINE(HAVE_NCORE,1,hardware acceleration)], AC_MSG_WARN([****** hardware acceleration support disabled -- please install libsigscan-devel ]))
d119f7a0
     fi
67fdff5c
 fi
 
881069d7
 AC_ARG_ENABLE(dns,
8f30c4e7
     AC_HELP_STRING([--disable-dns], [disable support for database verification through DNS]),
     [want_dns=$enableval], [want_dns=yes]
 )
 if test $want_dns = yes; then
e220098e
     AC_CHECK_LIB(resolv, __dn_expand, resolv_lib="-lresolv",)
     if test -z "$resolv_lib"; then
 	AC_CHECK_LIB(resolv, dn_expand, resolv_lib="-lresolv",)
     fi
9dfb1750
     AC_CHECK_HEADER(resolv.h,[FRESHCLAM_LIBS="$FRESHCLAM_LIBS $resolv_lib"; CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS $resolv_lib"; AC_DEFINE(HAVE_RESOLV_H,1,have resolv.h)], AC_MSG_WARN([****** DNS support disabled]))
468b9e48
 fi
 
e6b842b3
 AC_ARG_ENABLE(clamuko,
2f2fec5c
 [  --disable-clamuko	  disable clamuko support (Linux, DragonFly and FreeBSD only)],
aa23f2c0
 want_clamuko=$enableval, want_clamuko="yes")
e6b842b3
 
cf899a29
 AC_FUNC_SETPGRP
 
468b9e48
 AC_ARG_ENABLE(milter,
9e8e9b3b
 [  --enable-milter	  build clamav-milter],
aa23f2c0
 have_milter=$enableval, have_milter="no")
468b9e48
 
858b7da2
 if test "$have_milter" = "yes"; then
   sendmailprog=no
   AC_ARG_WITH(sendmail,
   [  --with-sendmail=PATH    specify location of Sendmail binary (default=auto find)],
   sendmailprog=$with_sendmail, sendmailprog=no)
 
   if test "$sendmailprog" = "no" ; then
     AC_PATH_PROG(sendmailprog, sendmail, no, $PATH:/sbin:/usr/sbin:/usr/lib:/usr/libexec)
   fi
 
6e95502c
   AC_DEFINE_UNQUOTED(SENDMAIL_BIN, "$sendmailprog", [location of Sendmail binary])
858b7da2
 
51d974d3
   sendmailver=`$sendmailprog -d0 < /dev/null | head -1 | awk '{print $2}'`
 
e3035b75
   if test -n "$sendmailver"; then
     sendmailver_a=`echo $sendmailver | awk -F. '{printf $1}'`
     sendmailver_b=`echo $sendmailver | awk -F. '{printf $2}'`
     sendmailver_c=`echo $sendmailver | awk -F. '{printf $3}'`
858b7da2
 
e3035b75
     AC_DEFINE_UNQUOTED(SENDMAIL_VERSION_A, $sendmailver_a, [major version of Sendmail])
     AC_DEFINE_UNQUOTED(SENDMAIL_VERSION_B, $sendmailver_b, [minor version of Sendmail])
     AC_DEFINE_UNQUOTED(SENDMAIL_VERSION_C, $sendmailver_c, [subversion of Sendmail])
   fi
858b7da2
 fi
 
4bf2cf8d
 AC_ARG_ENABLE(dsig,
9e8e9b3b
 [  --disable-dsig	  disable support for digital signatures],
aa23f2c0
 want_dsig=$enableval, want_dsig="yes")
4bf2cf8d
 
 if test "$want_dsig" = "yes"
 then
acda1fc1
     AC_CHECK_LIB(gmp, __gmpz_init, [LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lgmp"; AC_DEFINE(HAVE_GMP,1,have gmp installed)], [AC_CHECK_LIB(gmp, mpz_init, [LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lgmp"; AC_DEFINE(HAVE_GMP,1,have gmp installed)], AC_MSG_WARN([****** GNU MP 2 or newer NOT FOUND - digital signature support will be disabled !]); want_dsig="no")])
4bf2cf8d
 fi
 
9b29874a
 dnl libcurl
 AC_ARG_WITH(libcurl,
9e8e9b3b
 [  --with-libcurl	  support URLs downloading with libcurl (default=auto)],
9b29874a
 [ case "$withval" in
   yes|no) lcurl="$withval" ;;
   *)      AC_MSG_ERROR([--with-libcurl does not take an argument]) ;;
   esac],
 [ lcurl=auto ])
 
4a5581d9
 dnl Based on http://curl.signal42.com/libcurl/using/autoconf.html
9b29874a
 if test "$lcurl" != "no"
 then
4a5581d9
     my_cv_curl_vers=NONE
     dnl check is the plain-text version of the required version
599f27c8
     check="7.10.0"
4a5581d9
     dnl check_hex must be UPPERCASE if any hex letters are present
599f27c8
     check_hex="070A00"
4a5581d9
 
     AC_MSG_CHECKING([for curl >= $check])
 
9b29874a
     if eval curl-config --version 2>/dev/null >/dev/null; then
4a5581d9
 	ver=`curl-config --version | sed -e "s/libcurl //g"`
 	hex_ver=`curl-config --vernum | tr 'a-f' 'A-F'`
aecb0a73
 	fail=`echo "ibase=16; if($hex_ver<$check_hex) 1" | bc`
4a5581d9
 
aecb0a73
 	if test x$fail != x1; then
4a5581d9
 	    curl_libs=`curl-config --libs`
af63a4bd
 	    # openssl libs are required to link libcurl
 	    openssl_libs="`pkg-config --libs openssl`"
 	    curl_flags=`curl-config --cflags`
 	    LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS $curl_libs $openssl_libs"
 	    CPPFLAGS="$CPPFLAGS -I$ZLIB_HOME/include $curl_flags"
4a5581d9
 	    my_cv_curl_vers="$ver"
 	    AC_MSG_RESULT([$my_cv_curl_vers])
 	    AC_DEFINE(WITH_CURL,1,use libcurl in mbox code)
 	else
 	    AC_MSG_RESULT(FAILED)
 	    AC_MSG_WARN([$ver is too old. Need version $check or higher.])
 	fi
9b29874a
     else
4a5581d9
 	AC_MSG_RESULT(FAILED)
 	AC_MSG_WARN([curl-config was not found])
9b29874a
     fi
 fi
468b9e48
 
 AC_ARG_ENABLE(pthreads,
9e8e9b3b
 [  --disable-pthreads      disable POSIX threads support],
aa23f2c0
 have_pthreads=$enableval,)
468b9e48
 
 AC_ARG_ENABLE(cr,
9e8e9b3b
 [  --disable-cr		  don't link with C reentrant library (BSD) ],
c41cd1f2
 use_cr=$enableval,)
468b9e48
 
 AC_ARG_ENABLE(id-check,
9e8e9b3b
 [  --enable-id-check	  use id utility instead of /etc/passwd parsing],
aa23f2c0
 use_id=$enableval, use_id="no")
468b9e48
 
20814a85
 AC_ARG_ENABLE(yp-check,
9e8e9b3b
 [  --enable-yp-check	  use ypmatch utility instead of /etc/passwd parsing],
aa23f2c0
 use_yp=$enableval, use_yp="no")
20814a85
 
468b9e48
 AC_ARG_WITH(user, 
9e8e9b3b
 [  --with-user=uid	  name of the clamav user (default=clamav)],
468b9e48
 clamav_user="$withval", clamav_user="clamav")
 
 AC_ARG_WITH(group, 
9e8e9b3b
 [  --with-group=gid	  name of the clamav group (default=clamav)],
468b9e48
 clamav_group="$withval", clamav_group="clamav")
 
8b242bb9
 AC_DEFINE_UNQUOTED(CLAMAVUSER,"$clamav_user",[name of the clamav user])
 AC_DEFINE_UNQUOTED(CLAMAVGROUP,"$clamav_group",[name of the clamav group])
468b9e48
 
 AC_ARG_ENABLE(clamav,
9e8e9b3b
 [  --disable-clamav	  disable test for clamav user/group],
aa23f2c0
 test_clamav=$enableval, test_clamav=yes)
468b9e48
 
 AC_ARG_ENABLE(debug,
9e8e9b3b
 [  --enable-debug	  enable debug code],
aa23f2c0
 enable_debug=$enableval, enable_debug="no")
 
 if test "$enable_debug" = "yes"; then
   AC_DEFINE(CL_DEBUG,1,[enable debugging])
 fi
468b9e48
 
f63babe5
 AC_ARG_ENABLE(no-cache,
 [  --enable-no-cache	  use "Cache-Control: no-cache" in freshclam],
 enable_nocache=$enableval, enable_nocache="no")
 
 if test "$enable_nocache" = "yes"; then
   AC_DEFINE(FRESHCLAM_NO_CACHE,1,[use "Cache-Control: no-cache" in freshclam])
 fi
 
5472004a
 AC_ARG_ENABLE(dns-fix,
 [  --enable-dns-fix	  enable workaround for broken DNS servers (as in SpeedTouch 510)],
 enable_dnsfix=$enableval, enable_dnsfix="no")
 
 if test "$enable_dnsfix" = "yes"; then
   AC_DEFINE(FRESHCLAM_DNS_FIX,1,[enable workaround for broken DNS servers])
 fi
 
e7ca44c7
 AC_ARG_ENABLE(experimental,
 [  --enable-experimental	enable experimental code],
 enable_experimental=$enableval, enable_experimental="no")
 
 if test "$enable_experimental" = "yes"; then
   AC_DEFINE(CL_EXPERIMENTAL,1,[enable experimental code])
 fi
 
468b9e48
 AC_ARG_ENABLE(bigstack,
9e8e9b3b
 [  --enable-bigstack	  increase thread stack size],
aa23f2c0
 enable_bigstack=$enableval, enable_bigstack="no")
 
 if test "$enable_bigstack" = "yes"; then
   AC_DEFINE(C_BIGSTACK,1,[Increase thread stack size.])
 fi
468b9e48
 
 AC_ARG_WITH(dbdir, 
9e8e9b3b
 [  --with-dbdir=path	  path to virus database directory],
468b9e48
 db_dir="$withval", db_dir="_default_")
 
 AC_ARG_WITH(db1, 
9e8e9b3b
 [  --with-db1=name	  name of the main database (default=main.cvd)],
8b242bb9
 AC_DEFINE_UNQUOTED(DB1NAME,"$withval",[Name of the main database]), AC_DEFINE(DB1NAME, "main.cvd",[Name of the main database]))
468b9e48
 
 AC_ARG_WITH(db2, 
9e8e9b3b
 [  --with-db2=name	  name of the daily database (default=daily.cvd)],
8b242bb9
 AC_DEFINE_UNQUOTED(DB2NAME,"$withval",[Name of the daily database]), AC_DEFINE(DB2NAME, "daily.cvd",[Name of the daily database]))
468b9e48
 
7084e554
 dnl I had problems with $pkgdatadir thus these funny checks
468b9e48
 if test "$db_dir" = "_default_"
 then
     if test "$prefix" = "NONE"
     then
 	db_dir="$ac_default_prefix/share/clamav"
     else
 	db_dir="$prefix/share/clamav"
     fi
 fi
 
 AC_DEFINE_UNQUOTED(DATADIR,"$db_dir", [Path to virus database directory.])
 DBDIR="$db_dir"
 AC_SUBST(DBDIR)
 
acda1fc1
 dnl configure config directory
468b9e48
 cfg_dir=`echo $sysconfdir | grep prefix`
4be012e9
 
468b9e48
 if test -n "$cfg_dir"; then
4be012e9
     if test "$prefix" = "NONE"
     then
 	cfg_dir="$ac_default_prefix/etc"
     else
 	cfg_dir="$prefix/etc"
     fi
468b9e48
 else
     cfg_dir="$sysconfdir"
 fi
 
 CFGDIR=$cfg_dir
 AC_SUBST(CFGDIR)
8b242bb9
 AC_DEFINE_UNQUOTED(CONFDIR,"$cfg_dir",[where to look for the config file])
468b9e48
 
acda1fc1
 dnl check for in_port_t definition
8890798d
 AC_TRY_RUN([
07f31bb5
 #include <sys/types.h>
8890798d
 #include <netinet/in.h>
 int main(int argc, char **argv) { in_port_t pt; pt = 0; return pt; }
 ], AC_DEFINE(HAVE_IN_PORT_T,1,[in_port_t is defined]), AC_MSG_RESULT(in_port_t is not defined))
17e0a170
 
b36c1911
 dnl check for in_addr_t definition
 AC_TRY_RUN([
 #include <sys/types.h>
 #include <netinet/in.h>
 int main(int argc, char **argv) { in_addr_t pt; pt = 0; return pt; }
 ], AC_DEFINE(HAVE_IN_ADDR_T,1,[in_addr_t is defined]), AC_MSG_RESULT(in_addr_t is not defined))
 
468b9e48
 case "$target_os" in
 linux*)
8b242bb9
     AC_DEFINE(C_LINUX,1,[target is linux])
468b9e48
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
 	TH_SAFE="-thread-safe"
8b242bb9
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
8c63271b
 	CLAMD_LIBS="$CLAMD_LIBS -lpthread"
ff28b69c
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread"
468b9e48
 	if test "$want_clamuko" = "yes"; then
8b242bb9
 	    AC_DEFINE(CLAMUKO,1,[enable clamuko])
468b9e48
 	fi
8c63271b
 	CLAMSCAN_LIBS="$CLAMSCAN_LIBS -lpthread"
468b9e48
     fi
ee218f69
     case `uname -r` in
     1.*|2.0.*)
        AC_DEFINE(INCOMPLETE_CMSG,1,[Early Linux doesn't set cmsg fields])
        ;;
     esac
468b9e48
     ;;
 cygwin*)
8b242bb9
     AC_DEFINE(C_CYGWIN,1,[os is cygwin])
468b9e48
     if test "$test_clamav" = "yes"; then
 	if test ! -r /etc/passwd; then
 	   test_clamav="no"
 	fi
     fi
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
 	TH_SAFE="-thread-safe"
8b242bb9
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
468b9e48
     fi
6448ade8
     use_gethostbyname_r="no"
468b9e48
     ;;
 solaris*)
8c63271b
     FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lresolv"
468b9e48
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
8c63271b
 	CLAMD_LIBS="$CLAMD_LIBS -lpthread -lresolv"
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread -lresolv"
468b9e48
 	TH_SAFE="-thread-safe"
8b242bb9
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
468b9e48
     fi
8b242bb9
     AC_DEFINE(C_SOLARIS,1,[os is solaris])
468b9e48
     ;;
 freebsd*)
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -pthread -lc_r"
8c63271b
 	CLAMD_LIBS="$CLAMD_LIBS -pthread -lc_r"
ff28b69c
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread -lc_r"
468b9e48
 	TH_SAFE="-thread-safe"
8b242bb9
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
e6b842b3
 	if test "$want_clamuko" = "yes"; then
 	    AC_DEFINE(CLAMUKO,1,[enable clamuko])
 	fi
468b9e48
     fi
e6b842b3
     AC_DEFINE(C_BSD,1,[os is freebsd])
9abbfd34
     use_gethostbyname_r="no"
468b9e48
     ;;
2f2fec5c
 dragonfly*)
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -pthread"
 	CLAMD_LIBS="$CLAMD_LIBS -pthread"
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread"
 	TH_SAFE="-thread-safe"
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
 	if test "$want_clamuko" = "yes"; then
 	    AC_DEFINE(CLAMUKO,1,[enable clamuko])
 	fi
     fi
     AC_DEFINE(C_BSD,1,[os is dragonfly])
     use_gethostbyname_r="no"
     ;;
562f9b01
 openbsd*)
50099661
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -pthread"
c41cd1f2
 	if test "$use_cr" = "no"; then
8c63271b
 	    CLAMD_LIBS="$CLAMD_LIBS -pthread"
562f9b01
 	    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread"
 	else
 	    CLAMD_LIBS="$CLAMD_LIBS -pthread -lc_r"
 	    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread -lc_r"
50099661
 	fi
 	TH_SAFE="-thread-safe"
cc938d61
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
50099661
     fi
562f9b01
     AC_DEFINE(C_BSD,1,[os is OpenBSD])
9abbfd34
     use_gethostbyname_r="no"
50099661
     ;;
562f9b01
 bsdi*)
468b9e48
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -pthread"
562f9b01
 	CLAMD_LIBS="$CLAMD_LIBS -pthread"
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread"
468b9e48
 	TH_SAFE="-thread-safe"
8b242bb9
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
468b9e48
     fi
562f9b01
     AC_DEFINE(C_BSD,1,[os is BSDI BSD/OS])
9abbfd34
     use_gethostbyname_r="no"
468b9e48
     ;;
 netbsd*)
cc938d61
      if test "$have_pthreads" = "yes"; then
  	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
  	CLAMD_LIBS="-lpthread"
  	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread"
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
7084e554
 	ADDITIONAL_LIBS="$LIBS -lpthread"
cc938d61
      fi
562f9b01
     AC_DEFINE(C_BSD,1,[os is NetBSD])
9abbfd34
     use_gethostbyname_r="no"
468b9e48
     ;;
 bsd*)
     AC_MSG_RESULT(Unknown BSD detected. Disabling thread support.)
     have_pthreads="no"
8b242bb9
     AC_DEFINE(C_BSD,1,[os is bsd flavor])
9abbfd34
     use_gethostbyname_r="no"
468b9e48
     ;;
 beos*)
     AC_MSG_RESULT(BeOS detected. Disabling thread support.)
     have_pthreads="no"
8b242bb9
     AC_DEFINE(C_BEOS,1,[os is beos])
468b9e48
     ;;
 darwin*)
8b242bb9
     AC_DEFINE(C_BSD,1,[os is bsd flavor])
     AC_DEFINE(C_DARWIN,1,[os is darwin])
b36c1911
     AC_DEFINE(BIND_8_COMPAT,1,[enable bind8 compatibility])
468b9e48
     use_netinfo="yes"
9abbfd34
     use_gethostbyname_r="no"
468b9e48
     ;;
193c72c5
 os2*)
     FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lsyslog"
     CLAMD_LIBS="$CLAMD_LIBS -lsyslog"
     CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsyslog"
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
 	CLAMD_LIBS="$CLAMD_LIBS -lpthread"
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread"
 	TH_SAFE="-thread-safe"
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
     fi
     AC_DEFINE(C_OS2,1,[os is OS/2])
     ;;
468b9e48
 sco*)
     dnl njh@bandsman.sco.uk: SCO Unix port
8c63271b
     dnl FRESHCLAM_LIBS="-lsocket"
     dnl CLAMD_LIBS="-lsocket"
     dnl CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsocket"
468b9e48
     ;;
 hpux*)
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
8c63271b
 	CLAMD_LIBS="$CLAMD_LIBS -lpthread"
ff28b69c
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread"
468b9e48
 	TH_SAFE="-thread-safe"
8b242bb9
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
468b9e48
     fi
8b242bb9
     AC_DEFINE(C_HPUX,1,[os is hpux])
468b9e48
     ;;
 aix*)
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
8c63271b
 	CLAMD_LIBS="$CLAMD_LIBS -lpthread"
ff28b69c
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread"
468b9e48
 	TH_SAFE="-thread-safe"
8b242bb9
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
468b9e48
     fi
8b242bb9
     AC_DEFINE(C_AIX,1,[os is aix])
468b9e48
     ;;
bf43f458
 nto-qnx*)
      if test "$have_pthreads" = "yes"; then
        AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
        AC_DEFINE(_REENTRANT,1,[thread safe])
      fi
     AC_DEFINE(C_QNX6,1,[os is QNX 6.x.x])
     ;;
468b9e48
 irix*)
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
8c63271b
 	CLAMD_LIBS="$CLAMD_LIBS -lpthread"
ff28b69c
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread"
468b9e48
 	TH_SAFE="-thread-safe"
8b242bb9
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
468b9e48
     fi
8b242bb9
     AC_DEFINE(C_IRIX,1,[os is irix])
468b9e48
     ;;
618a038b
 interix*)
     AC_DEFINE(C_INTERIX,1,[os is interix])
     if test "$test_clamav" = "yes"; then
 	if test ! -r /etc/passwd; then
 	   test_clamav="no"
 	fi
     fi
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
 	TH_SAFE="-thread-safe"
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
     fi
     ;;
468b9e48
 *)
     ;;
 esac
 
 AC_SUBST(LIBCLAMAV_LIBS)
 AC_SUBST(CLAMD_LIBS)
ff28b69c
 AC_SUBST(CLAMAV_MILTER_LIBS)
468b9e48
 AC_SUBST(FRESHCLAM_LIBS)
 AC_SUBST(TH_SAFE)
7084e554
 AC_SUBST(ADDITIONAL_LIBS)
468b9e48
 
acda1fc1
 dnl --enable-milter
252cb5ba
 if test "$have_milter" = "yes"; then
acda1fc1
     dnl libmilter checking code adapted from spamass-milter by
     dnl Tom G. Christensen <tgc@statsbiblioteket.dk>
252cb5ba
 
acda1fc1
     dnl Check for libmilter and it's header files in the usual locations
252cb5ba
     save_LDFLAGS="$LDFLAGS"
     if test -d /usr/lib/libmilter ; then
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -L/usr/lib/libmilter"
     fi
7addd7a5
     LDFLAGS="$LDFLAGS -lmilter $CLAMAV_MILTER_LIBS"
     AC_CHECK_LIB(milter, mi_stop,[CLAMAV_MILTER_LIBS="-lmilter $CLAMAV_MILTER_LIBS"],[
acda1fc1
 	dnl Older sendmails require libsm or libsmutil for support functions
252cb5ba
 	AC_SEARCH_LIBS(strlcpy, [sm smutil], [test "$ac_cv_search_strlcpy" = "none required" || CLAMAV_MILTER_XLIB="$ac_cv_search_strlcpy"])
 	LDFLAGS="$save_LDFLAGS $CLAMAV_MILTER_LIBS $CLAMAV_MILTER_XLIB"
 	$as_unset ac_cv_lib_milter_mi_stop
7addd7a5
 	AC_CHECK_LIB(milter, mi_stop,[CLAMAV_MILTER_LIBS="-lmilter $CLAMAV_MILTER_XLIB $CLAMAV_MILTER_LIBS"],[
252cb5ba
 	    AC_MSG_ERROR([Cannot find libmilter])
 	])
     ])
     LDFLAGS="$save_LDFLAGS"
     AC_CHECK_HEADERS(libmilter/mfapi.h,have_milter="yes",[
 	AC_MSG_ERROR([Please install mfapi.h from the sendmail distribution])
     ])
 fi
 
13847a2d
 AM_CONDITIONAL(BUILD_CLAMD, test "$have_pthreads" = "yes")
468b9e48
 AM_CONDITIONAL(HAVE_MILTER, test "$have_milter" = "yes")
 
13847a2d
 if test "$have_pthreads" = "yes"
 then
8b242bb9
     AC_DEFINE(BUILD_CLAMD, 1, "build clamd")
13847a2d
 fi
468b9e48
 
ee218f69
 dnl Check if we can do fd passing
 dnl Submitted by Richard Lyons <frob-clamav@webcentral.com.au>
 AC_CHECK_FUNCS(recvmsg sendmsg)
 AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
 	ac_cv_have_accrights_in_msghdr, [
     AC_TRY_RUN(
 	[
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
 int main() {
 #ifdef msg_accrights
 exit(1);
 #endif
 struct msghdr m;
 m.msg_accrights = 0;
 exit(0);
 }
 	],
 	[ ac_cv_have_accrights_in_msghdr="yes" ],
 	[ ac_cv_have_accrights_in_msghdr="no" ]
     )
 ])
 if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
     AC_DEFINE(HAVE_ACCRIGHTS_IN_MSGHDR,1,[access rights in msghdr])
 fi
 
 AC_CACHE_CHECK([for msg_control field in struct msghdr],
 	ac_cv_have_control_in_msghdr, [
     AC_TRY_RUN(
 	[
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
 int main() {
 #ifdef msg_control
 exit(1);
 #endif
 struct msghdr m;
 m.msg_control = 0;
 exit(0);
 }
 	],
 	[ ac_cv_have_control_in_msghdr="yes" ],
 	[ ac_cv_have_control_in_msghdr="no" ]
     )
 ])
 if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
     AC_DEFINE(HAVE_CONTROL_IN_MSGHDR,1,[ancillary data style fd pass])
 fi
 
acda1fc1
 dnl tcpwrappers support
 dnl rules from http://ma.ph-freiburg.de/tng/tng-technical/2002-01/msg00094.html
fdbbe9f3
 AC_ARG_WITH(tcpwrappers,
9e8e9b3b
 [  --with-tcpwrappers      support hosts.allow / hosts.deny (default=auto)],
fdbbe9f3
 [ case "$withval" in
   yes|no) tcpw="$withval" ;;
   *)      AC_MSG_ERROR([--with-tcpwrappers does not take an argument]) ;;
   esac],
 [ tcpw=auto ])
 
 if test "$tcpw" != "no" && test "$have_milter" = "yes" ; then
         AC_CHECK_HEADERS(tcpd.h,[
                 AC_MSG_CHECKING([for TCP wrappers library])
                 save_LIBS="$LIBS"
                 LIBS="$LIBS -lwrap $FRESHCLAM_LIBS"
                 AC_TRY_LINK([
 #include <tcpd.h>
 int allow_severity = 0;
 int deny_severity  = 0;
 
 struct request_info *req;
                 ],[
 hosts_access(req)
                 ],[AC_MSG_RESULT([-lwrap])
                 have_wrappers=yes
 		LIBS="$save_LIBS"
                 CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lwrap"],[
                 dnl try with -lnsl
                 LIBS="$LIBS -lnsl $FRESHCLAM_LIBS"
                 AC_TRY_LINK([
 #include <tcpd.h>
 int allow_severity = 0;
 int deny_severity  = 0;
 
 struct request_info *req;
                 ],[
 hosts_access(req)
                 ],[AC_MSG_RESULT([-lwrap -lnsl])
                 have_wrappers=yes
                 CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lwrap"],[
                 AC_MSG_RESULT(no)
                 have_wrappers=no
                 LIBS=$save_LIBS])],[
                 have_wrappers=no])],[have_wrappers=no])
 
         if test $have_wrappers = yes ; then
                 AC_DEFINE(WITH_TCPWRAP,1, [tcpwrappers support])
         elif test $tcpw = yes ; then
                 AC_MSG_ERROR([could not find TCP wrappers])
         else
                 AC_MSG_WARN([could not find TCP wrappers, support disabled])
         fi
 fi
 
acda1fc1
 dnl Check for gethostbyname_r and number of its arguments
 dnl Code from libwww/configure.in
 AC_MSG_CHECKING(for gethostbyname_r)
 if test -z "$ac_cv_gethostbyname_args"; then
 AC_TRY_COMPILE(
 [
 #include <sys/types.h>
 #include <netdb.h>
 ],[
 struct hostent *hp;
 struct hostent h;
 char *name;
 char buffer[10];
 int  h_errno;
 hp = gethostbyname_r(name, &h, buffer, 10, &h_errno);
 ], ac_cv_gethostbyname_args=5)
 fi
 if test -z "$ac_cv_gethostbyname_args"; then
 AC_TRY_COMPILE(
 [
 #include <sys/types.h>
 #include <netdb.h>
 ],[
 struct hostent h;
 struct hostent_data hdata;
 char *name;
 int  rc;
 rc = gethostbyname_r(name, &h, &hdata);
 ], ac_cv_gethostbyname_args=3)
 fi
 if test -z "$ac_cv_gethostbyname_args"; then
 AC_TRY_COMPILE(
 [
 #include <sys/types.h>
 #include <netdb.h>
 ], [
 struct hostent h;
 struct hostent *hp;
 char *name;
 char buf[10];
 int rc;
 int h_errno;
 
 rc = gethostbyname_r(name, &h, buf, 10, &hp, &h_errno);
 ], ac_cv_gethostbyname_args=6)
 fi
9e8e9b3b
 
 AC_ARG_ENABLE(gethostbyname_r,
 [  --disable-gethostbyname_r	  disable support for gethostbyname_r],
9abbfd34
 use_gethostbyname_r=$enableval,)
9e8e9b3b
 
9abbfd34
 if test "$use_gethostbyname_r" = "no"; then
31688031
     AC_MSG_RESULT(support disabled)
 elif test -z "$ac_cv_gethostbyname_args"; then
acda1fc1
     AC_MSG_RESULT(no)
 else
     if test "$ac_cv_gethostbyname_args" = 3; then
 	AC_DEFINE(HAVE_GETHOSTBYNAME_R_3,1,[gethostbyname_r takes 3 arguments])
     elif test "$ac_cv_gethostbyname_args" = 5; then
 	AC_DEFINE(HAVE_GETHOSTBYNAME_R_5,1,[gethostbyname_r takes 5 arguments])
     elif test "$ac_cv_gethostbyname_args" = 6; then
 	AC_DEFINE(HAVE_GETHOSTBYNAME_R_6,1,[gethostbyname_r takes 6 arguments])
     fi
     AC_MSG_RESULT([yes, and it takes $ac_cv_gethostbyname_args arguments])
 fi
468b9e48
 
ec748835
 dnl Check for readdir_r and number of its arguments
 dnl Code from libwww/configure.in
 
 AC_MSG_CHECKING(for readdir_r)
 if test -z "$ac_cv_readdir_args"; then
     AC_TRY_COMPILE(
     [
 #include <sys/types.h>
 #include <dirent.h>
     ],
     [
     struct dirent dir, *dirp;
     DIR *mydir;
     dirp = readdir_r(mydir, &dir);
     ], ac_cv_readdir_args=2)
 fi
 if test -z "$ac_cv_readdir_args"; then
     AC_TRY_COMPILE(
         [
 #include <sys/types.h>
 #include <dirent.h>
     ],
     [
         struct dirent dir, *dirp;
         DIR *mydir;
         int rc;
         rc = readdir_r(mydir, &dir, &dirp);
     ], ac_cv_readdir_args=3)
 fi
 
 AC_ARG_ENABLE(readdir_r,
aa23f2c0
 [  --enable-readdir_r		    enable support for readdir_r],
 enable_readdir_r=$enableval, enable_readdir_r="no")
ec748835
 
aa23f2c0
 if test "$enable_readdir_r" = "no"; then
31688031
     AC_MSG_RESULT(support disabled)
 elif test -z "$ac_cv_readdir_args"; then
ec748835
     AC_MSG_RESULT(no)
 else
     if test "$ac_cv_readdir_args" = 2; then
 	AC_DEFINE(HAVE_READDIR_R_2,1,[readdir_r takes 2 arguments])
     elif test "$ac_cv_readdir_args" = 3; then
 	AC_DEFINE(HAVE_READDIR_R_3,1,[readdir_r takes 3 arguments])
     fi
     AC_MSG_RESULT([yes, and it takes $ac_cv_readdir_args arguments])
 fi
 
944631c9
 AC_MSG_CHECKING(for ctime_r)
 if test "$ac_cv_func_ctime_r" = "yes"; then
     AC_TRY_COMPILE([
 	#include <time.h>
     ],[
 	char buf[31];
 	time_t t;
 	ctime_r(&t, buf, 30);
     ],[
 	ac_cv_ctime_args=3
 	AC_DEFINE(HAVE_CTIME_R_3,1,[ctime_r takes 3 arguments])
     ],[
 	ac_cv_ctime_args=2
 	AC_DEFINE(HAVE_CTIME_R_2,1,[ctime_r takes 2 arguments])
     ])
 
     AC_MSG_RESULT([yes, and it takes $ac_cv_ctime_args arguments])
 fi
 
8afd932c
 dnl Determine socklen_t type. Code from lftp.
 AC_MSG_CHECKING(for socklen_t)
 AC_CACHE_VAL(ac_cv_socklen_t,
 [
     ac_cv_socklen_t=no
     AC_TRY_COMPILE([
 	#include <sys/types.h>
         #include <sys/socket.h>
     ],
     [
 	socklen_t len;
         getpeername(0,0,&len);
     ],
     [
 	ac_cv_socklen_t=yes
     ])
 ])
 AC_MSG_RESULT($ac_cv_socklen_t)
     if test $ac_cv_socklen_t = no; then
     AC_MSG_CHECKING(for socklen_t equivalent)
     AC_CACHE_VAL(ac_cv_socklen_t_equiv,
     [
 	ac_cv_socklen_t_equiv=int
         for t in int size_t unsigned long "unsigned long"; do
 	    AC_TRY_COMPILE([
 		#include <sys/types.h>
 		#include <sys/socket.h>
 	    ],
             [
 		$t len;
 		getpeername(0,0,&len);
             ],
             [
 		ac_cv_socklen_t_equiv="$t"
 		break
             ])
 	done
     ])
     AC_MSG_RESULT($ac_cv_socklen_t_equiv)
     AC_DEFINE_UNQUOTED(socklen_t, $ac_cv_socklen_t_equiv, [Define to "int" if <sys/socket.h> does not define.])
 fi
 
acda1fc1
 dnl Check for clamav in /etc/passwd
468b9e48
 if test "$test_clamav" = "yes"
 then
acda1fc1
     dnl parse /etc/passwd
     if test "$use_id" = "no"
468b9e48
     then
acda1fc1
 	AC_MSG_CHECKING(for $clamav_user in /etc/passwd)
468b9e48
 	if test -r /etc/passwd; then
acda1fc1
 	    clamavuser=`cat /etc/passwd|grep $clamav_user`
 	    clamavgroup=`cat /etc/group|grep $clamav_group`
468b9e48
 	fi
     else
acda1fc1
 	AC_MSG_CHECKING(for $clamav_user using id)
468b9e48
 	id $clamav_user > /dev/null 2>&1
 	if test "$?" = 0 ; then
 	    clamavuser=1
 	    AC_PATH_PROG(GETENT, getent)
 	    if test -n "$GETENT" ; then
 		clamavgroup=`$GETENT group | grep "^${clamav_group}:"`
 	    else
 		clamavgroup=`cat /etc/group|grep $clamav_group`
 	    fi
 	fi
     fi
 
     if test "$use_netinfo" = "yes"
     then
acda1fc1
 	AC_MSG_CHECKING(for $clamav_user using netinfo)
468b9e48
         clamavuser=`/usr/bin/nidump passwd . |grep ${clamav_user}`
         clamavgroup=`/usr/bin/nidump group . |grep ${clamav_group}`
     fi
 
20814a85
     if test "$use_yp" = "yes"
     then
acda1fc1
 	AC_MSG_CHECKING(for $clamav_user using ypmatch)
20814a85
         clamavuser=`ypmatch ${clamav_user} passwd`
         clamavgroup=`ypmatch ${clamav_group} group`
     fi
 
468b9e48
     if test -z "$clamavuser" || test -z "$clamavgroup"
     then
acda1fc1
 	AC_MSG_RESULT(no)
 	AC_MSG_ERROR(User $clamav_user (and/or group $clamav_group) doesn't exist. Please read the documentation !)
468b9e48
     else
acda1fc1
 	AC_MSG_RESULT([yes, user $clamav_user and group $clamav_group])
         CLAMAVUSER="$clamav_user"
         CLAMAVGROUP="$clamav_group"
468b9e48
         AC_SUBST(CLAMAVUSER)
         AC_SUBST(CLAMAVGROUP)
     fi
 fi
 
 AC_C_CONST
9b29874a
 AC_C_INLINE
468b9e48
 AC_C_BIGENDIAN
 if test $ac_cv_c_bigendian = yes; then
8b242bb9
   AC_DEFINE(WORDS_BIGENDIAN,1,endianess)
468b9e48
 else
8b242bb9
   AC_DEFINE(WORDS_BIGENDIAN,0,endianess)
468b9e48
 fi
 
50099661
 dnl check for __attribute__((packed))
 AC_MSG_CHECKING([for structure packing via __attribute__((packed))])
 AC_CACHE_VAL(have_attrib_packed,[
 	AC_TRY_COMPILE(,
 		[struct { int i __attribute__((packed)); } s; ],
 		[have_attrib_packed=yes],
 		[have_attrib_packed=no])
 	])
 AC_MSG_RESULT($have_attrib_packed)
 
 if test "$have_attrib_packed" = no; then
 	AC_MSG_CHECKING(for structure packing via pragma)
 	AC_CACHE_VAL(have_pragma_pack,[
17e0a170
 		AC_TRY_RUN([int main(int argc, char **argv) {
50099661
 #pragma pack(1)			/* has to be in column 1 ! */
 			struct { char c; long l; } s;
 			return sizeof(s)==sizeof(s.c)+sizeof(s.l) ? 0:1; } ],
 			[have_pragma_pack=yes],
 			[have_pragma_pack=no])
 		])
 	AC_MSG_RESULT($have_pragma_pack)
8b242bb9
 	AC_DEFINE(HAVE_PRAGMA_PACK, 1, "pragma pack")
50099661
 fi
 
3623f7d1
 dnl check for __attribute__((aligned))
 AC_MSG_CHECKING([for type aligning via __attribute__((aligned))])
 AC_CACHE_VAL(have_attrib_aligned,[
 	AC_TRY_COMPILE(,
 		[typedef int cl_aligned_int __attribute__((aligned));],
 		[have_attrib_aligned=yes],
 		[have_attrib_aligned=no])
 	])
 AC_MSG_RESULT($have_attrib_aligned)
 
50099661
 if test "$have_attrib_packed" = no -a "$have_pragma_pack" = no ; then
 	AC_MSG_ERROR(Need to know how to pack structures with this compiler)
 fi
3623f7d1
 
50099661
 if test "$have_attrib_packed" = yes; then
3623f7d1
 	AC_DEFINE(HAVE_ATTRIB_PACKED, 1, [attrib packed])
 fi
 
 if test "$have_attrib_aligned" = yes; then
 	AC_DEFINE(HAVE_ATTRIB_ALIGNED, 1, [attrib aligned])
50099661
 fi
 
acda1fc1
 dnl Check if <sys/select.h> needs to be included for fd_set
25872bbb
 AC_MSG_CHECKING([for fd_set])
 AC_TRY_COMPILE([#include <sys/types.h>],
         [fd_set readMask, writeMask;], have_fd_set=yes, have_fd_set=no)
 if test $have_fd_set = yes; then
     AC_MSG_RESULT([yes, found in sys/types.h])
 else
     AC_HEADER_EGREP(fd_mask, sys/select.h, have_fd_set=yes)
     if test $have_fd_set = yes; then
         AC_DEFINE(HAVE_SYS_SELECT_H, 1, "have <sys/select.h>")
         AC_MSG_RESULT([yes, found in sys/select.h])
     else
         AC_DEFINE(NO_FD_SET, 1, "no fd_set")
         AC_MSG_RESULT(no)
     fi
 fi
 
acda1fc1
 AC_MSG_CHECKING(default FD_SETSIZE value)
a156b0cd
 AC_TRY_RUN([
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/time.h>
 #include <sys/select.h>
 #include <sys/types.h>
 main() {
         FILE *fp = fopen("conftestval", "w");
         fprintf (fp, "%d\n", FD_SETSIZE);
         exit(0);
 }
 ],
 DEFAULT_FD_SETSIZE=`cat conftestval`,
 DEFAULT_FD_SETSIZE=256,
 DEFAULT_FD_SETSIZE=256)
 AC_MSG_RESULT($DEFAULT_FD_SETSIZE)
 AC_DEFINE_UNQUOTED(DEFAULT_FD_SETSIZE, $DEFAULT_FD_SETSIZE, "default FD_SETSIZE value")
 
468b9e48
 AC_OUTPUT([
 libclamav/Makefile
 clamscan/Makefile
 database/Makefile
 docs/Makefile
 clamd/Makefile
 clamdscan/Makefile
 clamav-milter/Makefile
 freshclam/Makefile
 sigtool/Makefile
4b6f0067
 clamconf/Makefile
468b9e48
 etc/Makefile
 Makefile
eeb69538
 clamav-config
 libclamav.pc
b36c1911
 docs/man/clamd.8
 docs/man/clamd.conf.5
 docs/man/freshclam.1
 docs/man/freshclam.conf.5
468b9e48
 ])