File: configure.in

package info (click to toggle)
libclamunrar 0.96.4-1
  • links: PTS
  • area: non-free
  • in suites: squeeze
  • size: 3,548 kB
  • ctags: 791
  • sloc: sh: 10,678; ansic: 4,951; makefile: 98
file content (1689 lines) | stat: -rw-r--r-- 51,217 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
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
dnl   Copyright (C) 2002 - 2006 Tomasz Kojm <tkojm@clamav.net>
dnl   readdir_r checks (c) COPYRIGHT MIT 1995
dnl   socklen_t check (c) Alexander V. Lukyanov <lav@yars.free.net>
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., 51 Franklin Street, Fifth Floor, Boston,
dnl   MA 02110-1301, USA.

AC_PREREQ([2.59])
dnl For a release change [devel] to the real version [0.xy]
dnl also change VERSION below
AC_INIT([ClamAV], [0.96.4], [http://bugs.clamav.net/], [clamav], [http://www.clamav.net/])

AH_BOTTOM([#include "platform.h"])
dnl put configure auxiliary into config
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_HEADER([clamav-config.h])

dnl safety check, this used to be a parameter to AC_INIT
AC_CONFIG_SRCDIR([libclamunrar_iface/unrar_iface.c])
AC_CONFIG_MACRO_DIR([m4])
AC_CREATE_TARGET_H([target.h])

dnl -Wall and -Werror here are NOT CFLAGS, they refer to automake warnings
dnl enable stealth builds and psychedelic tests
AM_INIT_AUTOMAKE([1.11 -Wall -Wportability -Wno-override -Werror std-options foreign dist-bzip2 no-define color-tests parallel-tests tar-ustar])
AM_SILENT_RULES([yes])

dnl we told automake to not define these, since we want to include
dnl the date in the version
AC_DEFINE([PACKAGE], PACKAGE_NAME, [Name of package])

dnl change this on a release
VERSION="0.96.4"
AC_DEFINE_UNQUOTED([VERSION],"$VERSION",[Version number of package])

LC_CURRENT=7
LC_REVISION=6
LC_AGE=1
LIBCLAMAV_VERSION="$LC_CURRENT":"$LC_REVISION":"$LC_AGE"
AC_SUBST([LIBCLAMAV_VERSION])

AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

LT_INIT([dlopen disable-static])

major=`expr $LC_CURRENT - $LC_AGE`
AC_DEFINE_UNQUOTED([LIBCLAMAV_FULLVER], "$major.$LC_AGE.$LC_REVISION",
	  ["Full library version number"])
AC_DEFINE_UNQUOTED([LIBCLAMAV_MAJORVER], $major,
	  ["Major library version number"])
AC_DEFINE([SCANBUFF], 131072, [scan buffer size])
AC_DEFINE([FILEBUFF], 8192,   [file i/o buffer size])

AC_LIB_MULTILIB_GUESS

AC_HEADER_STDC
AC_C_RESTRICT
AC_C_CONST
AC_C_INLINE
AC_C_FPU_BIGENDIAN
AC_C_BIGENDIAN

LT_LIB_M

AC_ARG_ENABLE([gcc-vcheck],
[  --disable-gcc-vcheck	  do not check for buggy gcc version ],
gcc_check=$enableval, gcc_check="yes")

msg_gcc_check="use --disable-gcc-vcheck to disable this check. Before reporting any bugs check with a supported version of gcc"
VERSION_SUFFIX=
dnl Check for gcc-4.1.0
if test "$gcc_check" = "yes"; then
	if test "x$ac_compiler_gnu" = "xyes"; then
		AC_MSG_CHECKING([for a supported version of gcc])
		gcc_version=`${CC} -dumpversion`
		case "${gcc_version}" in
			4.1.0*)
				AC_MSG_RESULT([no (${gcc_version})])
				AC_MSG_ERROR([gcc 4.1.0 is known to incorrectly compile upx.c. Upgrade your compiler to at least 4.1.1/4.1.2)])
				;;
			*)
				AC_MSG_RESULT([ok (${gcc_version})])
				;;
		esac
		case "${gcc_version}" in
		    [[56789]].* | 4.[[3456789]].*)
			# bb #1581 - temporarely add -fno-strict-aliasing so gcc 4.4.0
			# works correctly
			CFLAGS="$CFLAGS -fno-strict-aliasing"
			;;
		    *)
			;;
		esac
	fi
else
	CFLAGS="$CFLAGS -O0"
	VERSION_SUFFIX="$VERSION_SUFFIX-broken-compiler"
fi

# add distcheck warning flags
distcheck_enable_flags=0
if test "x$ac_compiler_gnu" = "xyes"; then
	gcc_version=`${CC} -dumpversion`
	case "${gcc_version}" in
		4.[[3456789]].*)
			distcheck_enable_flags=1
			;;
		[[56789]].*)
			distcheck_enable_flags=1
			;;
	esac
fi

dnl Checks if compiler produces valid code, regardless of compiler
dnl we do these checks here to avoid receiving endless bugreports about
dnl breakages due to compiler bugs.

dnl Check if compiler produces invalid code on gcc PR27603 (affects upx.c)
dnl testcase from gcc testsuite
AC_MSG_CHECKING([for gcc bug PR27603])
AC_TRY_RUN(
	   [
/* (C) Richard Guenther */	   
void exit (int);
void abort (void);
int a;
int main(void)
{
  int j;
  for (j = 0; j < 6; j++)
  {
    if ((unsigned)j - 3 <= 1)
      exit (0);
    a = 1000 * (6 - j);
  }
  abort ();
}
], [AC_MSG_RESULT([ok, bug not present])],
[AC_MSG_ERROR([your compiler has gcc PR27603 bug, use a different compiler, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27603])], [AC_MSG_RESULT([cross-compiling, assumed ok])])

dnl Check if compiler produces invalid code on gcc PR26763-2 (affects upx.c)
dnl testcase from gcc testsuite
AC_MSG_CHECKING([for gcc bug PR26763-2])
AC_TRY_RUN(
	   [
/* (C) Richard Guenther */	   
extern void abort(void);

static int try (char *a, int d)
{
  return a + d > a;
}

int main(void)
{
  char bla[100];

  if (try (bla + 50, -1))
    abort ();

  return 0;
}
], [AC_MSG_RESULT([ok, bug not present])],
[AC_MSG_ERROR([your compiler has gcc PR26763-2 bug, use a different compiler, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26763])],[AC_MSG_RESULT([cross-compiling, assumed ok])])

