File: configure.in

package info (click to toggle)
clamav 0.84-2.sarge.17
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,860 kB
  • ctags: 3,809
  • sloc: ansic: 40,520; sh: 9,258; cpp: 937; makefile: 555; perl: 131
file content (943 lines) | stat: -rw-r--r-- 28,726 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
dnl
dnl   Copyright (C) 2002 - 2005 Tomasz Kojm <tkojm@clamav.net>
dnl   gethostbyname_r and readdir_r checks (c) COPYRIGHT MIT 1995
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)
AM_INIT_AUTOMAKE(clamav, "0.84")
AM_CONFIG_HEADER(clamav-config.h)

LC_CURRENT=1
LC_REVISION=10
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

AC_DEFINE(SCANBUFF, 131072, [scan buffer size])
AC_DEFINE(FILEBUFF, 8192,   [file i/o buffer size])

AC_HEADER_STDC
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)
AC_CHECK_HEADER(syslog.h,AC_DEFINE(USE_SYSLOG,1,[use syslog]),)

AC_TYPE_OFF_T
AC_COMPILE_CHECK_SIZEOF(short)
AC_COMPILE_CHECK_SIZEOF(int)
AC_COMPILE_CHECK_SIZEOF(long)
AC_COMPILE_CHECK_SIZEOF(long long)

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"])

AC_CHECK_FUNCS(poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat inet_ntop setgroups initgroups ctime_r)
AC_FUNC_MMAP
AC_FUNC_FSEEKO

dnl Check for broken snprintf (code by Phil Oleson <oz*nixil.net>)
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

have_pthreads=no
AC_CHECK_HEADER(pthread.h,[have_pthreads=yes],)

AM_MAINTAINER_MODE
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)
])

zlib_check="yes"
AC_ARG_ENABLE(zlib-vcheck,
[  --disable-zlib-vcheck	  do not check for buggy zlib version ],
zlib_check="no",)

if test ! -f "$ZLIB_HOME/include/zlib.h"
then
    AC_MSG_ERROR(Please install zlib and zlib-devel packages)
else

    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
	if test "$zlib_check" = "yes"; then
	    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!)
	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
    fi

    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
fi

want_bzip2="yes"
AC_ARG_ENABLE(bzip2,
[  --disable-bzip2	  disable bzip2 support],
want_bzip2="no",)

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

AC_ARG_ENABLE(dns,
    AC_HELP_STRING([--disable-dns], [disable support for database verification through DNS]),
    [want_dns=$enableval], [want_dns=yes]
)
if test $want_dns = yes; then
    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
    AC_CHECK_HEADER(resolv.h,[FRESHCLAM_LIBS="$FRESHCLAM_LIBS $resolv_lib"; AC_DEFINE(HAVE_RESOLV_H,1,have resolv.h)], AC_MSG_WARN([****** DNS support disabled]))
fi

want_clamuko="yes"
AC_ARG_ENABLE(clamuko,
[  --disable-clamuko	  disable clamuko support (Linux and FreeBSD only)],
want_clamuko="no",)

AC_FUNC_SETPGRP

AC_ARG_ENABLE(milter,
[  --enable-milter	  build clamav-milter],
have_milter=$enableval,have_milter="no")

want_dsig="yes"
AC_ARG_ENABLE(dsig,
[  --disable-dsig	  disable support for digital signatures],
want_dsig="no",)

if test "$want_dsig" = "yes"
then
    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")])
fi

dnl libcurl
AC_ARG_WITH(libcurl,
[  --with-libcurl	  support URLs downloading with libcurl (default=auto)],
[ case "$withval" in
  yes|no) lcurl="$withval" ;;
  *)      AC_MSG_ERROR([--with-libcurl does not take an argument]) ;;
  esac],
[ lcurl=auto ])

