configure.in
468b9e48
 dnl
17e0a170
 dnl   Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.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
 dnl   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 AC_INIT(clamscan/clamscan.c)
 AC_CREATE_TARGET_H(target.h)
2e3e5525
 AM_INIT_AUTOMAKE(clamav, "0.72")
8b242bb9
 AM_CONFIG_HEADER(clamav-config.h)
 
468b9e48
 LC_CURRENT=1
5b68a87c
 LC_REVISION=4
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
1ed6a845
 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)
468b9e48
 AC_TYPE_OFF_T
 AC_COMPILE_CHECK_SIZEOF(short)
 AC_COMPILE_CHECK_SIZEOF(int)
 AC_COMPILE_CHECK_SIZEOF(long)
ad640f0b
 AC_CHECK_FUNCS(poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat inet_ntop)
fdbbe9f3
 AC_FUNC_MMAP
1ed6a845
 AC_FUNC_FSEEKO
36f2038b
 
 # Check for broken snprintf
 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],)
 
8b242bb9
 AC_CHECK_HEADER(zlib.h,[LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lz"; AC_DEFINE(HAVE_ZLIB_H,1,zlib installed)],[echo "Please install zlib and zlib-devel packages."; exit 1])
468b9e48
 
 want_bzip2="yes"
 AC_ARG_ENABLE(bzip2,
 [  --disable-bzip2	  Disable bzip2 support.],
 want_bzip2="no",)
 
 if test "$want_bzip2" = "yes"
 then
7084e554
     AC_CHECK_HEADER(bzlib.h,[LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lbz2"; AC_DEFINE(HAVE_BZLIB_H,1,have bzip2)],[echo "WARNING: Bzip2 support disabled"])
8b242bb9
     AC_CHECK_LIB(bz2, bzReadOpen, AC_DEFINE(NOBZ2PREFIX,1,bzip funtions do not have bz2 prefix),)
468b9e48
 fi
 
e6b842b3
 want_clamuko="yes"
 AC_ARG_ENABLE(clamuko,
 [  --disable-clamuko	  Disable clamuko support (Linux and FreeBSD only)],
 want_clamuko="no",)
 
cf899a29
 AC_FUNC_SETPGRP
 
468b9e48
 have_milter="no"
 AC_CHECK_HEADER(libmilter/mfapi.h,have_milter="yes",)
 
 AC_ARG_ENABLE(milter,
 [  --enable-milter	  Build clamav-milter (if milter library found)],
 ,have_milter="no")
 
4bf2cf8d
 want_dsig="yes"
 AC_ARG_ENABLE(dsig,
 [  --disable-dsig	  Disable digital signature support.],
 want_dsig="no",)
 
 if test "$want_dsig" = "yes"
 then
8b242bb9
     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)], [echo "WARNING: GNU MP 2 or newer NOT FOUND - digital signature support will be disabled !"; want_dsig="no"])])
4bf2cf8d
 fi
 
36f2038b
 AC_CHECK_HEADER(syslog.h,AC_DEFINE(USE_SYSLOG,1,[use syslog]),)
468b9e48
 
 AC_ARG_ENABLE(pthreads,
 [  --disable-pthreads      Disable POSIX threads support],
e8217f5a
 have_pthreads=no, )
468b9e48
 
 AC_ARG_ENABLE(cr,
 [  --disable-cr      Don't link with C reentrant library (BSD) ],
 disable_cr=yes,)
 
 test_urandom=yes
 AC_ARG_ENABLE(urandom,
 [  --disable-urandom       Disable test for /dev/urandom],
 test_urandom=no,)
 
 AC_ARG_ENABLE(id-check,
 [  --enable-id-check	  Use id utility instead of /etc/passwd parsing],
 use_id="yes", use_id="no")
 
20814a85
 AC_ARG_ENABLE(yp-check,
 [  --enable-yp-check	  Use ypmatch utility instead of /etc/passwd parsing],
 use_yp="yes", use_yp="no")
 
468b9e48
 AC_ARG_WITH(user, 
 [  --with-user=uid	  name of the clamav user (default=clamav).],
 clamav_user="$withval", clamav_user="clamav")
 
 AC_ARG_WITH(group, 
 [  --with-group=gid	  name of the clamav group (default=clamav).],
 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
 
 test_clamav=yes
 AC_ARG_ENABLE(clamav,
 [  --disable-clamav	  Disable test for clamav user/group],
 test_clamav=no,)
 
 AC_ARG_ENABLE(debug,
 [  --enable-debug	  Enable debug messages.],
8b242bb9
 AC_DEFINE(CL_DEBUG,1,[enable debugging]),)
468b9e48
 
 AC_ARG_ENABLE(bigstack,
 [  --enable-bigstack	  Increase thread stack size.],
8b242bb9
 AC_DEFINE(C_BIGSTACK,1,[Increase thread stack size.]),)
468b9e48
 
 AC_ARG_WITH(dbdir, 
 [  --with-dbdir=path	  Path to virus database directory.],
 db_dir="$withval", db_dir="_default_")
 
 AC_ARG_WITH(db1, 
442d8407
 [  --with-db1=name	  Name of the main database (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, 
442d8407
 [  --with-db2=name	  Name of the daily database (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)
 
 # config file
 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
 
7084e554
 dnl Do not overwrite current config files
0d98d74c
 AM_CONDITIONAL(INSTALL_CLAMAV_CONF, test ! -r "$cfg_dir/clamav.conf")
 AM_CONDITIONAL(INSTALL_FRESHCLAM_CONF, test ! -r "$cfg_dir/freshclam.conf")
468b9e48
 
17e0a170
 # 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
 
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])
468b9e48
 	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
 	CLAMSCAN_LIBS="-lpthread"
     fi
     ;;
 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
     ;;
 solaris*)
c6259ac5
     FRESHCLAM_LIBS="-lsocket -lnsl -lresolv"
468b9e48
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
80dbbf08
 	CLAMD_LIBS="-lpthread -lsocket -lnsl -lresolv"
ff28b69c
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread -lsocket -lnsl -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"
 	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])
468b9e48
     ;;
50099661
 openbsd3.3*)
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -pthread"
 	if test "$disable_cr" = "yes"; then
 	    CLAMD_LIBS="-pthread"