dnl Check if compiler produces invalid code on own testcase based on upx.c
AC_MSG_CHECKING([for valid code generation of CLI_ISCONTAINED])
AC_TRY_RUN(
	   [
#include <stdio.h>
static struct v{
	char* dst;
	unsigned int dsize;
	unsigned int dcur;
	unsigned int backsize;
	signed int unp_offset;
} values[] = {
	{(char*)0xf78ab008, 0x2e000, 1, 4, -1594},
	{(char*)0xb7af1008, 0x2e000, 1, 4, -1594}

};
extern void abort(void);

#define CLI_ISCONTAINED(bb, bb_size, sb, sb_size)	\
  ((bb_size) > 0 && (sb_size) > 0 && (size_t)(sb_size) <= (size_t)(bb_size) \
   && (sb) >= (bb) && ((sb) + (sb_size)) <= ((bb) + (bb_size)) && ((sb) + (sb_size)) > (bb) && (sb) < ((bb) + (bb_size)))

int crashtest()
{
	unsigned int backsize, dcur;
	int dval=0x12000, unp_offset;
	int* dsize = &dval;
	char* dst = (char*)0x12000;
	while(1) {
		backsize=4;
		dcur=0;
		unp_offset=0x800002c7;

		if (!CLI_ISCONTAINED(dst, *dsize, dst+dcur+unp_offset, backsize) || !CLI_ISCONTAINED(dst, *dsize, dst+dcur, backsize) || unp_offset >=0)
			return -1;
		abort();
	}
	return 0;
}

int main(void)
{
	int i;
	for(i=0;i<sizeof(values)/sizeof(values[0]);i++) {
		struct v* v= &values[i];
		char* dst = v->dst;
		unsigned int* dsize = &v->dsize;
		unsigned int dcur = v->dcur;
		unsigned int backsize = v->backsize-1;
		signed int  unp_offset = v->unp_offset;

		if(!CLI_ISCONTAINED(dst, *dsize, dst+dcur+unp_offset, backsize) ||
				!CLI_ISCONTAINED(dst, *dsize,dst+dcur,backsize) || unp_offset >= 0)  {
			continue;
		}
		abort();
	}
	crashtest();
	return 0;
}
], [AC_MSG_RESULT([ok, bug not present])],
[AC_MSG_ERROR([your compiler has a bug that causes clamav bug no. 670, use a different compiler, see http://bugs.clamav.net/bugzilla/show_bug.cgi?id=670])], [AC_MSG_RESULT([cross-compiling, assumed ok])])

dnl Check if compiler produces invalid code on gcc PR28045 (affects upx.c)
dnl testcase from gcc testsuite
AC_MSG_CHECKING([for gcc bug PR28045])
AC_TRY_RUN(
	   [
/* (C) Andrew Pinski */
extern void abort(void);
struct a
{
   unsigned int bits : 1;
   signed long val : ((sizeof(long) * 8) - 1);
};
static int Fnegate (struct a b)
{
  if ((-((long)b.val)) <= ((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))
      && (-((long)b.val)) >= (-(((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))) - 1))
     return 0 ;
  abort ();
}
int main (void)
{
  struct a b = {1, 1};
  Fnegate (b);
  return 0;
}
], [AC_MSG_RESULT([ok, bug not present])],
[AC_MSG_ERROR([your compiler has gcc PR28045 bug, use a different compiler, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28045])], [AC_MSG_RESULT([cross-compiling, assumed ok])])

dnl Check if compiler produces invalid code on gcc PR37573 (affects autoit.c)
dnl this is a bug in gcc 4.4.0, but for some reason it affects gcc 4.1.2 too
dnl gcc 4.1.3 is OK. This bug occurs only at -O3.
AC_MSG_CHECKING([for gcc bug PR37573])
AC_TRY_RUN(
	   [
#include <stdlib.h>
#include <string.h>
struct S
{
  unsigned int *a;
  unsigned int b;
  unsigned int c[624];
};
static unsigned char
foo (struct S *s)
{
  unsigned int r;
  if (!--s->b)
    {
      unsigned int *c = s->c;
      unsigned int i;
      s->a = c;
      for (i = 0; i < 227; i++)
	c[i] =
	  ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1) ^
	  ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i + 397];
      for (; i < 623; i++)
	c[i] =
	  ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1) ^
	  ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i - 227];
      c[623] =
	((((c[623] ^ c[0]) & 0x7ffffffe) ^ c[623]) >> 1) ^ ((0 - (c[0] & 1)) &
							    0x9908b0df) ^ c[i
									    -
									    227];
    }
  r = *(s->a++);
  r ^= (r >> 11);
  r ^= ((r & 0xff3a58ad) << 7);
  r ^= ((r & 0xffffdf8c) << 15);
  r ^= (r >> 18);
  return (unsigned char) (r >> 1);
}

void
bar (unsigned char *p, unsigned int q, unsigned int r)
{
  struct S s;
  unsigned int i;
  unsigned int *c = s.c;
  *c = r;
  for (i = 1; i < 624; i++)
    c[i] = i + 0x6c078965 * ((c[i - 1] >> 30) ^ c[i - 1]);
  s.b = 1;
  while (q--)
    *p++ ^= foo (&s);
};

static unsigned char p[23] = {
  0xc0, 0x49, 0x17, 0x32, 0x62, 0x1e, 0x2e, 0xd5, 0x4c, 0x19, 0x28, 0x49,
    0x91, 0xe4, 0x72, 0x83, 0x91, 0x3d, 0x93, 0x83, 0xb3, 0x61, 0x38
};

static unsigned char q[23] = {
  0x3e, 0x41, 0x55, 0x54, 0x4f, 0x49, 0x54, 0x20, 0x55, 0x4e, 0x49, 0x43,
    0x4f, 0x44, 0x45, 0x20, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x3c
};

int
main (void)
{
  unsigned int s;
  s = 23;
  bar (p, s, s + 0xa25e);
  if (memcmp (p, q, s) != 0)
	abort ();
  return 0;
}

], [AC_MSG_RESULT([ok, bug not present])],
[AC_MSG_ERROR([your compiler has gcc PR37573 bug, use a lower optimization level (-O1 or -O2), see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37573])], [AC_MSG_RESULT([cross-compiling, assumed ok])])