dnl Based on http://curl.signal42.com/libcurl/using/autoconf.html
if test "$lcurl" != "no"
then
    my_cv_curl_vers=NONE
    dnl check is the plain-text version of the required version
    check="7.10.0"
    dnl check_hex must be UPPERCASE if any hex letters are present
    check_hex="070A00"

    AC_MSG_CHECKING([for curl >= $check])

    if eval curl-config --version 2>/dev/null >/dev/null; then
	ver=`curl-config --version | sed -e "s/libcurl //g"`
	hex_ver=`curl-config --vernum | tr 'a-f' 'A-F'`
	fail=`echo "ibase=16; if($hex_ver<$check_hex) 1" | bc`

	if test x$fail != x1; then
	    curl_libs=`curl-config --libs`
	    LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS $curl_libs"
	    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
    else
	AC_MSG_RESULT(FAILED)
	AC_MSG_WARN([curl-config was not found])
    fi
fi

AC_ARG_ENABLE(pthreads,
[  --disable-pthreads      disable POSIX threads support],
have_pthreads=no, )

AC_ARG_ENABLE(cr,
[  --disable-cr		  don't link with C reentrant library (BSD) ],
disable_cr=yes,)

AC_ARG_ENABLE(id-check,
[  --enable-id-check	  use id utility instead of /etc/passwd parsing],
use_id="yes", use_id="no")

AC_ARG_ENABLE(yp-check,
[  --enable-yp-check	  use ypmatch utility instead of /etc/passwd parsing],
use_yp="yes", use_yp="no")

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")

AC_DEFINE_UNQUOTED(CLAMAVUSER,"$clamav_user",[name of the clamav user])
AC_DEFINE_UNQUOTED(CLAMAVGROUP,"$clamav_group",[name of the clamav group])

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 code],
AC_DEFINE(CL_DEBUG,1,[enable debugging]),)

AC_ARG_ENABLE(bigstack,
[  --enable-bigstack	  increase thread stack size],
AC_DEFINE(C_BIGSTACK,1,[Increase thread stack size.]),)

AC_ARG_WITH(dbdir, 
[  --with-dbdir=path	  path to virus database directory],
db_dir="$withval", db_dir="_default_")

AC_ARG_WITH(db1, 
[  --with-db1=name	  name of the main database (default=main.cvd)],
AC_DEFINE_UNQUOTED(DB1NAME,"$withval",[Name of the main database]), AC_DEFINE(DB1NAME, "main.cvd",[Name of the main database]))

AC_ARG_WITH(db2, 
[  --with-db2=name	  name of the daily database (default=daily.cvd)],
AC_DEFINE_UNQUOTED(DB2NAME,"$withval",[Name of the daily database]), AC_DEFINE(DB2NAME, "daily.cvd",[Name of the daily database]))

dnl I had problems with $pkgdatadir thus these funny checks
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)

dnl configure config directory
cfg_dir=`echo $sysconfdir | grep prefix`

if test -n "$cfg_dir"; then
    if test "$prefix" = "NONE"
    then
	cfg_dir="$ac_default_prefix/etc"
    else
	cfg_dir="$prefix/etc"
    fi
else
    cfg_dir="$sysconfdir"
fi

CFGDIR=$cfg_dir
AC_SUBST(CFGDIR)
AC_DEFINE_UNQUOTED(CONFDIR,"$cfg_dir",[where to look for the config file])

dnl check for in_port_t definition
AC_TRY_RUN([
#include <sys/types.h>
#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))

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))

case "$target_os" in
linux*)
    AC_DEFINE(C_LINUX,1,[target is linux])
    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])
	CLAMD_LIBS="$CLAMD_LIBS -lpthread"
	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread"
	if test "$want_clamuko" = "yes"; then
	    AC_DEFINE(CLAMUKO,1,[enable clamuko])
	fi
	CLAMSCAN_LIBS="$CLAMSCAN_LIBS -lpthread"
    fi
    case `uname -r` in
    1.*|2.0.*)
       AC_DEFINE(INCOMPLETE_CMSG,1,[Early Linux doesn't set cmsg fields])
       ;;
    esac
    ;;
cygwin*)
    AC_DEFINE(C_CYGWIN,1,[os is cygwin])
    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
    ;;
solaris*)
    FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lresolv"
    if test "$have_pthreads" = "yes"; then
	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread"
	CLAMD_LIBS="$CLAMD_LIBS -lpthread -lresolv"
	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread -lresolv"
	TH_SAFE="-thread-safe"
	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
	AC_DEFINE(_REENTRANT,1,[thread safe])
    fi
    AC_DEFINE(C_SOLARIS,1,[os is solaris])
    ;;