ff28b69c
 	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread"
50099661
 	fi
 	TH_SAFE="-thread-safe"
cc938d61
 	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
 	AC_DEFINE(_REENTRANT,1,[thread safe])
50099661
     fi
36f2038b
     AC_DEFINE(C_BSD,1,[os is bsd flavor])
50099661
     ;;
468b9e48
 openbsd*)
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -pthread"
 	if test "$disable_cr" = "yes"; then
 	    CLAMD_LIBS="-pthread"
ff28b69c
 	    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread"
468b9e48
 	else
 	    CLAMD_LIBS="-pthread -lc_r"
ff28b69c
 	    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread -lc_r"
468b9e48
 	fi
 	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_BSD,1,[os is bsd flavor])
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
8b242bb9
     AC_DEFINE(C_BSD,1,[os is bsd flavor])
468b9e48
     ;;
 bsd*)
     AC_MSG_RESULT(Unknown BSD detected. Disabling thread support.)
     have_pthreads="no"
8b242bb9
     AC_DEFINE(C_BSD,1,[os is bsd flavor])
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])
468b9e48
     use_netinfo="yes"
     ;;
 sco*)
     dnl njh@bandsman.sco.uk: SCO Unix port
     FRESHCLAM_LIBS="-lsocket"
     CLAMD_LIBS="-lsocket"
ff28b69c
     CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsocket"
468b9e48
     ;;
 hpux*)
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
 	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"
 	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
     ;;
 irix*)
     if test "$have_pthreads" = "yes"; then
 	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
 	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
     ;;
 
 *)
     ;;
 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
 
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
 
bef39227
 if test "$have_milter" = "yes"
 then
     AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail, $PATH:/usr/lib:/usr/sbin:/etc:/usr/local/lib:/usr/local/sbin:/usr/bin:/usr/local/bin)
 fi
 
fdbbe9f3
 # tcpwrappers support
 # rules from http://ma.ph-freiburg.de/tng/tng-technical/2002-01/msg00094.html
 AC_ARG_WITH(tcpwrappers,
 [  --with-tcpwrappers      Support hosts.allow / hosts.deny (default=auto)],
 [ 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
 
468b9e48
 dnl Check for clamav in /etc/passwd
 
 if test "$test_clamav" = "yes"
 then
     # parse /etc/passwd
     if test "$use_id" = no
     then
 	AC_MSG_RESULT(Checking /etc/passwd...)
 	if test -r /etc/passwd; then
 	    clamavuser=`cat /etc/passwd|grep ${clamav_user}`
 	    clamavgroup=`cat /etc/group|grep ${clamav_group}`
 	fi
     else
 	AC_MSG_RESULT(Checking id output...)
 	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
         clamavuser=`/usr/bin/nidump passwd . |grep ${clamav_user}`
         clamavgroup=`/usr/bin/nidump group . |grep ${clamav_group}`
     fi
 
20814a85
     if test "$use_yp" = "yes"
     then
         clamavuser=`ypmatch ${clamav_user} passwd`
         clamavgroup=`ypmatch ${clamav_group} group`
     fi
 
468b9e48
     if test -z "$clamavuser" || test -z "$clamavgroup"
     then
         echo "ERROR: User \"$clamav_user\" (and/or group \"$clamav_group\") doesn't exist. Please create it. You can omit this check with the --disable-clamav option."
         exit 1
     else
         CLAMAVUSER="${clamav_user}"
         CLAMAVGROUP="${clamav_group}"
         AC_SUBST(CLAMAVUSER)
         AC_SUBST(CLAMAVGROUP)
     fi
 fi
 
 AC_C_CONST
 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
 
 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
 if test "$have_attrib_packed" = yes; then
8b242bb9
 	AC_DEFINE(HAVE_ATTRIB_PACKED, 1, "attrib packed")
50099661
 fi
 
25872bbb
 # Check if <sys/select.h> needs to be included for fd_set
 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
 
a156b0cd
 AC_MSG_CHECKING(Default FD_SETSIZE value)
 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
 etc/Makefile
 Makefile
 ])