dnl Linker feature checks
dnl check for version script support in the linker (GNU ld, or Solaris ld style)
AC_CACHE_CHECK([for ld --version-script], [ac_cv_ld_version_script], [dnl
  cat > conftest.c <<EOF
void cl_symbol1(void) {}
void cli_symbol2(void) {}
EOF
  cat > conftest.map <<EOF
RELEASE
{
	global:
		cl_*;
	local:
		*;
};
PRIVATE
{
	global:
		cli_*;
	local:
		*;
};
EOF
  dnl check for GNU ld style linker version script
  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $pic_flag $LDFLAGS -shared
				-o conftest.so conftest.c
				-Wl,--version-script,conftest.map
		       1>&AS_MESSAGE_LOG_FD]);
  then
      VERSIONSCRIPTFLAG=--version-script
      ac_cv_ld_version_script=yes
  else
	dnl check for Solaris ld style linker version script
	if AC_TRY_COMMAND([${CC-cc} $CFLAGS $pic_flag $LDFLAGS -shared
				-o conftest.so conftest.c
				-Wl,-M,conftest.map
			1>&AS_MESSAGE_LOG_FD]);
	then
		VERSIONSCRIPTFLAG=-M
		ac_cv_ld_version_script=yes;
	else
		ac_cv_ld_version_script=no
	fi
  fi
 rm -f conftest*])
AC_SUBST([VERSIONSCRIPTFLAG])
AM_CONDITIONAL([VERSIONSCRIPT], test "x$ac_cv_ld_version_script" = "xyes")

# it is not fatal if gperf is missing
AM_MISSING_PROG(GPERF, gperf)
AC_SUBST(GPERF)

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 limits.h sys/filio.h sys/uio.h termios.h stdbool.h pwd.h grp.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_COMPILE_CHECK_SIZEOF([void *])

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])
  VERSION_SUFFIX="$VERSION_SUFFIX-exp"
fi

build_configure_args=`echo "$ac_configure_args" | sed -e 's/[\"]//g'`
AC_SUBST([BUILD_CONFIGURE_FLAGS], [$build_configure_args])

AX_CHECK_UNAME_SYSCALL
AC_CHECK_LIB([socket], [bind], [LIBS="$LIBS -lsocket"; CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsocket"; FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lsocket"; CLAMD_LIBS="$CLAMD_LIBS -lsocket"])
AC_SEARCH_LIBS([gethostent],[nsl], [(LIBS="$LIBS -lnsl"; CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lnsl"; FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lnsl"; CLAMD_LIBS="$CLAMD_LIBS -lnsl")])

AC_CHECK_FUNCS([poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat strcasestr inet_ntop setgroups initgroups ctime_r mkstemp mallinfo madvise])
AC_FUNC_FSEEKO

dnl Check if anon maps are available, check if we can determine the page size
AC_C_FUNC_MMAP_PRIVATE
AC_C_FUNC_PAGESIZE
AC_C_FUNC_MMAP_ANONYMOUS
AC_ARG_ENABLE([mempool],[  --disable-mempool       disable memory pools], enable_mempool=$enableval, enable_mempool="yes")
have_mempool="no"
if test "$enable_mempool" = "yes"; then
	if test "$ac_cv_c_mmap_private" != "yes"; then
		AC_MSG_NOTICE([****** mempool support disabled (mmap not available or not usable)])
	else
		if test "$ac_cv_c_can_get_pagesize" != "yes"; then
			AC_MSG_NOTICE([****** mempool support disabled (pagesize cannot be determined)])
		else
			if test "$ac_cv_c_mmap_anonymous" = "no"; then
				AC_MSG_NOTICE([****** mempool support disabled (anonymous mmap not available)])
			else
				AC_DEFINE([USE_MPOOL],1,[enable memory pools])
				have_mempool="yes"
			fi
		fi
	fi
fi

enable_check_ut=auto
enable_ut_install=no
AC_ARG_ENABLE(check,
[  --enable-check           Enable 'check' unit tests (default=auto)], enable_check_ut=$enableval, enable_check_ut="auto" )