freebsd*)
    if test "$have_pthreads" = "yes"; then
	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -pthread -lc_r"
	CLAMD_LIBS="$CLAMD_LIBS -pthread -lc_r"
	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread -lc_r"
	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 freebsd])
    disable_gethostbyname_r="yes"
    ;;
openbsd*)
    if test "$have_pthreads" = "yes"; then
	LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -pthread"
	if test "$disable_cr" = "yes"; then
	    CLAMD_LIBS="$CLAMD_LIBS -pthread"
	    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread"
	else
	    CLAMD_LIBS="$CLAMD_LIBS -pthread -lc_r"
	    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread -lc_r"
	fi
	TH_SAFE="-thread-safe"
	AC_DEFINE(CL_THREAD_SAFE,1,[thread safe])
	AC_DEFINE(_REENTRANT,1,[thread safe])
    fi
    AC_DEFINE(C_BSD,1,[os is OpenBSD])
    disable_gethostbyname_r="yes"
    ;;
bsdi*)
    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])
    fi
    AC_DEFINE(C_BSD,1,[os is BSDI BSD/OS])
    disable_gethostbyname_r="yes"
    ;;
netbsd*)
     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])
	ADDITIONAL_LIBS="$LIBS -lpthread"
     fi
    AC_DEFINE(C_BSD,1,[os is NetBSD])
    disable_gethostbyname_r="yes"
    ;;
bsd*)
    AC_MSG_RESULT(Unknown BSD detected. Disabling thread support.)
    have_pthreads="no"
    AC_DEFINE(C_BSD,1,[os is bsd flavor])
    disable_gethostbyname_r="yes"
    ;;
beos*)
    AC_MSG_RESULT(BeOS detected. Disabling thread support.)
    have_pthreads="no"
    AC_DEFINE(C_BEOS,1,[os is beos])
    ;;
darwin*)
    AC_DEFINE(C_BSD,1,[os is bsd flavor])
    AC_DEFINE(C_DARWIN,1,[os is darwin])
    AC_DEFINE(BIND_8_COMPAT,1,[enable bind8 compatibility])
    use_netinfo="yes"
    disable_gethostbyname_r="yes"
    ;;
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])
    ;;
sco*)
    dnl njh@bandsman.sco.uk: SCO Unix port
    dnl FRESHCLAM_LIBS="-lsocket"
    dnl CLAMD_LIBS="-lsocket"
    dnl CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsocket"
    ;;
hpux*)
    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_HPUX,1,[os is hpux])
    ;;
aix*)
    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_AIX,1,[os is aix])
    ;;
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])
    ;;
irix*)
    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_IRIX,1,[os is irix])
    ;;
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
    ;;
*)
    ;;
esac

AC_SUBST(LIBCLAMAV_LIBS)
AC_SUBST(CLAMD_LIBS)
AC_SUBST(CLAMAV_MILTER_LIBS)
AC_SUBST(FRESHCLAM_LIBS)
AC_SUBST(TH_SAFE)
AC_SUBST(ADDITIONAL_LIBS)