if test "$enable_check_ut" != "no" ; then
	AC_LIB_FIND([check],[check.h],
			AC_LANG_PROGRAM([#include <check.h>],[srunner_create(0)]),
			[CHECK_CPPFLAGS="$INCCHECK"; CHECK_LIBS="$LTLIBCHECK"],
			[])
fi
AC_SUBST([CHECK_CPPFLAGS])
AC_SUBST([CHECK_LIBS])
AM_CONDITIONAL([HAVE_LIBCHECK],test "X$HAVE_LIBCHECK" = "Xyes")

if test "x$CHECK_LIBS" = "x" -a "$enable_check_ut" = "yes"; then
    AC_MSG_ERROR([

ERROR!  Check was configured, but not found.  Get it from http://check.sf.net/
])
fi

AC_ARG_ENABLE(coverage,
	      AC_HELP_STRING([--enable-coverage],
			     [turn on test coverage
			      @<:@default=no@:>@]),
[enable_cov=$enableval],[enable_cov="no"])

if test "x$enable_coverage" = "xyes"; then
	if test "x$CHECK_LIBS" = "x"; then
		AC_MSG_ERROR([Coverage testing required, but unit tests not enabled!])
	fi
	if test "x$ac_compiler_gnu" != "xyes"; then
		AC_MSG_ERROR([coverage testing only works if gcc is used])
	fi

	CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
	LDFLAGS="$LDFLAGS -lgcov"
	AC_CHECK_PROGS(GCOV, gcov, false)
	AC_CHECK_PROGS(LCOV, lcov, false)
	AC_CHECK_PROGS(GENHTML, genhtml, false)
fi

AM_CONDITIONAL(ENABLE_COVERAGE, test "x$enable_coverage" = "xyes")

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

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

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

    save_LIBS="$LIBS"
    if test "$ZLIB_HOME" != "/usr"; then
	CPPFLAGS="$CPPFLAGS -I$ZLIB_HOME/include"
	save_LDFLAGS="$LDFLAGS"
	LDFLAGS="$LDFLAGS -L$ZLIB_HOME/lib"
	AC_CHECK_LIB([z], [inflateEnd], [LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -L$ZLIB_HOME/lib -lz"; FRESHCLAM_LIBS="$FRESHCLAM_LIBS -L$ZLIB_HOME/lib -lz"], AC_MSG_ERROR([Please install zlib and zlib-devel packages]))
	AC_CHECK_LIB([z], [gzopen], [], AC_MSG_ERROR([Your zlib is missing gzopen()]))
	LDFLAGS="$save_LDFLAGS"
    else
	AC_CHECK_LIB([z], [inflateEnd], [LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lz";FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lz"], AC_MSG_ERROR([Please install zlib and zlib-devel packages]))
	AC_CHECK_LIB([z], [gzopen],[], AC_MSG_ERROR([Your zlib is missing gzopen()]))
    fi
    LIBS="$save_LIBS"
fi

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

bzip_check="ok"
if test "$want_bzip2" = "yes"
then
    AC_LIB_LINKFLAGS([bz2])
    save_LDFLAGS="$LDFLAGS"
    # Only add -L if prefix is not empty
    test -z "$LIBBZ2_PREFIX" || LDFLAGS="$LDFLAGS -L$LIBBZ2_PREFIX/$acl_libdirstem";

    have_bzprefix="no"
    AC_CHECK_LIB([bz2], [BZ2_bzReadOpen], [have_bzprefix="yes"])
    if test "x$have_bzprefix" = "xno"; then
        AC_DEFINE([NOBZ2PREFIX],1,[bzip funtions do not have bz2 prefix])
    fi
    LDFLAGS="$save_LDFLAGS"
    if test "$HAVE_LIBBZ2" = "yes"; then
	AC_CHECK_HEADER([bzlib.h],
			[AC_C_CVE_2008_1372],
			[ac_cv_c_cve_2008_1372="no"])
	if test "$ac_cv_c_cve_2008_1372" = "bugged"; then
		AC_MSG_WARN([****** bzip2 libraries are affected by the CVE-2008-1372 bug])
		AC_MSG_WARN([****** We strongly suggest you to update to bzip2 1.0.5.])
		AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
		bzip_check="bugged (CVE-2008-1372)"
	fi
	if test "$ac_cv_c_cve_2008_1372" = "linkfailed"; then
		dnl This shouldn't happen
		dnl We failed to link but libtool may still be able to link, so don't disable bzip2 just yet
		AC_MSG_WARN([****** Unable to link bzip2 testcase])
		AC_MSG_WARN([****** You may be affected by CVE-2008-1372 bug, but I need to be able to link a testcase to verify])
		AC_MSG_WARN([****** It is recommended to fix your build environment so that we can run the testcase!])
		AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
		bzip_check="link failed (CVE-2008-1372)"
	fi

	case "$ac_cv_c_cve_2008_1372" in
	ok|bugged|linkfailed)
		;;
	*)
		HAVE_LIBBZ2=no
		;;
	esac
    fi

    if test "$HAVE_LIBBZ2" = "yes"; then
	AC_C_CVE_2010_0405
	if test "$ac_cv_c_cve_2010_0405" = "bugged"; then
		AC_MSG_WARN([****** bzip2 libraries are affected by the CVE-2010-0405 bug])
		AC_MSG_WARN([****** We strongly suggest you to update bzip2])
		AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
		bzip_check="bugged (CVE-2010-0405)"
	fi
	if test "$ac_cv_c_cve_2010_0405" = "linkfailed"; then
		dnl This shouldn't happen
		dnl We failed to link but libtool may still be able to link, so don't disable bzip2 just yet
		AC_MSG_WARN([****** Unable to link bzip2 testcase])
		AC_MSG_WARN([****** You may be affected by CVE-2010-0405 bug, but I need to be able to link a testcase to verify])
		AC_MSG_WARN([****** It is recommended to fix your build environment so that we can run the testcase!])
		AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
		bzip_check="link failed (CVE-2010-0405)"
	fi

	case "$ac_cv_c_cve_2010_0405" in
	ok|bugged|linkfailed)
		LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS $LTLIBBZ2"
		AC_DEFINE([HAVE_BZLIB_H],1,[have bzip2])
		;;
	*)
		AC_MSG_WARN([****** bzip2 support disabled])
		;;
	esac

    else
	AC_MSG_WARN([****** bzip2 support disabled])
    fi
fi

AC_ARG_ENABLE([unrar],
[  --disable-unrar	  don't build libclamunrar and libclamunrar_iface ],
want_unrar=$enableval, want_unrar="yes")
AM_CONDITIONAL([ENABLE_UNRAR],[test "$want_unrar" = "yes"])

AC_ARG_ENABLE([getaddrinfo],
[  --disable-getaddrinfo          disable support for getaddrinfo],
want_getaddrinfo=$enableval, want_getaddrinfo="yes")

if test "$want_getaddrinfo" = "yes"
then
    AC_MSG_CHECKING([for getaddrinfo])
    AC_CACHE_VAL([have_cv_gai],[
		AC_TRY_RUN([
		    #include <sys/types.h>
		    #include <sys/socket.h>
		    #include <netdb.h>
		    #include <unistd.h>
		    int main(int argc, char **argv)
		    {
			    struct addrinfo *res;
			    int sd;

			if(getaddrinfo("127.0.0.1", NULL, NULL, &res) < 0)
			    return 1;
			freeaddrinfo(res);

			return 0;
		    }
		],
		[have_cv_gai=yes],
		[have_cv_gai=no],
		[have_cv_gai=no])
		])
    AC_MSG_RESULT([$have_cv_gai])
    if test "$have_cv_gai" = yes; then
	AC_DEFINE(HAVE_GETADDRINFO, 1, [have getaddrinfo()])
    fi
fi

AC_ARG_ENABLE([ipv6],
[  --disable-ipv6          disable IPv6 support],
want_ipv6=$enableval, want_ipv6="yes")

if test "$want_ipv6" = "yes"
then
    AC_MSG_CHECKING([for IPv6 support])
    AC_CACHE_VAL([have_cv_ipv6],[
		AC_TRY_RUN([
		    #include <sys/types.h>
		    #include <sys/socket.h>
		    #include <netdb.h>
		    #include <unistd.h>
		    int main(int argc, char **argv)
		    {
			    struct addrinfo *res, hints;
			    int sd;

			if((sd = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
			    return 1;
			close(sd);
			/* also check if getaddrinfo() handles AF_UNSPEC -- bb#1196 */
			memset(&hints, 0, sizeof(hints));
			hints.ai_family = AF_UNSPEC;
			if(getaddrinfo("127.0.0.1", NULL, &hints, &res) < 0)
			    return 1;
			freeaddrinfo(res);
			return 0;
		    }
		],
		[have_cv_ipv6=yes],
		[have_cv_ipv6=no],
		[have_cv_ipv6=no])
		])
    AC_MSG_RESULT([$have_cv_ipv6])
    if test "$have_cv_ipv6" = yes; then
	AC_DEFINE(SUPPORT_IPv6, 1, [Support for IPv6])
    fi
fi

AC_C_DNS

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

dnl AC_FUNC_SETPGRP does not work when cross compiling
dnl Instead, assume we will have a prototype for setpgrp if cross compiling.
dnl testcase from gdb/configure.ac
if test "$cross_compiling" = no; then
 AC_FUNC_SETPGRP
else
 AC_CACHE_CHECK([whether setpgrp takes no argument], [ac_cv_func_setpgrp_void],
   [AC_TRY_COMPILE([
#include <unistd.h>
], [
 if (setpgrp(1,1) == -1)
   exit (0);
 else
   exit (1);
], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes)])
if test $ac_cv_func_setpgrp_void = yes; then
 AC_DEFINE([SETPGRP_VOID], 1)
fi
fi

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

have_system_tommath=no
AC_ARG_WITH([system-tommath],
[  --with-system-tommath	link against system libtommath (default = no, use bundled)],
[
	case "$withval" in
	yes)
		AC_CHECK_LIB([tommath], [mp_mul_2d],
			[
				AC_DEFINE([HAVE_SYSTEM_TOMMATH], 1, [link against system-wide libtommath])
				LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -ltommath"
				have_system_tommath=yes
			],
			[AC_MSG_WARN([****** Option --with-system-tommath was given but libtommath does not seem to be available, using bundled files instead])]
		)
	;;
	no) ;;
	*) AC_MSG_ERROR([--with-system-tommath does not take an argument]) ;;
	esac
])
AM_CONDITIONAL([LINK_TOMMATH], test "x$have_system_tommath" = "xyes")


dnl we need to try to link with iconv, otherwise there could be a 
dnl mismatch between a 32-bit and 64-bit lib. Detect this at configure time.
dnl we need to check after zlib/bzip2, because they can change the include path
AC_ARG_WITH([iconv], [  --with-iconv supports iconv() (default=auto)],
[
 case "$withval" in
	 yes|no) wiconv="$withval";;
	 *) AC_MSG_ERROR([--with-iconv does not take an argument]);;
 esac],
[ wiconv=auto ])
if test "X$wiconv" != "Xno"; then
	AC_CHECK_LIB([iconv], [libiconv_open], LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -liconv")
	AC_MSG_CHECKING([for iconv])
	save_LIBS="$LIBS"
	LIBS="$LIBCLAMAV_LIBS"
	AC_TRY_LINK([
		     #include <iconv.h>
	],[
	char** xin,**xout;
	unsigned long il,ol;
	int rc;
	iconv_t iconv_struct = iconv_open("UTF-16BE","UTF-8");
	rc = iconv(iconv_struct,xin,&il,xout,&ol);
	iconv_close(iconv_struct);
],[
   AC_MSG_RESULT(yes)
   AC_DEFINE([HAVE_ICONV], 1, [iconv() available])
],[
	AC_MSG_RESULT(no)
])
	LIBS="$save_LIBS"
fi

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

AC_ARG_ENABLE([cr],
[  --disable-cr		  don't link with C reentrant library (BSD) ],
use_cr=$enableval,)

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

AC_ARG_ENABLE([yp-check],
[  --enable-yp-check	  use ypmatch utility instead of /etc/passwd parsing],
use_yp=$enableval, 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])

AC_ARG_ENABLE([clamav],
[  --disable-clamav	  disable test for clamav user/group],
test_clamav=$enableval, test_clamav=yes)

AC_ARG_ENABLE([debug],
[  --enable-debug	  enable debug code],
enable_debug=$enableval, enable_debug="no")

if test "$enable_debug" = "yes"; then
  VERSION_SUFFIX="$VERSION_SUFFIX-debug"
  AC_DEFINE([CL_DEBUG],1,[enable debugging])
else
  AC_DEFINE([NDEBUG],1,[disable assertions])
fi

AC_ARG_ENABLE([unsigned-bytecode],
[  --enable-unsigned-bytecode	  enable load of unsigned bytecode],
enable_unsignedbytecode="$enableval", enable_unsignedbytecode="no")

if test "$enable_unsignedbytecode" = "yes"; then
  VERSION_SUFFIX="$VERSION_SUFFIX-unsigned-bc"
  AC_DEFINE([CL_BCUNSIGNED],1,[enable loading of unsigned bytecode])
fi

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

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

AC_ARG_ENABLE([bigstack],
[  --enable-bigstack	  increase thread stack size],
enable_bigstack=$enableval, enable_bigstack="no")

if test "$enable_bigstack" = "yes"; then
  AC_DEFINE([C_BIGSTACK],1,[Increase thread stack size.])
fi

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

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_MSG_CHECKING([whether in_port_t is defined])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netinet/in.h>
],
[in_port_t pt; pt = 0; return pt;],
[
    AC_MSG_RESULT(yes)
    AC_DEFINE([HAVE_IN_PORT_T],1,[in_port_t is defined])
],
AC_MSG_RESULT(no))

dnl check for in_addr_t definition
AC_MSG_CHECKING([for in_addr_t definition])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netinet/in.h>
],
[ in_addr_t pt; pt = 0; return pt; ],
[
    AC_MSG_RESULT(yes)
    AC_DEFINE([HAVE_IN_ADDR_T],1,[in_addr_t is defined])
],
AC_MSG_RESULT(no))

case "$target_os" in
linux*)
    AC_DEFINE([C_LINUX],1,[target is linux])
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-lpthread"
	TH_SAFE="-thread-safe"
	if test "$want_clamuko" = "yes"; then
	    AC_DEFINE([CLAMUKO],1,[enable clamuko])
	fi
    fi
    ;;
kfreebsd*-gnu)
    AC_DEFINE([C_KFREEBSD_GNU],1,[target is kfreebsd-gnu])
    if test "$have_pthreads" = "yes"; then
       THREAD_LIBS="-lpthread"
       TH_SAFE="-thread-safe"
       if test "$want_clamuko" = "yes"; then
           AC_DEFINE([CLAMUKO],1,[enable clamuko])
       fi
    fi
    ;;
solaris*)
    FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lresolv"
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-lpthread"
	CLAMD_LIBS="$CLAMD_LIBS -lresolv"
	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lresolv"
	TH_SAFE="-thread-safe"
    fi
    AC_DEFINE([C_SOLARIS],1,[os is solaris])
    ;;