dnl --enable-milter
if test "$have_milter" = "yes"; then
    dnl libmilter checking code adapted from spamass-milter by
    dnl Tom G. Christensen <tgc@statsbiblioteket.dk>

    dnl Check for libmilter and it's header files in the usual locations
    save_LDFLAGS="$LDFLAGS"
    if test -d /usr/lib/libmilter ; then
	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -L/usr/lib/libmilter"
    fi
    LDFLAGS="$LDFLAGS -lmilter $CLAMAV_MILTER_LIBS"
    AC_CHECK_LIB(milter, mi_stop,[CLAMAV_MILTER_LIBS="-lmilter $CLAMAV_MILTER_LIBS"],[
	dnl Older sendmails require libsm or libsmutil for support functions
	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
	AC_CHECK_LIB(milter, mi_stop,[CLAMAV_MILTER_LIBS="-lmilter $CLAMAV_MILTER_XLIB $CLAMAV_MILTER_LIBS"],[
	    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

AM_CONDITIONAL(BUILD_CLAMD, test "$have_pthreads" = "yes")
AM_CONDITIONAL(HAVE_MILTER, test "$have_milter" = "yes")

if test "$have_pthreads" = "yes"
then
    AC_DEFINE(BUILD_CLAMD, 1, "build clamd")
fi

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

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

dnl tcpwrappers support
dnl 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

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

AC_ARG_ENABLE(gethostbyname_r,
[  --disable-gethostbyname_r	  disable support for gethostbyname_r],
disable_gethostbyname_r="yes", )

if test "$disable_gethostbyname_r" = "yes"; then
    AC_MSG_RESULT(support disabled)
elif test -z "$ac_cv_gethostbyname_args"; then
    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

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,
[  --enable-readdir_r		    enable support for readdir_r],,
disable_readdir_r="yes")

if test "$disable_readdir_r" = "yes"; then
    AC_MSG_RESULT(support disabled)
elif test -z "$ac_cv_readdir_args"; then
    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

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

dnl Check for clamav in /etc/passwd
if test "$test_clamav" = "yes"
then
    dnl parse /etc/passwd
    if test "$use_id" = "no"
    then
	AC_MSG_CHECKING(for $clamav_user in /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_CHECKING(for $clamav_user using id)
	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
	AC_MSG_CHECKING(for $clamav_user using netinfo)
        clamavuser=`/usr/bin/nidump passwd . |grep ${clamav_user}`
        clamavgroup=`/usr/bin/nidump group . |grep ${clamav_group}`
    fi

    if test "$use_yp" = "yes"
    then
	AC_MSG_CHECKING(for $clamav_user using ypmatch)
        clamavuser=`ypmatch ${clamav_user} passwd`
        clamavgroup=`ypmatch ${clamav_group} group`
    fi

    if test -z "$clamavuser" || test -z "$clamavgroup"
    then
	AC_MSG_RESULT(no)
	AC_MSG_ERROR(User $clamav_user (and/or group $clamav_group) doesn't exist. Please read the documentation !)
    else
	AC_MSG_RESULT([yes, user $clamav_user and group $clamav_group])
        CLAMAVUSER="$clamav_user"
        CLAMAVGROUP="$clamav_group"
        AC_SUBST(CLAMAVUSER)
        AC_SUBST(CLAMAVGROUP)
    fi
fi

AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN
if test $ac_cv_c_bigendian = yes; then
  AC_DEFINE(WORDS_BIGENDIAN,1,endianess)
else
  AC_DEFINE(WORDS_BIGENDIAN,0,endianess)
fi

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,[
		AC_TRY_RUN([int main(int argc, char **argv) {
#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)
	AC_DEFINE(HAVE_PRAGMA_PACK, 1, "pragma pack")
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
	AC_DEFINE(HAVE_ATTRIB_PACKED, 1, "attrib packed")
fi

dnl 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

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")

AC_OUTPUT([
libclamav/Makefile
clamscan/Makefile
database/Makefile
docs/Makefile
clamd/Makefile
clamdscan/Makefile
clamav-milter/Makefile
freshclam/Makefile
sigtool/Makefile
etc/Makefile
Makefile
clamav-config
libclamav.pc
docs/man/clamd.8
docs/man/clamd.conf.5
docs/man/freshclam.1
docs/man/freshclam.conf.5
])