freebsd[[45]]*)
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-pthread -lc_r"
	TH_SAFE="-thread-safe"
	if test "$want_clamuko" = "yes"; then
	    AC_DEFINE([CLAMUKO],1,[enable clamuko])
	fi
    fi
    AC_DEFINE([C_BSD],1,[os is freebsd 4 or 5])
    ;;
freebsd*)
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-lthr"
	TH_SAFE="-thread-safe"
	if test "$want_clamuko" = "yes"; then
	    AC_DEFINE([CLAMUKO],1,[enable clamuko])
	fi
    fi
    AC_DEFINE([C_BSD],1,[os is freebsd 6])
    ;;
dragonfly*)
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-pthread"
	TH_SAFE="-thread-safe"
	if test "$want_clamuko" = "yes"; then
	    AC_DEFINE([CLAMUKO],1,[enable clamuko])
	fi
    fi
    AC_DEFINE([C_BSD],1,[os is dragonfly])
    ;;
openbsd*)
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-pthread"
	CLAMD_LIBS="$CLAMD_LIBS -pthread"
	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread"
	TH_SAFE="-thread-safe"
    fi
    AC_DEFINE([C_BSD],1,[os is OpenBSD])
    ;;
bsdi*)
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-pthread"
	TH_SAFE="-thread-safe"
    fi
    AC_DEFINE([C_BSD],1,[os is BSDI BSD/OS])
    ;;
netbsd*)
     if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-lpthread"
     fi
    AC_DEFINE([C_BSD],1,[os is NetBSD])
    ;;
bsd*)
    AC_MSG_RESULT([Unknown BSD detected. Disabling thread support.])
    have_pthreads="no"
    AC_DEFINE([C_BSD],1,[os is bsd flavor])
    ;;
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"
    ;;
os2*)
    FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lsyslog"
    CLAMD_LIBS="$CLAMD_LIBS -lsyslog"
    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsyslog"
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-lpthread"
	TH_SAFE="-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
	THREAD_LIBS="-lpthread"
	TH_SAFE="-thread-safe"
    fi
    AC_DEFINE([C_HPUX],1,[os is hpux])
    ;;
aix*)
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-lpthread"
	TH_SAFE="-thread-safe"
	AC_DEFINE([_THREAD_SAFE],1,[thread safe])
    fi
    AC_DEFINE([C_AIX],1,[os is aix])
    ;;
*-*-osf*)
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-pthread"
	TH_SAFE="-thread-safe"
	AC_DEFINE([_POSIX_PII_SOCKET],1,[POSIX compatibility])
    fi
    AC_DEFINE([C_OSF],1,[os is osf/tru64])
    ;;
nto-qnx*)
    AC_DEFINE([C_QNX6],1,[os is QNX 6.x.x])
    ;;
irix*)
    if test "$have_pthreads" = "yes"; then
	THREAD_LIBS="-lpthread"
	TH_SAFE="-thread-safe"
    fi
    LIBS="$LIBS -lgen"
    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
	THREAD_LIBS="-lpthread"
	TH_SAFE="-thread-safe"
    fi
    ;;
gnu*)
    AC_DEFINE([C_GNU_HURD],1,[target is gnu-hurd])
    if test "$have_pthreads" = "yes"; then
       THREAD_LIBS="-lpthread"
       TH_SAFE="-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([THREAD_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_LIBS="$LIBS"
    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread"
    if test -d /usr/lib/libmilter ; then
	CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -L/usr/lib/libmilter"
    fi
    LIBS="$LIBS -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"])
	LIBS="$save_LIBS $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])
	])
    ])
    LIBS="$save_LIBS"
    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
    save_LIBS="$LIBS"
    LIBS="$THREAD_LIBS $LIBS"
    AC_CHECK_FUNCS([sched_yield pthread_yield])
    LIBS="$save_LIBS"
    AC_DEFINE([BUILD_CLAMD], 1, "build clamd")
    dnl define these here, so we don't forget any system
    AC_DEFINE([CL_THREAD_SAFE],1,[thread safe])
    AC_DEFINE([_REENTRANT],1,[thread safe])
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],
enable_readdir_r=$enableval, enable_readdir_r="no")

if test "$enable_readdir_r" = "no"; 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 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

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
	if test -x /usr/bin/dscl; then
	    AC_MSG_CHECKING([for $clamav_user using dscl])
	    clamavuser=`/usr/bin/dscl . -list /Users |grep ${clamav_user}`
	    clamavgroup=`/usr/bin/dscl . -list /Groups |grep ${clamav_group}`
	else
	    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
    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

dnl check for __attribute__((packed))
dnl but only on compilers claiming to be gcc compatible
dnl because for example Sun's compiler silently ignores the packed attribute.
AC_MSG_CHECKING([for structure packing via __attribute__((packed))])
AC_CACHE_VAL([have_cv_attrib_packed],[
	AC_TRY_COMPILE(,
		[#ifdef __GNUC__
		 struct { int i __attribute__((packed)); } s;
		 #else
		 #error Only checking for packed attribute on gcc-like compilers
		 #endif],
		[have_cv_attrib_packed=yes],
		[have_cv_attrib_packed=no])
	])
AC_MSG_RESULT([$have_cv_attrib_packed])

if test "$have_cv_attrib_packed" = no; then
	AC_MSG_CHECKING([for structure packing via pragma])
	AC_CACHE_VAL([have_cv_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_cv_pragma_pack=yes],
			[have_cv_pragma_pack=no])
		])
	AC_MSG_RESULT([$have_cv_pragma_pack])
	if test "$have_cv_pragma_pack" = yes; then
		AC_DEFINE([HAVE_PRAGMA_PACK], 1, "pragma pack")
	else
		AC_MSG_CHECKING([for structure packing via hppa/hp-ux pragma])
		AC_CACHE_VAL([have_cv_pragma_pack_hpux],[
			AC_TRY_RUN([
			/* hppa/hp-ux wants pragma outside of function */
#pragma pack 1 /* has to be in column 1 ! */
			struct { char c; long l; } s;
			    int main(int argc, char **argv) {
			return sizeof(s)==sizeof(s.c)+sizeof(s.l) ? 0:1; } ],
			[have_cv_pragma_pack_hpux=yes],
			[have_cv_pragma_pack_hpux=no])
		])
		AC_MSG_RESULT([$have_cv_pragma_pack_hpux])
		AC_DEFINE([HAVE_PRAGMA_PACK_HPPA], 1, "pragma pack hppa/hp-ux style")
	fi
fi

dnl check for __attribute__((aligned))
AC_MSG_CHECKING([for type aligning via __attribute__((aligned))])
AC_CACHE_VAL([have_cv_attrib_aligned],[
	AC_TRY_COMPILE(,
		[typedef int cl_aligned_int __attribute__((aligned));],
		[have_cv_attrib_aligned=yes],
		[have_cv_attrib_aligned=no])
	])
AC_MSG_RESULT([$have_cv_attrib_aligned])

if test "$have_cv_attrib_packed" = no -a "$have_cv_pragma_pack" = no -a "$have_cv_pragma_pack_hpux" = no; then
	AC_MSG_ERROR(Need to know how to pack structures with this compiler)
fi

if test "$have_cv_attrib_packed" = yes; then
	AC_DEFINE([HAVE_ATTRIB_PACKED], 1, [attrib packed])
fi

if test "$have_cv_attrib_aligned" = yes; then
	AC_DEFINE([HAVE_ATTRIB_ALIGNED], 1, [attrib aligned])
fi

dnl Sanity check that struct packing works
AC_MSG_CHECKING([that structure packing works])
AC_CACHE_VAL([have_cv_struct_pack],[
    AC_TRY_RUN([
#ifndef HAVE_ATTRIB_PACKED
#define __attribute__(x)
#endif
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1) /* has to be in column 1 ! */
#endif
#ifdef HAVE_PRAGMA_PACK_HPPA
#pragma pack 1 /* has to be in column 1 ! */
#endif

struct { char c __attribute__((packed)); long l __attribute__((packed)); } s;

#ifdef HAVE_PRAGMA_PACK
#pragma pack()
#endif
#ifdef HAVE_PRAGMA_PACK_HPPA
#pragma pack
#endif

struct { char c; long l;} s2;

#ifdef HAVE_PRAGMA_PACK
#pragma pack(1) /* has to be in column 1 ! */
#endif
#ifdef HAVE_PRAGMA_PACK_HPPA
#pragma pack 1 /* has to be in column 1 ! */
#endif

struct { char c; long l; } __attribute__((packed)) s3;

#ifdef HAVE_PRAGMA_PACK
#pragma pack()
#endif
#ifdef HAVE_PRAGMA_PACK_HPPA
#pragma pack
#endif

    int main(int argc, char **argv) {
        if (sizeof(s)!=sizeof(s.c)+sizeof(s.l))
	    return 1;
	if (sizeof(s) != sizeof(s3))
	    return 2;
	return (sizeof(s2) >= sizeof(s)) ? 0 : 3;
    }],
    [have_cv_struct_pack=yes],
    [have_cv_struct_pack=no],
    [have_cv_struct_pack=yes])
])
AC_MSG_RESULT([$have_cv_struct_pack])

if test "$have_cv_struct_pack" = "no"; then
    AC_MSG_ERROR([Structure packing seems to be available, but is not working with this compiler])
fi

dnl Check if <sys/select.h> needs to be included for fd_set
AC_MSG_CHECKING([for fd_set])
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_TRY_COMPILE([#include <sys/time.h>
			#include <sys/types.h>
			#ifdef HAVE_UNISTD_H
			#include <unistd.h>
			#endif],
		[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_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>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <errno.h>
int main(void) {
        FILE *fp = fopen("conftestval", "w");
	if(fp) {
		if(fprintf (fp, "%d\n", FD_SETSIZE) < 1)  {
			perror("fprintf failed");
			return errno;
		}
	} else {
		perror("fopen failed");
		return errno;
	}
        return 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")

dnl Check signed right shift implementation
AC_MSG_CHECKING([whether signed right shift is sign extended])
AC_TRY_RUN([int main(void){int a=-1;int b=a>>1;return(a!=b);}],
    [have_signed_rightshift_extended=yes],
    [have_signed_rightshift_extended=no],
    [have_signed_rightshift_extended=no])
if test $have_signed_rightshift_extended = yes; then
    AC_DEFINE([HAVE_SAR], 1, [Define signed right shift implementation])
fi
AC_MSG_RESULT([$have_signed_rightshift_extended]);

AC_C_FDPASSING

AC_DEFINE_UNQUOTED([VERSION_SUFFIX],"$VERSION_SUFFIX",[Version suffix for package])

AC_ARG_ENABLE(clamdtop,
	      AC_HELP_STRING([--enable-clamdtop],
			     [Enable 'clamdtop' tool @<:@default=auto@:>@]),
[enable_clamdtop=$enableval], [enable_clamdtop="auto"])

if test "$enable_clamdtop" != "no"; then

AC_LIB_FIND([ncurses], [ncurses/ncurses.h],
	    AC_LANG_PROGRAM([#include <ncurses/ncurses.h>],
			    [initscr(); KEY_RESIZE;]),
	    [CURSES_CPPFLAGS="$INCNCURSES"; CURSES_LIBS="$LTLIBNCURSES";
	     CURSES_INCLUDE="<ncurses/ncurses.h>"],
	    [])

if test "X$HAVE_LIBNCURSES" != "Xyes"; then
    HAVE_LIBNCURSES=
    AC_LIB_FIND([ncurses], [ncurses.h],
	    AC_LANG_PROGRAM([#include <ncurses.h>],
			    [initscr(); KEY_RESIZE;]),
	    [CURSES_CPPFLAGS="$INCNCURSES"; CURSES_LIBS="$LTLIBNCURSES";
	     CURSES_INCLUDE="<ncurses.h>"],
	    [])
fi

if test "X$HAVE_LIBNCURSES" != "Xyes"; then
    AC_LIB_FIND([pdcurses],[curses.h],
			    AC_LANG_PROGRAM([#include <curses.h>],
					    [initscr(); KEY_RESIZE;]),
			    [CURSES_CPPFLAGS="$INCPDCURSES";
			     CURSES_LIBS="$LTLIBPDCURSES";
			     CURSES_INCLUDE="<curses.h>"],
			    [AC_MSG_WARN([****** not building clamdtop: ncurses not found])])
fi

if test "x$CURSES_LIBS" = "x" -a "$enable_clamdtop" = "yes"; then
    AC_MSG_ERROR([

ERROR!  Clamdtop was configured, but not found.  You need to install libncurses5-dev.
])
fi

fi

AC_DEFINE_UNQUOTED([CURSES_INCLUDE], $CURSES_INCLUDE, [curses header location])
AC_SUBST([CURSES_CPPFLAGS])
AC_SUBST([CURSES_LIBS])
AM_CONDITIONAL([HAVE_CURSES],
	       [test "X$HAVE_LIBNCURSES" = "Xyes" || test "X$HAVE_LIBPDCURSES" = "Xyes"])

AC_ARG_ENABLE([distcheck-werror],
	      AC_HELP_STRING([--enable-distcheck-werror],
			     [enable warnings as error for distcheck
			      @<:@default=no@:>@]),
[enable_distcheckwerror=$enableval],[enable_distcheckwerror="no"])

# Enable distcheck warnings and Werror only for gcc versions that support them,
# and only after we've run the configure tests.
# Some configure tests fail (like checking for cos in -lm) if we enable these
# Werror flags for configure too (for example -Wstrict-prototypes makes
# configure think that -lm doesn't have cos, hence its in libc).
if test "x$enable_distcheckwerror" = "xyes"; then
    if test "$distcheck_enable_flags" = "1"; then
	CFLAGS="$CFLAGS -Wno-pointer-sign -Werror-implicit-function-declaration -Werror -Wextra -Wall -Wno-error=bad-function-cast -Wbad-function-cast -Wcast-align -Wendif-labels -Wfloat-equal -Wformat=2 -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wno-error=missing-prototypes -Wnested-externs -Wno-error=nested-externs -Wpointer-arith -Wstrict-prototypes -Wno-error=strict-prototypes -Wno-switch -Wno-switch-enum -Wundef -Wwrite-strings -Wstrict-overflow=1 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wdeclaration-after-statement -Waggregate-return -Wmissing-format-attribute -Wno-error=missing-format-attribute -Wno-error=type-limits -Wno-error=unused-function -Wno-error=unused-value -Wno-error=unused-variable -Wcast-qual -Wno-error=cast-qual -Wno-error=sign-compare -Wshadow -Wno-error=shadow -Wno-error=uninitialized -fdiagnostics-show-option -Wno-unused-parameter -Wno-error=unreachable-code -Winvalid-pch -Wno-error=invalid-pch -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector -Wno-error=aggregate-return"
    fi
fi

AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm],
				    [Enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
				    [enable_llvm=$enableval], [enable_llvm="auto"])

if test "$enable_llvm" != "no"; then
    dnl Try to configure subdir, optionally
    AC_CONFIG_SUBDIRS_OPTIONAL([libclamav/c++])
fi

AC_ARG_ENABLE([sha-collector-for-internal-use], [], [enable_sha_collector="yes"], [enable_sha_collector="no"])
if test "$enable_sha_collector" != "no"; then
    AC_DEFINE([HAVE__INTERNAL__SHA_COLLECT], 1, [For internal use only - DO NOT DEFINE])
fi
AM_CONDITIONAL([BUILD_SHA1],[test "$enable_sha_collector" != "no"])

AC_OUTPUT([
libclamunrar_iface/Makefile
Makefile
platform.h
])

if test "$enable_llvm" = "yes" && test "$subdirfailed" != "no"; then
    AC_MSG_ERROR([Failed to configure LLVM, and LLVM was explicitly requested])
fi
AM_CONDITIONAL([ENABLE_LLVM],
	       [test "$subdirfailed" != "yes" && test "$enable_llvm" != "no"])
no_recursion="yes";

cat <<EOF
              OS          : $target_os
              pthreads    : $have_pthreads ($THREAD_LIBS)
EOF

AC_MSG_NOTICE([Summary of miscellaneous  features])
if test "x$CHECK_LIBS" = "x"; then
    check_libs="no"
else
    check_libs="$CHECK_LIBS"
fi
CL_MSG_STATUS([check       ],[$check_libs],[$enable_check_ut])
CL_MSG_STATUS([clamuko     ],[$want_clamuko],[$want_clamuko])
if test "x$ac_cv_have_control_in_msghdr" = "xyes"; then
    CL_MSG_STATUS([fdpassing   ],[$have_fdpass],[$want_fdpassing])
else
    CL_MSG_STATUS([fdpassing   ],[n/a],[])
fi
CL_MSG_STATUS([IPv6        ],[$have_cv_ipv6],[$want_ipv6])

AC_MSG_NOTICE([Summary of optional tools])
CL_MSG_STATUS([clamdtop    ],[$CURSES_LIBS],[$enable_clamdtop])
CL_MSG_STATUS([milter      ],[yes],[$have_milter])

AC_MSG_NOTICE([Summary of engine performance features)])
if test "x$enable_debug" = "xyes"; then
    CL_MSG_STATUS([release mode],[no],[debug build])
else
    CL_MSG_STATUS([release mode],[yes],[yes])
fi
have_jit="no"
if test "$subdirfailed" = "no"; then
    have_jit="yes"
fi
CL_MSG_STATUS([jit         ],[$have_jit],[$enable_llvm])
CL_MSG_STATUS([mempool     ],[$have_mempool],[$enable_mempool])

AC_MSG_NOTICE([Summary of engine detection features])
CL_MSG_STATUS([autoit_ea06 ],[$have_autoitea06],[])
CL_MSG_STATUS([bzip2       ],[$bzip_check],[$want_bzip2])
CL_MSG_STATUS([zlib        ],[$ZLIB_HOME],[yes])
CL_MSG_STATUS([unrar       ],[$want_unrar],[$want_unrar])

# Yep, downgrading the compiler avoids the bug too:
# 4.0.x, and 4.1.0 are the known buggy versions
# 3.4 doesn't have the bug
if test "x$gcc_check" != "xyes"; then
	AC_MSG_WARN([
****** Optimizations disabled to avoid compiler bugs
****** The resulting binaries will be slow!
****** It is recommended to either upgrade or downgrade your compiler
])
fi

if test "x$cross_compiling" != "xno" || test "x$gcc_check" != "xyes" || test "x$zlib_check" = "xno" || test "x$bzip_check" != "xok" ; then
AC_MSG_WARN([
****** WARNING:
****** You are cross compiling to a different host or you are
****** linking to bugged system libraries or you have manually
****** disabled important configure checks.
****** Please be aware that this build may be badly broken.
****** DO NOT REPORT BUGS BASED ON THIS BUILD !!!
])
fi