~ubuntu-branches/ubuntu/wily/clamav/wily-proposed

« back to all changes in this revision

Viewing changes to .pc/0005-configure.ac-patches-to-got-with-autoreconf-and-auto.patch/configure.ac

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-03-15 12:47:13 UTC
  • mfrom: (0.35.39 sid)
  • Revision ID: package-import@ubuntu.com-20140315124713-xqgr3h376zqnw9yb
Tags: 0.98.1+dfsg-3ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Drop build-dep on electric-fence (in Universe)
  - Add apparmor profiles for clamd and freshclam along with maintainer
    script changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl   Copyright (C) 2002 - 2006 Tomasz Kojm <tkojm@clamav.net>
 
2
dnl   readdir_r checks (c) COPYRIGHT MIT 1995
 
3
dnl   socklen_t check (c) Alexander V. Lukyanov <lav@yars.free.net>
 
4
dnl
 
5
dnl   This program is free software; you can redistribute it and/or modify
 
6
dnl   it under the terms of the GNU General Public License as published by
 
7
dnl   the Free Software Foundation; either version 2 of the License, or
 
8
dnl   (at your option) any later version.
 
9
dnl
 
10
dnl   This program is distributed in the hope that it will be useful,
 
11
dnl   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
dnl   GNU General Public License for more details.
 
14
dnl
 
15
dnl   You should have received a copy of the GNU General Public License
 
16
dnl   along with this program; if not, write to the Free Software
 
17
dnl   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
18
dnl   MA 02110-1301, USA.
 
19
 
 
20
AC_PREREQ([2.59])
 
21
dnl For a release change [devel] to the real version [0.xy]
 
22
dnl also change VERSION below
 
23
AC_INIT([ClamAV], [0.98.1], [http://bugs.clamav.net/], [clamav], [http://www.clamav.net/])
 
24
 
 
25
AH_BOTTOM([#include "platform.h"])
 
26
dnl put configure auxiliary into config
 
27
AC_CONFIG_AUX_DIR([config])
 
28
AC_CONFIG_HEADER([clamav-config.h])
 
29
 
 
30
dnl safety check, this used to be a parameter to AC_INIT
 
31
AC_CONFIG_SRCDIR([clamscan/clamscan.c])
 
32
AC_CONFIG_MACRO_DIR([m4])
 
33
AC_CREATE_TARGET_H([target.h])
 
34
 
 
35
dnl -Wall and -Werror here are NOT CFLAGS, they refer to automake warnings
 
36
dnl enable stealth builds and psychedelic tests
 
37
AM_INIT_AUTOMAKE([1.11 -Wall -Wportability -Wno-override -Werror std-options foreign dist-bzip2 no-define color-tests parallel-tests tar-ustar])
 
38
AM_SILENT_RULES([yes])
 
39
 
 
40
dnl we told automake to not define these, since we want to include
 
41
dnl the date in the version
 
42
AC_DEFINE([PACKAGE], PACKAGE_NAME, [Name of package])
 
43
 
 
44
dnl change this on a release
 
45
dnl VERSION="devel-`date +%Y%m%d`"
 
46
VERSION="0.98.1"
 
47
 
 
48
LC_CURRENT=7
 
49
LC_REVISION=20
 
50
LC_AGE=1
 
51
LIBCLAMAV_VERSION="$LC_CURRENT":"$LC_REVISION":"$LC_AGE"
 
52
AC_SUBST([LIBCLAMAV_VERSION])
 
53
 
 
54
AC_PROG_AWK
 
55
AC_PROG_INSTALL
 
56
AC_PROG_LN_S
 
57
AC_PROG_MAKE_SET
 
58
 
 
59
LT_CONFIG_LTDL_DIR([libltdl])
 
60
LT_INIT([dlopen disable-static])
 
61
LTDL_INIT([recursive])
 
62
AC_CONFIG_FILES([libltdl/Makefile])
 
63
 
 
64
major=`expr $LC_CURRENT - $LC_AGE`
 
65
AC_DEFINE_UNQUOTED([LIBCLAMAV_FULLVER], "$major.$LC_AGE.$LC_REVISION",
 
66
          ["Full library version number"])
 
67
AC_DEFINE_UNQUOTED([LIBCLAMAV_MAJORVER], $major,
 
68
          ["Major library version number"])
 
69
AC_DEFINE([SCANBUFF], 131072, [scan buffer size])
 
70
AC_DEFINE([FILEBUFF], 8192,   [file i/o buffer size])
 
71
 
 
72
AC_LIB_MULTILIB_GUESS
 
73
 
 
74
AC_HEADER_STDC
 
75
AC_C_RESTRICT
 
76
AC_C_CONST
 
77
AC_C_INLINE
 
78
AC_C_FPU_BIGENDIAN
 
79
AC_C_BIGENDIAN
 
80
 
 
81
LT_LIB_M
 
82
 
 
83
AC_ARG_ENABLE([gcc-vcheck],
 
84
[  --disable-gcc-vcheck   do not check for buggy gcc version ],
 
85
gcc_check=$enableval, gcc_check="yes")
 
86
 
 
87
msg_gcc_check="use --disable-gcc-vcheck to disable this check. Before reporting any bugs check with a supported version of gcc"
 
88
VERSION_SUFFIX=
 
89
dnl Check for gcc-4.1.0
 
90
if test "$gcc_check" = "yes"; then
 
91
        if test "x$ac_compiler_gnu" = "xyes"; then
 
92
                AC_MSG_CHECKING([for a supported version of gcc])
 
93
                gcc_version=`${CC} -dumpversion`
 
94
                case "${gcc_version}" in
 
95
                        4.1.0*)
 
96
                                AC_MSG_RESULT([no (${gcc_version})])
 
97
                                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)])
 
98
                                ;;
 
99
                        *)
 
100
                                AC_MSG_RESULT([ok (${gcc_version})])
 
101
                                ;;
 
102
                esac
 
103
                case "${gcc_version}" in
 
104
                    [[56789]].* | 4.[[3456789]].*)
 
105
                        # bb #1581 - temporarely add -fno-strict-aliasing so gcc 4.4.0
 
106
                        # works correctly
 
107
                        CFLAGS="$CFLAGS -fno-strict-aliasing"
 
108
                        ;;
 
109
                    *)
 
110
                        ;;
 
111
                esac
 
112
        fi
 
113
else
 
114
        CFLAGS="$CFLAGS -O0"
 
115
        VERSION_SUFFIX="$VERSION_SUFFIX-broken-compiler"
 
116
fi
 
117
 
 
118
# add distcheck warning flags
 
119
distcheck_enable_flags=0
 
120
if test "x$ac_compiler_gnu" = "xyes"; then
 
121
        gcc_version=`${CC} -dumpversion`
 
122
        case "${gcc_version}" in
 
123
                4.[[3456789]]*)
 
124
                        distcheck_enable_flags=1
 
125
                        ;;
 
126
                [[56789]].*)
 
127
                        distcheck_enable_flags=1
 
128
                        ;;
 
129
        esac
 
130
fi
 
131
 
 
132
dnl Checks if compiler produces valid code, regardless of compiler
 
133
dnl we do these checks here to avoid receiving endless bugreports about
 
134
dnl breakages due to compiler bugs.
 
135
 
 
136
dnl Check if compiler produces invalid code on gcc PR27603 (affects upx.c)
 
137
dnl testcase from gcc testsuite
 
138
AC_MSG_CHECKING([for gcc bug PR27603])
 
139
AC_TRY_RUN(
 
140
           [
 
141
/* (C) Richard Guenther */         
 
142
void exit (int);
 
143
void abort (void);
 
144
int a;
 
145
int main(void)
 
146
{
 
147
  int j;
 
148
  for (j = 0; j < 6; j++)
 
149
  {
 
150
    if ((unsigned)j - 3 <= 1)
 
151
      exit (0);
 
152
    a = 1000 * (6 - j);
 
153
  }
 
154
  abort ();
 
155
}
 
156
], [AC_MSG_RESULT([ok, bug not present])],
 
157
[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])])
 
158
 
 
159
dnl Check if compiler produces invalid code on gcc PR26763-2 (affects upx.c)
 
160
dnl testcase from gcc testsuite
 
161
AC_MSG_CHECKING([for gcc bug PR26763-2])
 
162
AC_TRY_RUN(
 
163
           [
 
164
/* (C) Richard Guenther */         
 
165
extern void abort(void);
 
166
 
 
167
static int try (char *a, int d)
 
168
{
 
169
  return a + d > a;
 
170
}
 
171
 
 
172
int main(void)
 
173
{
 
174
  char bla[100];
 
175
 
 
176
  if (try (bla + 50, -1))
 
177
    abort ();
 
178
 
 
179
  return 0;
 
180
}
 
181
], [AC_MSG_RESULT([ok, bug not present])],
 
182
[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])])
 
183
 
 
184
dnl Check if compiler produces invalid code on own testcase based on upx.c
 
185
AC_MSG_CHECKING([for valid code generation of CLI_ISCONTAINED])
 
186
AC_TRY_RUN(
 
187
           [
 
188
#include <stdio.h>
 
189
static struct v{
 
190
        char* dst;
 
191
        unsigned int dsize;
 
192
        unsigned int dcur;
 
193
        unsigned int backsize;
 
194
        signed int unp_offset;
 
195
} values[] = {
 
196
        {(char*)0xf78ab008, 0x2e000, 1, 4, -1594},
 
197
        {(char*)0xb7af1008, 0x2e000, 1, 4, -1594}
 
198
 
 
199
};
 
200
extern void abort(void);
 
201
 
 
202
#define CLI_ISCONTAINED(bb, bb_size, sb, sb_size)       \
 
203
  ((bb_size) > 0 && (sb_size) > 0 && (size_t)(sb_size) <= (size_t)(bb_size) \
 
204
   && (sb) >= (bb) && ((sb) + (sb_size)) <= ((bb) + (bb_size)) && ((sb) + (sb_size)) > (bb) && (sb) < ((bb) + (bb_size)))
 
205
 
 
206
int crashtest()
 
207
{
 
208
        unsigned int backsize, dcur;
 
209
        int dval=0x12000, unp_offset;
 
210
        int* dsize = &dval;
 
211
        char* dst = (char*)0x12000;
 
212
        while(1) {
 
213
                backsize=4;
 
214
                dcur=0;
 
215
                unp_offset=0x800002c7;
 
216
 
 
217
                if (!CLI_ISCONTAINED(dst, *dsize, dst+dcur+unp_offset, backsize) || !CLI_ISCONTAINED(dst, *dsize, dst+dcur, backsize) || unp_offset >=0)
 
218
                        return -1;
 
219
                abort();
 
220
        }
 
221
        return 0;
 
222
}
 
223
 
 
224
int main(void)
 
225
{
 
226
        int i;
 
227
        for(i=0;i<sizeof(values)/sizeof(values[0]);i++) {
 
228
                struct v* v= &values[i];
 
229
                char* dst = v->dst;
 
230
                unsigned int* dsize = &v->dsize;
 
231
                unsigned int dcur = v->dcur;
 
232
                unsigned int backsize = v->backsize-1;
 
233
                signed int  unp_offset = v->unp_offset;
 
234
 
 
235
                if(!CLI_ISCONTAINED(dst, *dsize, dst+dcur+unp_offset, backsize) ||
 
236
                                !CLI_ISCONTAINED(dst, *dsize,dst+dcur,backsize) || unp_offset >= 0)  {
 
237
                        continue;
 
238
                }
 
239
                abort();
 
240
        }
 
241
        crashtest();
 
242
        return 0;
 
243
}
 
244
], [AC_MSG_RESULT([ok, bug not present])],
 
245
[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])])
 
246
 
 
247
dnl Check if compiler produces invalid code on gcc PR28045 (affects upx.c)
 
248
dnl testcase from gcc testsuite
 
249
AC_MSG_CHECKING([for gcc bug PR28045])
 
250
AC_TRY_RUN(
 
251
           [
 
252
/* (C) Andrew Pinski */
 
253
extern void abort(void);
 
254
struct a
 
255
{
 
256
   unsigned int bits : 1;
 
257
   signed long val : ((sizeof(long) * 8) - 1);
 
258
};
 
259
static int Fnegate (struct a b)
 
260
{
 
261
  if ((-((long)b.val)) <= ((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))
 
262
      && (-((long)b.val)) >= (-(((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))) - 1))
 
263
     return 0 ;
 
264
  abort ();
 
265
}
 
266
int main (void)
 
267
{
 
268
  struct a b = {1, 1};
 
269
  Fnegate (b);
 
270
  return 0;
 
271
}
 
272
], [AC_MSG_RESULT([ok, bug not present])],
 
273
[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])])
 
274
 
 
275
dnl Check if compiler produces invalid code on gcc PR37573 (affects autoit.c)
 
276
dnl this is a bug in gcc 4.4.0, but for some reason it affects gcc 4.1.2 too
 
277
dnl gcc 4.1.3 is OK. This bug occurs only at -O3.
 
278
AC_MSG_CHECKING([for gcc bug PR37573])
 
279
AC_TRY_RUN(
 
280
           [
 
281
#include <stdlib.h>
 
282
#include <string.h>
 
283
struct S
 
284
{
 
285
  unsigned int *a;
 
286
  unsigned int b;
 
287
  unsigned int c[624];
 
288
};
 
289
static unsigned char
 
290
foo (struct S *s)
 
291
{
 
292
  unsigned int r;
 
293
  if (!--s->b)
 
294
    {
 
295
      unsigned int *c = s->c;
 
296
      unsigned int i;
 
297
      s->a = c;
 
298
      for (i = 0; i < 227; i++)
 
299
        c[i] =
 
300
          ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1) ^
 
301
          ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i + 397];
 
302
      for (; i < 623; i++)
 
303
        c[i] =
 
304
          ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1) ^
 
305
          ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i - 227];
 
306
      c[623] =
 
307
        ((((c[623] ^ c[0]) & 0x7ffffffe) ^ c[623]) >> 1) ^ ((0 - (c[0] & 1)) &
 
308
                                                            0x9908b0df) ^ c[i
 
309
                                                                            -
 
310
                                                                            227];
 
311
    }
 
312
  r = *(s->a++);
 
313
  r ^= (r >> 11);
 
314
  r ^= ((r & 0xff3a58ad) << 7);
 
315
  r ^= ((r & 0xffffdf8c) << 15);
 
316
  r ^= (r >> 18);
 
317
  return (unsigned char) (r >> 1);
 
318
}
 
319
 
 
320
void
 
321
bar (unsigned char *p, unsigned int q, unsigned int r)
 
322
{
 
323
  struct S s;
 
324
  unsigned int i;
 
325
  unsigned int *c = s.c;
 
326
  *c = r;
 
327
  for (i = 1; i < 624; i++)
 
328
    c[i] = i + 0x6c078965 * ((c[i - 1] >> 30) ^ c[i - 1]);
 
329
  s.b = 1;
 
330
  while (q--)
 
331
    *p++ ^= foo (&s);
 
332
};
 
333
 
 
334
static unsigned char p[23] = {
 
335
  0xc0, 0x49, 0x17, 0x32, 0x62, 0x1e, 0x2e, 0xd5, 0x4c, 0x19, 0x28, 0x49,
 
336
    0x91, 0xe4, 0x72, 0x83, 0x91, 0x3d, 0x93, 0x83, 0xb3, 0x61, 0x38
 
337
};
 
338
 
 
339
static unsigned char q[23] = {
 
340
  0x3e, 0x41, 0x55, 0x54, 0x4f, 0x49, 0x54, 0x20, 0x55, 0x4e, 0x49, 0x43,
 
341
    0x4f, 0x44, 0x45, 0x20, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x3c
 
342
};
 
343
 
 
344
int
 
345
main (void)
 
346
{
 
347
  unsigned int s;
 
348
  s = 23;
 
349
  bar (p, s, s + 0xa25e);
 
350
  if (memcmp (p, q, s) != 0)
 
351
        abort ();
 
352
  return 0;
 
353
}
 
354
 
 
355
], [AC_MSG_RESULT([ok, bug not present])],
 
356
[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])])
 
357
 
 
358
dnl Linker feature checks
 
359
dnl check for version script support in the linker (GNU ld, or Solaris ld style)
 
360
AC_CACHE_CHECK([for ld --version-script], [ac_cv_ld_version_script], [dnl
 
361
  cat > conftest.c <<EOF
 
362
void cl_symbol1(void) {}
 
363
void cli_symbol2(void) {}
 
364
EOF
 
365
  cat > conftest.map <<EOF
 
366
RELEASE
 
367
{
 
368
        global:
 
369
                cl_*;
 
370
        local:
 
371
                *;
 
372
};
 
373
PRIVATE
 
374
{
 
375
        global:
 
376
                cli_*;
 
377
        local:
 
378
                *;
 
379
};
 
380
EOF
 
381
  dnl check for GNU ld style linker version script
 
382
  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $pic_flag $LDFLAGS -shared
 
383
                                -o conftest.so conftest.c
 
384
                                -Wl,--version-script,conftest.map
 
385
                       1>&AS_MESSAGE_LOG_FD]);
 
386
  then
 
387
      VERSIONSCRIPTFLAG=--version-script
 
388
      ac_cv_ld_version_script=yes
 
389
  else
 
390
        dnl check for Solaris ld style linker version script
 
391
        if AC_TRY_COMMAND([${CC-cc} $CFLAGS $pic_flag $LDFLAGS -shared
 
392
                                -o conftest.so conftest.c
 
393
                                -Wl,-M,conftest.map
 
394
                        1>&AS_MESSAGE_LOG_FD]);
 
395
        then
 
396
                VERSIONSCRIPTFLAG=-M
 
397
                ac_cv_ld_version_script=yes;
 
398
        else
 
399
                ac_cv_ld_version_script=no
 
400
        fi
 
401
  fi
 
402
 rm -f conftest*])
 
403
AC_SUBST([VERSIONSCRIPTFLAG])
 
404
AM_CONDITIONAL([VERSIONSCRIPT], test "x$ac_cv_ld_version_script" = "xyes")
 
405
 
 
406
# it is not fatal if gperf is missing
 
407
AM_MISSING_PROG(GPERF, gperf)
 
408
AC_SUBST(GPERF)
 
409
 
 
410
AC_CHECK_HEADERS([stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h sys/times.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])
 
411
AC_CHECK_HEADER([syslog.h],AC_DEFINE([USE_SYSLOG],1,[use syslog]),)
 
412
 
 
413
AC_TYPE_OFF_T
 
414
AC_COMPILE_CHECK_SIZEOF([short])
 
415
AC_COMPILE_CHECK_SIZEOF([int])
 
416
AC_COMPILE_CHECK_SIZEOF([long])
 
417
AC_COMPILE_CHECK_SIZEOF([long long])
 
418
AC_COMPILE_CHECK_SIZEOF([void *])
 
419
 
 
420
AC_ARG_ENABLE([experimental],
 
421
[  --enable-experimental        enable experimental code],
 
422
enable_experimental=$enableval, enable_experimental="no")
 
423
 
 
424
if test "$enable_experimental" = "yes"; then
 
425
  AC_DEFINE([CL_EXPERIMENTAL],1,[enable experimental code])
 
426
  VERSION_SUFFIX="$VERSION_SUFFIX-exp"
 
427
fi
 
428
 
 
429
build_configure_args=`echo "$ac_configure_args" | sed -e 's/[\"]//g'`
 
430
AC_SUBST([BUILD_CONFIGURE_FLAGS], [$build_configure_args])
 
431
 
 
432
AX_CHECK_UNAME_SYSCALL
 
433
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"])
 
434
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")])
 
435
 
 
436
AC_CHECK_FUNCS([poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat strcasestr inet_ntop setgroups initgroups ctime_r mkstemp mallinfo madvise])
 
437
AC_FUNC_FSEEKO
 
438
 
 
439
dnl Check if anon maps are available, check if we can determine the page size
 
440
AC_C_FUNC_MMAP_PRIVATE
 
441
AC_C_FUNC_PAGESIZE
 
442
AC_C_FUNC_MMAP_ANONYMOUS
 
443
AC_ARG_ENABLE([mempool],[  --disable-mempool       disable memory pools], enable_mempool=$enableval, enable_mempool="yes")
 
444
have_mempool="no"
 
445
if test "$enable_mempool" = "yes"; then
 
446
        if test "$ac_cv_c_mmap_private" != "yes"; then
 
447
                AC_MSG_NOTICE([****** mempool support disabled (mmap not available or not usable)])
 
448
        else
 
449
                if test "$ac_cv_c_can_get_pagesize" != "yes"; then
 
450
                        AC_MSG_NOTICE([****** mempool support disabled (pagesize cannot be determined)])
 
451
                else
 
452
                        if test "$ac_cv_c_mmap_anonymous" = "no"; then
 
453
                                AC_MSG_NOTICE([****** mempool support disabled (anonymous mmap not available)])
 
454
                        else
 
455
                                AC_DEFINE([USE_MPOOL],1,[enable memory pools])
 
456
                                have_mempool="yes"
 
457
                        fi
 
458
                fi
 
459
        fi
 
460
fi
 
461
 
 
462
enable_check_ut=auto
 
463
enable_ut_install=no
 
464
AC_ARG_ENABLE(check,
 
465
[  --enable-check           Enable 'check' unit tests (default=auto)], enable_check_ut=$enableval, enable_check_ut="auto" )
 
466
 
 
467
if test "$enable_check_ut" = "auto" ; then
 
468
        PKG_CHECK_EXISTS([check], [enable_check_ut="yes"],
 
469
                         [enable_check_ut="no"])
 
470
fi
 
471
 
 
472
if test "$enable_check_ut" = "yes" ; then
 
473
        PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
 
474
fi
 
475
AM_CONDITIONAL([HAVE_LIBCHECK],test "X$CHECK_LIBS" != "X")
 
476
 
 
477
AC_ARG_ENABLE(coverage,
 
478
              AC_HELP_STRING([--enable-coverage],
 
479
                             [turn on test coverage
 
480
                              @<:@default=no@:>@]),
 
481
[enable_cov=$enableval],[enable_cov="no"])
 
482
 
 
483
if test "x$enable_coverage" = "xyes"; then
 
484
        if test "x$CHECK_LIBS" = "x"; then
 
485
                AC_MSG_ERROR([Coverage testing required, but unit tests not enabled!])
 
486
        fi
 
487
        if test "x$ac_compiler_gnu" != "xyes"; then
 
488
                AC_MSG_ERROR([coverage testing only works if gcc is used])
 
489
        fi
 
490
 
 
491
        CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
 
492
        LDFLAGS="$LDFLAGS -lgcov"
 
493
        AC_CHECK_PROGS(GCOV, gcov, false)
 
494
        AC_CHECK_PROGS(LCOV, lcov, false)
 
495
        AC_CHECK_PROGS(GENHTML, genhtml, false)
 
496
fi
 
497
 
 
498
AM_CONDITIONAL(ENABLE_COVERAGE, test "x$enable_coverage" = "xyes")
 
499
 
 
500
have_pthreads=no
 
501
AC_CHECK_HEADER([pthread.h],[have_pthreads=yes],)
 
502
 
 
503
AM_MAINTAINER_MODE
 
504
dnl Check for zlib
 
505
AC_MSG_CHECKING([for zlib installation])
 
506
AC_ARG_WITH([zlib],
 
507
[  --with-zlib=DIR        path to directory containing zlib library (default=
 
508
                          /usr/local or /usr if not found in /usr/local)],
 
509
[
 
510
if test "$withval"; then
 
511
  ZLIB_HOME="$withval"
 
512
  AC_MSG_RESULT([using $ZLIB_HOME])
 
513
fi
 
514
], [
 
515
ZLIB_HOME=/usr/local
 
516
if test ! -f "$ZLIB_HOME/include/zlib.h"
 
517
then
 
518
  ZLIB_HOME=/usr
 
519
fi
 
520
AC_MSG_RESULT([$ZLIB_HOME])
 
521
])
 
522
 
 
523
CLAMDSCAN_LIBS="$FRESHCLAM_LIBS"
 
524
 
 
525
AC_ARG_ENABLE([zlib-vcheck],
 
526
[  --disable-zlib-vcheck          do not check for buggy zlib version ],
 
527
zlib_check=$enableval, zlib_check="yes")
 
528
 
 
529
if test ! -f "$ZLIB_HOME/include/zlib.h"
 
530
then
 
531
    AC_MSG_ERROR([Please install zlib and zlib-devel packages])
 
532
else
 
533
 
 
534
    vuln=`grep "ZLIB_VERSION \"1.2.0" $ZLIB_HOME/include/zlib.h`
 
535
    if test -z "$vuln"; then
 
536
        vuln=`grep "ZLIB_VERSION \"1.2.1" $ZLIB_HOME/include/zlib.h`
 
537
    fi
 
538
 
 
539
    if test -n "$vuln"; then
 
540
        if test "$zlib_check" = "yes"; then
 
541
            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!)
 
542
        else
 
543
            AC_MSG_WARN([****** This ClamAV installation may be linked against])
 
544
            AC_MSG_WARN([****** a broken zlib version. Please DO NOT report any])
 
545
            AC_MSG_WARN([****** stability problems to the ClamAV developers!])
 
546
        fi
 
547
    fi
 
548
 
 
549
    save_LIBS="$LIBS"
 
550
    if test "$ZLIB_HOME" != "/usr"; then
 
551
        CPPFLAGS="$CPPFLAGS -I$ZLIB_HOME/include"
 
552
        save_LDFLAGS="$LDFLAGS"
 
553
        LDFLAGS="$LDFLAGS -L$ZLIB_HOME/lib"
 
554
        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]))
 
555
        AC_CHECK_LIB([z], [gzopen], [], AC_MSG_ERROR([Your zlib is missing gzopen()]))
 
556
        LDFLAGS="$save_LDFLAGS"
 
557
    else
 
558
        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]))
 
559
        AC_CHECK_LIB([z], [gzopen],[], AC_MSG_ERROR([Your zlib is missing gzopen()]))
 
560
    fi
 
561
    LIBS="$save_LIBS"
 
562
fi
 
563
 
 
564
AC_ARG_ENABLE([bzip2],
 
565
[  --disable-bzip2        disable bzip2 support],
 
566
want_bzip2=$enableval, want_bzip2="yes")
 
567
 
 
568
bzip_check="ok"
 
569
if test "$want_bzip2" = "yes"
 
570
then
 
571
    AC_LIB_LINKFLAGS([bz2])
 
572
    save_LDFLAGS="$LDFLAGS"
 
573
    # Only add -L if prefix is not empty
 
574
    test -z "$LIBBZ2_PREFIX" || LDFLAGS="$LDFLAGS -L$LIBBZ2_PREFIX/$acl_libdirstem";
 
575
 
 
576
    have_bzprefix="no"
 
577
    AC_CHECK_LIB([bz2], [BZ2_bzDecompressInit], [have_bzprefix="yes"])
 
578
    if test "x$have_bzprefix" = "xno"; then
 
579
        AC_DEFINE([NOBZ2PREFIX],1,[bzip funtions do not have bz2 prefix])
 
580
    fi
 
581
    LDFLAGS="$save_LDFLAGS"
 
582
    if test "$HAVE_LIBBZ2" = "yes"; then
 
583
        AC_CHECK_HEADER([bzlib.h],
 
584
                        [AC_C_CVE_2008_1372],
 
585
                        [ac_cv_c_cve_2008_1372="no"])
 
586
        if test "$ac_cv_c_cve_2008_1372" = "bugged"; then
 
587
                AC_MSG_WARN([****** bzip2 libraries are affected by the CVE-2008-1372 bug])
 
588
                AC_MSG_WARN([****** We strongly suggest you to update to bzip2 1.0.5.])
 
589
                AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
 
590
                bzip_check="bugged (CVE-2008-1372)"
 
591
        fi
 
592
        if test "$ac_cv_c_cve_2008_1372" = "linkfailed"; then
 
593
                dnl This shouldn't happen
 
594
                dnl We failed to link but libtool may still be able to link, so don't disable bzip2 just yet
 
595
                AC_MSG_WARN([****** Unable to link bzip2 testcase])
 
596
                AC_MSG_WARN([****** You may be affected by CVE-2008-1372 bug, but I need to be able to link a testcase to verify])
 
597
                AC_MSG_WARN([****** It is recommended to fix your build environment so that we can run the testcase!])
 
598
                AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
 
599
                bzip_check="link failed (CVE-2008-1372)"
 
600
        fi
 
601
 
 
602
        case "$ac_cv_c_cve_2008_1372" in
 
603
        ok|bugged|linkfailed)
 
604
                ;;
 
605
        *)
 
606
                HAVE_LIBBZ2=no
 
607
                ;;
 
608
        esac
 
609
    fi
 
610
 
 
611
    if test "$HAVE_LIBBZ2" = "yes"; then
 
612
        AC_C_CVE_2010_0405
 
613
        if test "$ac_cv_c_cve_2010_0405" = "bugged"; then
 
614
                AC_MSG_WARN([****** bzip2 libraries are affected by the CVE-2010-0405 bug])
 
615
                AC_MSG_WARN([****** We strongly suggest you to update bzip2])
 
616
                AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
 
617
                bzip_check="bugged (CVE-2010-0405)"
 
618
        fi
 
619
        if test "$ac_cv_c_cve_2010_0405" = "linkfailed"; then
 
620
                dnl This shouldn't happen
 
621
                dnl We failed to link but libtool may still be able to link, so don't disable bzip2 just yet
 
622
                AC_MSG_WARN([****** Unable to link bzip2 testcase])
 
623
                AC_MSG_WARN([****** You may be affected by CVE-2010-0405 bug, but I need to be able to link a testcase to verify])
 
624
                AC_MSG_WARN([****** It is recommended to fix your build environment so that we can run the testcase!])
 
625
                AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
 
626
                bzip_check="link failed (CVE-2010-0405)"
 
627
        fi
 
628
 
 
629
        case "$ac_cv_c_cve_2010_0405" in
 
630
        ok|bugged|linkfailed)
 
631
                LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS $LTLIBBZ2"
 
632
                AC_DEFINE([HAVE_BZLIB_H],1,[have bzip2])
 
633
                ;;
 
634
        *)
 
635
                AC_MSG_WARN([****** bzip2 support disabled])
 
636
                ;;
 
637
        esac
 
638
 
 
639
    else
 
640
        AC_MSG_WARN([****** bzip2 support disabled])
 
641
    fi
 
642
fi
 
643
 
 
644
AM_CONDITIONAL([HAVE_LIBBZ2], test "x$HAVE_LIBBZ2" = "xyes")
 
645
 
 
646
AC_ARG_ENABLE([unrar],
 
647
[  --disable-unrar        do not build libclamunrar and libclamunrar_iface ],
 
648
want_unrar=$enableval, want_unrar="yes")
 
649
AM_CONDITIONAL([ENABLE_UNRAR],[test "$want_unrar" = "yes"])
 
650
 
 
651
dnl libxml2
 
652
want_xml="auto"
 
653
AC_ARG_ENABLE([xml],
 
654
[  --disable-xml          disable DMG and XAR support],
 
655
want_xml=$enableval, want_xml="auto")
 
656
 
 
657
XML_HOME=""
 
658
if test "X$want_xml" != "Xno"; then
 
659
  AC_MSG_CHECKING([for libxml2 installation])
 
660
  AC_ARG_WITH([xml],
 
661
  [  --with-xml=DIR       path to directory containing libxml2 library (default=
 
662
                          /usr/local or /usr if not found in /usr/local)],
 
663
  [
 
664
  if test "$withval"
 
665
  then
 
666
    XML_HOME="$withval"
 
667
    AC_MSG_RESULT([using $XML_HOME])
 
668
  else
 
669
    AC_MSG_ERROR([cannot assign blank value to --with-xml])
 
670
  fi
 
671
  ], [
 
672
  XML_HOME=/usr/local
 
673
  if test ! -x "$XML_HOME/bin/xml2-config"
 
674
  then
 
675
    XML_HOME=/usr
 
676
    if test ! -x "$XML_HOME/bin/xml2-config"
 
677
    then
 
678
      XML_HOME=""
 
679
    fi
 
680
  fi
 
681
  if test "x$XML_HOME" != "x"; then
 
682
    AC_MSG_RESULT([$XML_HOME])
 
683
  else
 
684
    AC_MSG_RESULT([not found])
 
685
  fi
 
686
  ])
 
687
fi
 
688
 
 
689
found_xml="no"
 
690
XMLCONF_VERSION=""
 
691
XML_CPPFLAGS=""
 
692
XML_LIBS=""
 
693
if test "x$XML_HOME" != "x"; then
 
694
  AC_MSG_CHECKING([xml2-config version])
 
695
  XMLCONF_VERSION="`$XML_HOME/bin/xml2-config --version`"
 
696
  if test "x%XMLCONF_VERSION" != "x"; then
 
697
    AC_MSG_RESULT([$XMLCONF_VERSION])
 
698
    found_xml="yes"
 
699
    XML_CPPFLAGS="`$XML_HOME/bin/xml2-config --cflags`"
 
700
    XML_LIBS="`$XML_HOME/bin/xml2-config --libs`"
 
701
  else
 
702
    AC_MSG_ERROR([xml2-config failed])
 
703
  fi
 
704
fi
 
705
 
 
706
working_xml="no"
 
707
if test "X$found_xml" != "Xno"; then
 
708
  AC_MSG_CHECKING([for xmlreader.h in $XML_HOME])
 
709
 
 
710
  if test ! -f "$XML_HOME/include/libxml2/libxml/xmlreader.h"; then
 
711
    AC_MSG_RESULT([not found])
 
712
  else
 
713
    AC_MSG_RESULT([found])
 
714
    save_LIBS="$LIBS"
 
715
    save_CPPFLAGS="$CPPFLAGS"
 
716
    CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
 
717
    save_LDFLAGS="$LDFLAGS"
 
718
    LDFLAGS="$LDFLAGS $XML_LIBS"
 
719
 
 
720
    AC_CHECK_LIB([xml2], [xmlTextReaderRead], [working_xml="yes"], [working_xml="no"])
 
721
 
 
722
    CPPFLAGS="$save_CPPFLAGS"
 
723
    LDFLAGS="$save_LDFLAGS"
 
724
    LIBS="$save_LIBS"
 
725
  fi
 
726
fi
 
727
 
 
728
if test "$working_xml" = "yes"; then
 
729
  AC_DEFINE([HAVE_LIBXML2],1,[Define to 1 if you have the 'libxml2' library (-lxml2).])
 
730
  AC_SUBST(XML_CPPFLAGS)
 
731
  AC_SUBST(XML_LIBS)
 
732
  AC_MSG_NOTICE([Compiling and linking with libxml2 from $XML_HOME])
 
733
else
 
734
  if test "$want_xml" = "yes"; then
 
735
     AC_MSG_ERROR([****** Please install libxml2 packages!])
 
736
  else
 
737
    if test "$want_xml" != "no"; then
 
738
      AC_MSG_NOTICE([****** libxml2 support unavailable])
 
739
    fi
 
740
  fi
 
741
  XML_CPPFLAGS=""
 
742
  XML_LIBS=""
 
743
  AC_SUBST(XML_CPPFLAGS)
 
744
  AC_SUBST(XML_LIBS)
 
745
fi
 
746
 
 
747
AC_ARG_ENABLE([getaddrinfo],
 
748
[  --disable-getaddrinfo          disable support for getaddrinfo],
 
749
want_getaddrinfo=$enableval, want_getaddrinfo="yes")
 
750
 
 
751
if test "$want_getaddrinfo" = "yes"
 
752
then
 
753
    AC_MSG_CHECKING([for getaddrinfo])
 
754
    AC_CACHE_VAL([have_cv_gai],[
 
755
                AC_TRY_RUN([
 
756
                    #include <sys/types.h>
 
757
                    #include <sys/socket.h>
 
758
                    #include <netdb.h>
 
759
                    #include <unistd.h>
 
760
                    int main(int argc, char **argv)
 
761
                    {
 
762
                            struct addrinfo *res;
 
763
                            int sd;
 
764
 
 
765
                        if(getaddrinfo("127.0.0.1", NULL, NULL, &res) < 0)
 
766
                            return 1;
 
767
                        freeaddrinfo(res);
 
768
 
 
769
                        return 0;
 
770
                    }
 
771
                ],
 
772
                [have_cv_gai=yes],
 
773
                [have_cv_gai=no],
 
774
                [have_cv_gai=no])
 
775
                ])
 
776
    AC_MSG_RESULT([$have_cv_gai])
 
777
    if test "$have_cv_gai" = yes; then
 
778
        AC_DEFINE(HAVE_GETADDRINFO, 1, [have getaddrinfo()])
 
779
    fi
 
780
fi
 
781
 
 
782
AC_ARG_ENABLE([ipv6],
 
783
[  --disable-ipv6          disable IPv6 support],
 
784
want_ipv6=$enableval, want_ipv6="yes")
 
785
 
 
786
if test "$want_ipv6" = "yes"
 
787
then
 
788
    AC_MSG_CHECKING([for IPv6 support])
 
789
    AC_CACHE_VAL([have_cv_ipv6],[
 
790
                AC_TRY_RUN([
 
791
                    #include <sys/types.h>
 
792
                    #include <sys/socket.h>
 
793
                    #include <netdb.h>
 
794
                    #include <unistd.h>
 
795
                    int main(int argc, char **argv)
 
796
                    {
 
797
                            struct addrinfo *res, hints;
 
798
                            int sd;
 
799
 
 
800
                        if((sd = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
 
801
                            return 1;
 
802
                        close(sd);
 
803
                        /* also check if getaddrinfo() handles AF_UNSPEC -- bb#1196 */
 
804
                        memset(&hints, 0, sizeof(hints));
 
805
                        hints.ai_family = AF_UNSPEC;
 
806
                        if(getaddrinfo("127.0.0.1", NULL, &hints, &res) < 0)
 
807
                            return 1;
 
808
                        freeaddrinfo(res);
 
809
                        return 0;
 
810
                    }
 
811
                ],
 
812
                [have_cv_ipv6=yes],
 
813
                [have_cv_ipv6=no],
 
814
                [have_cv_ipv6=no])
 
815
                ])
 
816
    AC_MSG_RESULT([$have_cv_ipv6])
 
817
    if test "$have_cv_ipv6" = yes; then
 
818
        AC_DEFINE(SUPPORT_IPv6, 1, [Support for IPv6])
 
819
    fi
 
820
fi
 
821
 
 
822
AC_C_DNS
 
823
 
 
824
AC_ARG_ENABLE([fanotify],
 
825
[  --disable-fanotify     disable fanotify support (Linux only)],
 
826
want_fanotify=$enableval, want_fanotify="yes")
 
827
 
 
828
dnl AC_FUNC_SETPGRP does not work when cross compiling
 
829
dnl Instead, assume we will have a prototype for setpgrp if cross compiling.
 
830
dnl testcase from gdb/configure.ac
 
831
if test "$cross_compiling" = no; then
 
832
 AC_FUNC_SETPGRP
 
833
else
 
834
 AC_CACHE_CHECK([whether setpgrp takes no argument], [ac_cv_func_setpgrp_void],
 
835
   [AC_TRY_COMPILE([
 
836
#include <unistd.h>
 
837
], [
 
838
 if (setpgrp(1,1) == -1)
 
839
   exit (0);
 
840
 else
 
841
   exit (1);
 
842
], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes)])
 
843
if test $ac_cv_func_setpgrp_void = yes; then
 
844
 AC_DEFINE([SETPGRP_VOID], 1)
 
845
fi
 
846
fi
 
847
 
 
848
AC_ARG_ENABLE([milter],
 
849
[  --enable-milter        build clamav-milter],
 
850
have_milter=$enableval, have_milter="no")
 
851
 
 
852
dnl we need to try to link with iconv, otherwise there could be a 
 
853
dnl mismatch between a 32-bit and 64-bit lib. Detect this at configure time.
 
854
dnl we need to check after zlib/bzip2, because they can change the include path
 
855
AC_ARG_WITH([iconv], [  --with-iconv supports iconv() (default=auto)],
 
856
[
 
857
 case "$withval" in
 
858
         yes|no) wiconv="$withval";;
 
859
         *) AC_MSG_ERROR([--with-iconv does not take an argument]);;
 
860
 esac],
 
861
[ wiconv=auto ])
 
862
if test "X$wiconv" != "Xno"; then
 
863
        AC_CHECK_LIB([iconv], [libiconv_open], LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -liconv")
 
864
        AC_MSG_CHECKING([for iconv])
 
865
        save_LIBS="$LIBS"
 
866
        LIBS="$LIBCLAMAV_LIBS"
 
867
        AC_TRY_LINK([
 
868
                     #include <iconv.h>
 
869
        ],[
 
870
        char** xin,**xout;
 
871
        unsigned long il,ol;
 
872
        int rc;
 
873
        iconv_t iconv_struct = iconv_open("UTF-16BE","UTF-8");
 
874
        rc = iconv(iconv_struct,xin,&il,xout,&ol);
 
875
        iconv_close(iconv_struct);
 
876
],[
 
877
   AC_MSG_RESULT(yes)
 
878
   AC_DEFINE([HAVE_ICONV], 1, [iconv() available])
 
879
],[
 
880
        AC_MSG_RESULT(no)
 
881
])
 
882
        LIBS="$save_LIBS"
 
883
fi
 
884
 
 
885
AC_ARG_ENABLE([pthreads],
 
886
[  --disable-pthreads      disable POSIX threads support],
 
887
have_pthreads=$enableval,)
 
888
 
 
889
AC_ARG_ENABLE([cr],
 
890
[  --disable-cr           do not link with C reentrant library (BSD) ],
 
891
use_cr=$enableval,)
 
892
 
 
893
AC_ARG_ENABLE([id-check],
 
894
[  --enable-id-check      use id utility instead of /etc/passwd parsing],
 
895
use_id=$enableval, use_id="no")
 
896
 
 
897
AC_ARG_ENABLE([yp-check],
 
898
[  --enable-yp-check      use ypmatch utility instead of /etc/passwd parsing],
 
899
use_yp=$enableval, use_yp="no")
 
900
 
 
901
AC_ARG_WITH([user], 
 
902
[  --with-user=uid        name of the clamav user (default=clamav)],
 
903
clamav_user="$withval", clamav_user="clamav")
 
904
 
 
905
AC_ARG_WITH([group], 
 
906
[  --with-group=gid       name of the clamav group (default=clamav)],
 
907
clamav_group="$withval", clamav_group="clamav")
 
908
 
 
909
AC_DEFINE_UNQUOTED([CLAMAVUSER],"$clamav_user",[name of the clamav user])
 
910
AC_DEFINE_UNQUOTED([CLAMAVGROUP],"$clamav_group",[name of the clamav group])
 
911
 
 
912
AC_ARG_ENABLE([clamav],
 
913
[  --disable-clamav       disable test for clamav user/group],
 
914
test_clamav=$enableval, test_clamav=yes)
 
915
 
 
916
AC_ARG_ENABLE([debug],
 
917
[  --enable-debug         enable debug code],
 
918
enable_debug=$enableval, enable_debug="no")
 
919
 
 
920
if test "$enable_debug" = "yes"; then
 
921
  VERSION_SUFFIX="$VERSION_SUFFIX-debug"
 
922
  AC_DEFINE([CL_DEBUG],1,[enable debugging])
 
923
else
 
924
  AC_DEFINE([NDEBUG],1,[disable assertions])
 
925
fi
 
926
 
 
927
AC_ARG_WITH([version], 
 
928
[  --with-version=STR    use custom version string (dev only)],
 
929
VERSION="$withval", )
 
930
 
 
931
AC_ARG_ENABLE([no-cache],
 
932
[  --enable-no-cache      use "Cache-Control: no-cache" in freshclam],
 
933
enable_nocache=$enableval, enable_nocache="no")
 
934
 
 
935
if test "$enable_nocache" = "yes"; then
 
936
  AC_DEFINE([FRESHCLAM_NO_CACHE],1,[use "Cache-Control: no-cache" in freshclam])
 
937
fi
 
938
 
 
939
AC_ARG_ENABLE([dns-fix],
 
940
[  --enable-dns-fix       enable workaround for broken DNS servers (as in SpeedTouch 510)],
 
941
enable_dnsfix=$enableval, enable_dnsfix="no")
 
942
 
 
943
if test "$enable_dnsfix" = "yes"; then
 
944
  AC_DEFINE([FRESHCLAM_DNS_FIX],1,[enable workaround for broken DNS servers])
 
945
fi
 
946
 
 
947
AC_ARG_ENABLE([bigstack],
 
948
[  --enable-bigstack      increase thread stack size],
 
949
enable_bigstack=$enableval, enable_bigstack="no")
 
950
 
 
951
if test "$enable_bigstack" = "yes"; then
 
952
  AC_DEFINE([C_BIGSTACK],1,[Increase thread stack size.])
 
953
fi
 
954
 
 
955
AC_ARG_WITH([dbdir], 
 
956
[  --with-dbdir=path      path to virus database directory],
 
957
db_dir="$withval", db_dir="_default_")
 
958
 
 
959
dnl I had problems with $pkgdatadir thus these funny checks
 
960
if test "$db_dir" = "_default_"
 
961
then
 
962
    if test "$prefix" = "NONE"
 
963
    then
 
964
        db_dir="$ac_default_prefix/share/clamav"
 
965
    else
 
966
        db_dir="$prefix/share/clamav"
 
967
    fi
 
968
fi
 
969
 
 
970
AC_DEFINE_UNQUOTED([DATADIR],"$db_dir", [Path to virus database directory.])
 
971
DBDIR="$db_dir"
 
972
AC_SUBST([DBDIR])
 
973
 
 
974
dnl configure config directory
 
975
cfg_dir=`echo $sysconfdir | grep prefix`
 
976
 
 
977
if test -n "$cfg_dir"; then
 
978
    if test "$prefix" = "NONE"
 
979
    then
 
980
        cfg_dir="$ac_default_prefix/etc"
 
981
    else
 
982
        cfg_dir="$prefix/etc"
 
983
    fi
 
984
else
 
985
    cfg_dir="$sysconfdir"
 
986
fi
 
987
 
 
988
CFGDIR=$cfg_dir
 
989
AC_SUBST([CFGDIR])
 
990
AC_DEFINE_UNQUOTED([CONFDIR],"$cfg_dir",[where to look for the config file])
 
991
 
 
992
dnl check for in_port_t definition
 
993
AC_MSG_CHECKING([whether in_port_t is defined])
 
994
AC_TRY_COMPILE([
 
995
#include <sys/types.h>
 
996
#include <netinet/in.h>
 
997
],
 
998
[in_port_t pt; pt = 0; return pt;],
 
999
[
 
1000
    AC_MSG_RESULT(yes)
 
1001
    AC_DEFINE([HAVE_IN_PORT_T],1,[in_port_t is defined])
 
1002
],
 
1003
AC_MSG_RESULT(no))
 
1004
 
 
1005
dnl check for in_addr_t definition
 
1006
AC_MSG_CHECKING([for in_addr_t definition])
 
1007
AC_TRY_COMPILE([
 
1008
#include <sys/types.h>
 
1009
#include <netinet/in.h>
 
1010
],
 
1011
[ in_addr_t pt; pt = 0; return pt; ],
 
1012
[
 
1013
    AC_MSG_RESULT(yes)
 
1014
    AC_DEFINE([HAVE_IN_ADDR_T],1,[in_addr_t is defined])
 
1015
],
 
1016
AC_MSG_RESULT(no))
 
1017
 
 
1018
case "$target_os" in
 
1019
linux*)
 
1020
    AC_DEFINE([C_LINUX],1,[target is linux])
 
1021
    if test "$have_pthreads" = "yes"; then
 
1022
        THREAD_LIBS="-lpthread"
 
1023
        TH_SAFE="-thread-safe"
 
1024
        if test "$want_fanotify" = "yes"; then
 
1025
            AC_CHECK_HEADER([linux/fanotify.h],AC_DEFINE([FANOTIFY],1,[use fanotify]),)
 
1026
        fi
 
1027
    fi
 
1028
    ;;
 
1029
kfreebsd*-gnu)
 
1030
    AC_DEFINE([C_KFREEBSD_GNU],1,[target is kfreebsd-gnu])
 
1031
    if test "$have_pthreads" = "yes"; then
 
1032
       THREAD_LIBS="-lpthread"
 
1033
       TH_SAFE="-thread-safe"
 
1034
    fi
 
1035
    ;;
 
1036
solaris*)
 
1037
    CLAMDSCAN_LIBS="$CLAMDSCAN_LIBS -lresolv"
 
1038
    FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lresolv"
 
1039
    if test "$have_pthreads" = "yes"; then
 
1040
        THREAD_LIBS="-lpthread"
 
1041
        CLAMD_LIBS="$CLAMD_LIBS -lresolv"
 
1042
        CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lresolv"
 
1043
        TH_SAFE="-thread-safe"
 
1044
    fi
 
1045
    AC_DEFINE([C_SOLARIS],1,[os is solaris])
 
1046
    ;;
 
1047
freebsd[[45]]*)
 
1048
    if test "$have_pthreads" = "yes"; then
 
1049
        THREAD_LIBS="-pthread -lc_r"
 
1050
        TH_SAFE="-thread-safe"
 
1051
    fi
 
1052
    AC_DEFINE([C_BSD],1,[os is freebsd 4 or 5])
 
1053
    ;;
 
1054
freebsd*)
 
1055
    if test "$have_pthreads" = "yes"; then
 
1056
        THREAD_LIBS="-lthr"
 
1057
        TH_SAFE="-thread-safe"
 
1058
    fi
 
1059
    AC_DEFINE([C_BSD],1,[os is freebsd 6])
 
1060
    ;;
 
1061
dragonfly*)
 
1062
    if test "$have_pthreads" = "yes"; then
 
1063
        THREAD_LIBS="-pthread"
 
1064
        TH_SAFE="-thread-safe"
 
1065
    fi
 
1066
    AC_DEFINE([C_BSD],1,[os is dragonfly])
 
1067
    ;;
 
1068
openbsd*)
 
1069
    if test "$have_pthreads" = "yes"; then
 
1070
        THREAD_LIBS="-pthread"
 
1071
        CLAMD_LIBS="$CLAMD_LIBS -pthread"
 
1072
        CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread"
 
1073
        TH_SAFE="-thread-safe"
 
1074
    fi
 
1075
    AC_DEFINE([C_BSD],1,[os is OpenBSD])
 
1076
    ;;
 
1077
bsdi*)
 
1078
    if test "$have_pthreads" = "yes"; then
 
1079
        THREAD_LIBS="-pthread"
 
1080
        TH_SAFE="-thread-safe"
 
1081
    fi
 
1082
    AC_DEFINE([C_BSD],1,[os is BSDI BSD/OS])
 
1083
    ;;
 
1084
netbsd*)
 
1085
     if test "$have_pthreads" = "yes"; then
 
1086
        THREAD_LIBS="-lpthread"
 
1087
     fi
 
1088
    AC_DEFINE([C_BSD],1,[os is NetBSD])
 
1089
    ;;
 
1090
bsd*)
 
1091
    AC_MSG_RESULT([Unknown BSD detected. Disabling thread support.])
 
1092
    have_pthreads="no"
 
1093
    AC_DEFINE([C_BSD],1,[os is bsd flavor])
 
1094
    ;;
 
1095
beos*)
 
1096
    AC_MSG_RESULT([BeOS detected. Disabling thread support.])
 
1097
    have_pthreads="no"
 
1098
    AC_DEFINE([C_BEOS],1,[os is beos])
 
1099
    ;;
 
1100
x86:Interix*)
 
1101
    AC_DEFINE([C_INTERIX],1,[os is Interix])
 
1102
    ;;
 
1103
darwin*)
 
1104
    AC_DEFINE([C_BSD],1,[os is bsd flavor])
 
1105
    AC_DEFINE([C_DARWIN],1,[os is darwin])
 
1106
    AC_DEFINE([BIND_8_COMPAT],1,[enable bind8 compatibility])
 
1107
    AC_DEFINE([CLAMAUTH],1,[use ClamAuth])
 
1108
    use_netinfo="yes"
 
1109
    ;;
 
1110
os2*)
 
1111
    CLAMDSCAN_LIBS="$CLAMDSCAN_LIBS -lsyslog"
 
1112
    FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lsyslog"
 
1113
    CLAMD_LIBS="$CLAMD_LIBS -lsyslog"
 
1114
    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsyslog"
 
1115
    if test "$have_pthreads" = "yes"; then
 
1116
        THREAD_LIBS="-lpthread"
 
1117
        TH_SAFE="-thread-safe"
 
1118
    fi
 
1119
    AC_DEFINE([C_OS2],1,[os is OS/2])
 
1120
    ;;
 
1121
sco*)
 
1122
    dnl njh@bandsman.sco.uk: SCO Unix port
 
1123
    dnl FRESHCLAM_LIBS="-lsocket"
 
1124
    dnl CLAMD_LIBS="-lsocket"
 
1125
    dnl CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsocket"
 
1126
    ;;
 
1127
hpux*)
 
1128
    if test "$have_pthreads" = "yes"; then
 
1129
        THREAD_LIBS="-lpthread"
 
1130
        TH_SAFE="-thread-safe"
 
1131
    fi
 
1132
    AC_DEFINE([C_HPUX],1,[os is hpux])
 
1133
    if test "$have_mempool" = "yes"; then
 
1134
        LDFLAGS="$LDFLAGS -Wl,+pd,1M"
 
1135
    fi
 
1136
    ;;
 
1137
aix*)
 
1138
    if test "$have_pthreads" = "yes"; then
 
1139
        THREAD_LIBS="-lpthread"
 
1140
        TH_SAFE="-thread-safe"
 
1141
        AC_DEFINE([_THREAD_SAFE],1,[thread safe])
 
1142
    fi
 
1143
    AC_DEFINE([C_AIX],1,[os is aix])
 
1144
    ;;
 
1145
*-*-osf*)
 
1146
    if test "$have_pthreads" = "yes"; then
 
1147
        THREAD_LIBS="-pthread"
 
1148
        TH_SAFE="-thread-safe"
 
1149
        AC_DEFINE([_POSIX_PII_SOCKET],1,[POSIX compatibility])
 
1150
    fi
 
1151
    AC_DEFINE([C_OSF],1,[os is osf/tru64])
 
1152
    ;;
 
1153
nto-qnx*)
 
1154
    AC_DEFINE([C_QNX6],1,[os is QNX 6.x.x])
 
1155
    ;;
 
1156
irix*)
 
1157
    if test "$have_pthreads" = "yes"; then
 
1158
        THREAD_LIBS="-lpthread"
 
1159
        TH_SAFE="-thread-safe"
 
1160
    fi
 
1161
    LIBS="$LIBS -lgen"
 
1162
    AC_DEFINE([C_IRIX],1,[os is irix])
 
1163
    ;;
 
1164
interix*)
 
1165
    AC_DEFINE([C_INTERIX],1,[os is interix])
 
1166
    if test "$test_clamav" = "yes"; then
 
1167
        if test ! -r /etc/passwd; then
 
1168
           test_clamav="no"
 
1169
        fi
 
1170
    fi
 
1171
    if test "$have_pthreads" = "yes"; then
 
1172
        THREAD_LIBS="-lpthread"
 
1173
        TH_SAFE="-thread-safe"
 
1174
    fi
 
1175
    ;;
 
1176
gnu*)
 
1177
    AC_DEFINE([C_GNU_HURD],1,[target is gnu-hurd])
 
1178
    if test "$have_pthreads" = "yes"; then
 
1179
       THREAD_LIBS="-lpthread"
 
1180
       TH_SAFE="-thread-safe"
 
1181
    fi
 
1182
    ;;
 
1183
*)
 
1184
    ;;
 
1185
esac
 
1186
 
 
1187
AC_SUBST([LIBCLAMAV_LIBS])
 
1188
AC_SUBST([CLAMD_LIBS])
 
1189
AC_SUBST([CLAMAV_MILTER_LIBS])
 
1190
AC_SUBST([FRESHCLAM_LIBS])
 
1191
AC_SUBST([CLAMDSCAN_LIBS])
 
1192
AC_SUBST([TH_SAFE])
 
1193
AC_SUBST([THREAD_LIBS])
 
1194
 
 
1195
dnl --enable-milter
 
1196
if test "$have_milter" = "yes"; then
 
1197
    dnl libmilter checking code adapted from spamass-milter by
 
1198
    dnl Tom G. Christensen <tgc@statsbiblioteket.dk>
 
1199
 
 
1200
    dnl Check for libmilter and it's header files in the usual locations
 
1201
    save_LIBS="$LIBS"
 
1202
    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread"
 
1203
    if test -d /usr/lib/libmilter ; then
 
1204
        CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -L/usr/lib/libmilter"
 
1205
    fi
 
1206
    LIBS="$LIBS -lmilter $CLAMAV_MILTER_LIBS"
 
1207
    AC_CHECK_LIB([milter],[mi_stop],[CLAMAV_MILTER_LIBS="-lmilter $CLAMAV_MILTER_LIBS"],[
 
1208
        dnl Older sendmails require libsm or libsmutil for support functions
 
1209
        AC_SEARCH_LIBS([strlcpy], [sm smutil], [test "$ac_cv_search_strlcpy" = "none required" || CLAMAV_MILTER_XLIB="$ac_cv_search_strlcpy"])
 
1210
        LIBS="$save_LIBS $CLAMAV_MILTER_LIBS $CLAMAV_MILTER_XLIB"
 
1211
        $as_unset ac_cv_lib_milter_mi_stop
 
1212
        AC_CHECK_LIB([milter],[mi_stop],[CLAMAV_MILTER_LIBS="-lmilter $CLAMAV_MILTER_XLIB $CLAMAV_MILTER_LIBS"],[
 
1213
            AC_MSG_ERROR([Cannot find libmilter])
 
1214
        ])
 
1215
    ])
 
1216
    LIBS="$save_LIBS"
 
1217
    AC_CHECK_HEADERS([libmilter/mfapi.h],[have_milter="yes"],[
 
1218
        AC_MSG_ERROR([Please install mfapi.h from the sendmail distribution])
 
1219
    ])
 
1220
fi
 
1221
 
 
1222
AM_CONDITIONAL([BUILD_CLAMD],[test "$have_pthreads" = "yes"])
 
1223
AM_CONDITIONAL([HAVE_MILTER],[test "$have_milter" = "yes"])
 
1224
 
 
1225
if test "$have_pthreads" = "yes"
 
1226
then
 
1227
    save_LIBS="$LIBS"
 
1228
    LIBS="$THREAD_LIBS $LIBS"
 
1229
    AC_CHECK_FUNCS([sched_yield pthread_yield])
 
1230
    LIBS="$save_LIBS"
 
1231
    AC_DEFINE([BUILD_CLAMD], 1, "build clamd")
 
1232
    dnl define these here, so we don't forget any system
 
1233
    AC_DEFINE([CL_THREAD_SAFE],1,[thread safe])
 
1234
    AC_DEFINE([_REENTRANT],1,[thread safe])
 
1235
fi
 
1236
 
 
1237
AC_CHECK_FUNCS([enable_extended_FILE_stdio])
 
1238
 
 
1239
dnl Check for readdir_r and number of its arguments
 
1240
dnl Code from libwww/configure.in
 
1241
 
 
1242
AC_MSG_CHECKING([for readdir_r])
 
1243
if test -z "$ac_cv_readdir_args"; then
 
1244
    AC_TRY_COMPILE(
 
1245
    [
 
1246
#include <sys/types.h>
 
1247
#include <dirent.h>
 
1248
    ],
 
1249
    [
 
1250
    struct dirent dir, *dirp;
 
1251
    DIR *mydir;
 
1252
    dirp = readdir_r(mydir, &dir);
 
1253
    ], ac_cv_readdir_args=2)
 
1254
fi
 
1255
if test -z "$ac_cv_readdir_args"; then
 
1256
    AC_TRY_COMPILE(
 
1257
        [
 
1258
#include <sys/types.h>
 
1259
#include <dirent.h>
 
1260
    ],
 
1261
    [
 
1262
        struct dirent dir, *dirp;
 
1263
        DIR *mydir;
 
1264
        int rc;
 
1265
        rc = readdir_r(mydir, &dir, &dirp);
 
1266
    ], ac_cv_readdir_args=3)
 
1267
fi
 
1268
 
 
1269
AC_ARG_ENABLE([readdir_r],
 
1270
[  --enable-readdir_r               enable support for readdir_r],
 
1271
enable_readdir_r=$enableval, enable_readdir_r="no")
 
1272
 
 
1273
if test "$enable_readdir_r" = "no"; then
 
1274
    AC_MSG_RESULT(support disabled)
 
1275
elif test -z "$ac_cv_readdir_args"; then
 
1276
    AC_MSG_RESULT(no)
 
1277
else
 
1278
    if test "$ac_cv_readdir_args" = 2; then
 
1279
        AC_DEFINE([HAVE_READDIR_R_2],1,[readdir_r takes 2 arguments])
 
1280
    elif test "$ac_cv_readdir_args" = 3; then
 
1281
        AC_DEFINE([HAVE_READDIR_R_3],1,[readdir_r takes 3 arguments])
 
1282
    fi
 
1283
    AC_MSG_RESULT([yes, and it takes $ac_cv_readdir_args arguments])
 
1284
fi
 
1285
 
 
1286
AC_MSG_CHECKING([for ctime_r])
 
1287
if test "$ac_cv_func_ctime_r" = "yes"; then
 
1288
    AC_TRY_COMPILE([
 
1289
        #include <time.h>
 
1290
    ],[
 
1291
        char buf[31];
 
1292
        time_t t;
 
1293
        ctime_r(&t, buf, 30);
 
1294
    ],[
 
1295
        ac_cv_ctime_args=3
 
1296
        AC_DEFINE([HAVE_CTIME_R_3],1,[ctime_r takes 3 arguments])
 
1297
    ],[
 
1298
        ac_cv_ctime_args=2
 
1299
        AC_DEFINE([HAVE_CTIME_R_2],1,[ctime_r takes 2 arguments])
 
1300
    ])
 
1301
 
 
1302
    AC_MSG_RESULT([yes, and it takes $ac_cv_ctime_args arguments])
 
1303
fi
 
1304
 
 
1305
dnl Determine socklen_t type. Code from lftp.
 
1306
AC_MSG_CHECKING([for socklen_t])
 
1307
AC_CACHE_VAL([ac_cv_socklen_t],
 
1308
[
 
1309
    ac_cv_socklen_t=no
 
1310
    AC_TRY_COMPILE([
 
1311
        #include <sys/types.h>
 
1312
        #include <sys/socket.h>
 
1313
    ],
 
1314
    [
 
1315
        socklen_t len;
 
1316
        getpeername(0,0,&len);
 
1317
    ],
 
1318
    [
 
1319
        ac_cv_socklen_t=yes
 
1320
    ])
 
1321
])
 
1322
AC_MSG_RESULT([$ac_cv_socklen_t])
 
1323
    if test $ac_cv_socklen_t = no; then
 
1324
    AC_MSG_CHECKING([for socklen_t equivalent])
 
1325
    AC_CACHE_VAL([ac_cv_socklen_t_equiv],
 
1326
    [
 
1327
        ac_cv_socklen_t_equiv=int
 
1328
        for t in int size_t unsigned long "unsigned long"; do
 
1329
            AC_TRY_COMPILE([
 
1330
                #include <sys/types.h>
 
1331
                #include <sys/socket.h>
 
1332
            ],
 
1333
            [
 
1334
                $t len;
 
1335
                getpeername(0,0,&len);
 
1336
            ],
 
1337
            [
 
1338
                ac_cv_socklen_t_equiv="$t"
 
1339
                break
 
1340
            ])
 
1341
        done
 
1342
    ])
 
1343
    AC_MSG_RESULT([$ac_cv_socklen_t_equiv])
 
1344
    AC_DEFINE_UNQUOTED([socklen_t], $ac_cv_socklen_t_equiv, [Define to "int" if <sys/socket.h> does not define.])
 
1345
fi
 
1346
 
 
1347
dnl Check for clamav in /etc/passwd
 
1348
if test "$test_clamav" = "yes"
 
1349
then
 
1350
    dnl parse /etc/passwd
 
1351
    if test "$use_id" = "no"
 
1352
    then
 
1353
        AC_MSG_CHECKING([for $clamav_user in /etc/passwd])
 
1354
        if test -r /etc/passwd; then
 
1355
            clamavuser=`cat /etc/passwd|grep "^$clamav_user:"`
 
1356
            clamavgroup=`cat /etc/group|grep "^$clamav_group:"`
 
1357
        fi
 
1358
    else
 
1359
        AC_MSG_CHECKING([for $clamav_user using id])
 
1360
        id $clamav_user > /dev/null 2>&1
 
1361
        if test "$?" = 0 ; then
 
1362
            clamavuser=1
 
1363
            AC_PATH_PROG(GETENT, getent)
 
1364
            if test -n "$GETENT" ; then
 
1365
                clamavgroup=`$GETENT group | grep "^${clamav_group}:"`
 
1366
            else
 
1367
                clamavgroup=`cat /etc/group|grep $clamav_group`
 
1368
            fi
 
1369
        fi
 
1370
    fi
 
1371
 
 
1372
    if test "$use_netinfo" = "yes"
 
1373
    then
 
1374
        if test -x /usr/bin/dscl; then
 
1375
            AC_MSG_CHECKING([for $clamav_user using dscl])
 
1376
            clamavuser=`/usr/bin/dscl . -list /Users |grep ${clamav_user}`
 
1377
            clamavgroup=`/usr/bin/dscl . -list /Groups |grep ${clamav_group}`
 
1378
        else
 
1379
            AC_MSG_CHECKING([for $clamav_user using netinfo])
 
1380
            clamavuser=`/usr/bin/nidump passwd . |grep ${clamav_user}`
 
1381
            clamavgroup=`/usr/bin/nidump group . |grep ${clamav_group}`
 
1382
        fi
 
1383
    fi
 
1384
 
 
1385
    if test "$use_yp" = "yes"
 
1386
    then
 
1387
        AC_MSG_CHECKING([for $clamav_user using ypmatch])
 
1388
        clamavuser=`ypmatch ${clamav_user} passwd`
 
1389
        clamavgroup=`ypmatch ${clamav_group} group`
 
1390
    fi
 
1391
 
 
1392
    if test -z "$clamavuser" || test -z "$clamavgroup"
 
1393
    then
 
1394
        AC_MSG_RESULT(no)
 
1395
        AC_MSG_ERROR([User $clamav_user (and/or group $clamav_group) does not exist. Please read the documentation !])
 
1396
    else
 
1397
        AC_MSG_RESULT([yes, user $clamav_user and group $clamav_group])
 
1398
        CLAMAVUSER="$clamav_user"
 
1399
        CLAMAVGROUP="$clamav_group"
 
1400
        AC_SUBST([CLAMAVUSER])
 
1401
        AC_SUBST([CLAMAVGROUP])
 
1402
    fi
 
1403
fi
 
1404
 
 
1405
dnl check for __attribute__((packed))
 
1406
dnl but only on compilers claiming to be gcc compatible
 
1407
dnl because for example Sun's compiler silently ignores the packed attribute.
 
1408
AC_MSG_CHECKING([for structure packing via __attribute__((packed))])
 
1409
AC_CACHE_VAL([have_cv_attrib_packed],[
 
1410
        AC_TRY_COMPILE(,
 
1411
                [#ifdef __GNUC__
 
1412
                 struct { int i __attribute__((packed)); } s;
 
1413
                 #else
 
1414
                 #error Only checking for packed attribute on gcc-like compilers
 
1415
                 #endif],
 
1416
                [have_cv_attrib_packed=yes],
 
1417
                [have_cv_attrib_packed=no])
 
1418
        ])
 
1419
AC_MSG_RESULT([$have_cv_attrib_packed])
 
1420
 
 
1421
if test "$have_cv_attrib_packed" = no; then
 
1422
        AC_MSG_CHECKING([for structure packing via pragma])
 
1423
        AC_CACHE_VAL([have_cv_pragma_pack],[
 
1424
                AC_TRY_RUN([
 
1425
                            int main(int argc, char **argv) {
 
1426
#pragma pack(1)                 /* has to be in column 1 ! */
 
1427
                        struct { char c; long l; } s;
 
1428
                        return sizeof(s)==sizeof(s.c)+sizeof(s.l) ? 0:1; } ],
 
1429
                        [have_cv_pragma_pack=yes],
 
1430
                        [have_cv_pragma_pack=no])
 
1431
                ])
 
1432
        AC_MSG_RESULT([$have_cv_pragma_pack])
 
1433
        if test "$have_cv_pragma_pack" = yes; then
 
1434
                AC_DEFINE([HAVE_PRAGMA_PACK], 1, "pragma pack")
 
1435
        else
 
1436
                AC_MSG_CHECKING([for structure packing via hppa/hp-ux pragma])
 
1437
                AC_CACHE_VAL([have_cv_pragma_pack_hpux],[
 
1438
                        AC_TRY_RUN([
 
1439
                        /* hppa/hp-ux wants pragma outside of function */
 
1440
#pragma pack 1 /* has to be in column 1 ! */
 
1441
                        struct { char c; long l; } s;
 
1442
                            int main(int argc, char **argv) {
 
1443
                        return sizeof(s)==sizeof(s.c)+sizeof(s.l) ? 0:1; } ],
 
1444
                        [have_cv_pragma_pack_hpux=yes],
 
1445
                        [have_cv_pragma_pack_hpux=no])
 
1446
                ])
 
1447
                AC_MSG_RESULT([$have_cv_pragma_pack_hpux])
 
1448
                AC_DEFINE([HAVE_PRAGMA_PACK_HPPA], 1, "pragma pack hppa/hp-ux style")
 
1449
        fi
 
1450
fi
 
1451
 
 
1452
dnl check for __attribute__((aligned))
 
1453
AC_MSG_CHECKING([for type aligning via __attribute__((aligned))])
 
1454
AC_CACHE_VAL([have_cv_attrib_aligned],[
 
1455
        AC_TRY_COMPILE(,
 
1456
                [typedef int cl_aligned_int __attribute__((aligned));],
 
1457
                [have_cv_attrib_aligned=yes],
 
1458
                [have_cv_attrib_aligned=no])
 
1459
        ])
 
1460
AC_MSG_RESULT([$have_cv_attrib_aligned])
 
1461
 
 
1462
if test "$have_cv_attrib_packed" = no -a "$have_cv_pragma_pack" = no -a "$have_cv_pragma_pack_hpux" = no; then
 
1463
        AC_MSG_ERROR(Need to know how to pack structures with this compiler)
 
1464
fi
 
1465
 
 
1466
if test "$have_cv_attrib_packed" = yes; then
 
1467
        AC_DEFINE([HAVE_ATTRIB_PACKED], 1, [attrib packed])
 
1468
fi
 
1469
 
 
1470
if test "$have_cv_attrib_aligned" = yes; then
 
1471
        AC_DEFINE([HAVE_ATTRIB_ALIGNED], 1, [attrib aligned])
 
1472
fi
 
1473
 
 
1474
dnl Sanity check that struct packing works
 
1475
AC_MSG_CHECKING([that structure packing works])
 
1476
AC_CACHE_VAL([have_cv_struct_pack],[
 
1477
    AC_TRY_RUN([
 
1478
#ifndef HAVE_ATTRIB_PACKED
 
1479
#define __attribute__(x)
 
1480
#endif
 
1481
#ifdef HAVE_PRAGMA_PACK
 
1482
#pragma pack(1) /* has to be in column 1 ! */
 
1483
#endif
 
1484
#ifdef HAVE_PRAGMA_PACK_HPPA
 
1485
#pragma pack 1 /* has to be in column 1 ! */
 
1486
#endif
 
1487
 
 
1488
struct { char c __attribute__((packed)); long l __attribute__((packed)); } s;
 
1489
 
 
1490
#ifdef HAVE_PRAGMA_PACK
 
1491
#pragma pack()
 
1492
#endif
 
1493
#ifdef HAVE_PRAGMA_PACK_HPPA
 
1494
#pragma pack
 
1495
#endif
 
1496
 
 
1497
struct { char c; long l;} s2;
 
1498
 
 
1499
#ifdef HAVE_PRAGMA_PACK
 
1500
#pragma pack(1) /* has to be in column 1 ! */
 
1501
#endif
 
1502
#ifdef HAVE_PRAGMA_PACK_HPPA
 
1503
#pragma pack 1 /* has to be in column 1 ! */
 
1504
#endif
 
1505
 
 
1506
struct { char c; long l; } __attribute__((packed)) s3;
 
1507
 
 
1508
#ifdef HAVE_PRAGMA_PACK
 
1509
#pragma pack()
 
1510
#endif
 
1511
#ifdef HAVE_PRAGMA_PACK_HPPA
 
1512
#pragma pack
 
1513
#endif
 
1514
 
 
1515
    int main(int argc, char **argv) {
 
1516
        if (sizeof(s)!=sizeof(s.c)+sizeof(s.l))
 
1517
            return 1;
 
1518
        if (sizeof(s) != sizeof(s3))
 
1519
            return 2;
 
1520
        return (sizeof(s2) >= sizeof(s)) ? 0 : 3;
 
1521
    }],
 
1522
    [have_cv_struct_pack=yes],
 
1523
    [have_cv_struct_pack=no],
 
1524
    [have_cv_struct_pack=yes])
 
1525
])
 
1526
AC_MSG_RESULT([$have_cv_struct_pack])
 
1527
 
 
1528
if test "$have_cv_struct_pack" = "no"; then
 
1529
    AC_MSG_ERROR([Structure packing seems to be available, but is not working with this compiler])
 
1530
fi
 
1531
 
 
1532
dnl Check if <sys/select.h> needs to be included for fd_set
 
1533
AC_MSG_CHECKING([for fd_set])
 
1534
AC_HEADER_EGREP([fd_mask], [sys/select.h], [have_fd_set=yes])
 
1535
if test "$have_fd_set" = yes; then
 
1536
        AC_DEFINE([HAVE_SYS_SELECT_H], 1, "have <sys/select.h>")
 
1537
        AC_MSG_RESULT([yes, found in sys/select.h])
 
1538
else
 
1539
        AC_TRY_COMPILE([#include <sys/time.h>
 
1540
                        #include <sys/types.h>
 
1541
                        #ifdef HAVE_UNISTD_H
 
1542
                        #include <unistd.h>
 
1543
                        #endif],
 
1544
                [fd_set readMask, writeMask;], have_fd_set=yes, have_fd_set=no)
 
1545
        if test "$have_fd_set" = yes; then
 
1546
                AC_MSG_RESULT([yes, found in sys/types.h])
 
1547
        else
 
1548
                AC_DEFINE([NO_FD_SET], 1, "no fd_set")
 
1549
                AC_MSG_RESULT(no)
 
1550
        fi
 
1551
fi
 
1552
 
 
1553
AC_MSG_CHECKING([default FD_SETSIZE value])
 
1554
AC_TRY_RUN([
 
1555
#include <stdio.h>
 
1556
#include <unistd.h>
 
1557
#include <sys/time.h>
 
1558
#ifdef HAVE_SYS_SELECT_H
 
1559
#include <sys/select.h>
 
1560
#endif
 
1561
#ifdef HAVE_SYS_TYPES_H
 
1562
#include <sys/types.h>
 
1563
#endif
 
1564
#include <errno.h>
 
1565
int main(void) {
 
1566
        FILE *fp = fopen("conftestval", "w");
 
1567
        if(fp) {
 
1568
                if(fprintf (fp, "%d\n", FD_SETSIZE) < 1)  {
 
1569
                        perror("fprintf failed");
 
1570
                        return errno;
 
1571
                }
 
1572
        } else {
 
1573
                perror("fopen failed");
 
1574
                return errno;
 
1575
        }
 
1576
        return 0;
 
1577
}
 
1578
],
 
1579
DEFAULT_FD_SETSIZE=`cat conftestval`,
 
1580
DEFAULT_FD_SETSIZE=256,
 
1581
DEFAULT_FD_SETSIZE=256)
 
1582
AC_MSG_RESULT([$DEFAULT_FD_SETSIZE])
 
1583
AC_DEFINE_UNQUOTED([DEFAULT_FD_SETSIZE], $DEFAULT_FD_SETSIZE, "default FD_SETSIZE value")
 
1584
 
 
1585
AC_MSG_CHECKING([stat64])
 
1586
AC_TRY_RUN([
 
1587
#define _LARGEFILE_SOURCE
 
1588
#define _LARGEFILE64_SOURCE
 
1589
#include <stdio.h>
 
1590
#include <sys/types.h>
 
1591
#include <sys/stat.h>
 
1592
#include <unistd.h>
 
1593
#include <errno.h>
 
1594
 
 
1595
int main(void) {
 
1596
    struct stat64 sb;
 
1597
 
 
1598
    if (stat64(".", &sb) == -1)
 
1599
        return errno;
 
1600
 
 
1601
    return 0;
 
1602
}
 
1603
],
 
1604
[enable_stat64=yes],
 
1605
[enable_stat64=no],
 
1606
[enable_stat64=no],
 
1607
)
 
1608
 
 
1609
if test "$enable_stat64" != "no"; then
 
1610
AC_DEFINE([HAVE_STAT64],1,[enable stat64])
 
1611
CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
 
1612
fi
 
1613
AC_MSG_RESULT([$enable_stat64])
 
1614
 
 
1615
dnl Check signed right shift implementation
 
1616
AC_MSG_CHECKING([whether signed right shift is sign extended])
 
1617
AC_TRY_RUN([int main(void){int a=-1;int b=a>>1;return(a!=b);}],
 
1618
    [have_signed_rightshift_extended=yes],
 
1619
    [have_signed_rightshift_extended=no],
 
1620
    [have_signed_rightshift_extended=no])
 
1621
if test $have_signed_rightshift_extended = yes; then
 
1622
    AC_DEFINE([HAVE_SAR], 1, [Define signed right shift implementation])
 
1623
fi
 
1624
AC_MSG_RESULT([$have_signed_rightshift_extended]);
 
1625
 
 
1626
AC_C_FDPASSING
 
1627
 
 
1628
AC_DEFINE_UNQUOTED([VERSION],"$VERSION",[Version number of package])
 
1629
AC_DEFINE_UNQUOTED([VERSION_SUFFIX],"$VERSION_SUFFIX",[Version suffix for package])
 
1630
 
 
1631
AC_ARG_ENABLE(clamdtop,
 
1632
              AC_HELP_STRING([--enable-clamdtop],
 
1633
                             [Enable 'clamdtop' tool @<:@default=auto@:>@]),
 
1634
[enable_clamdtop=$enableval], [enable_clamdtop="auto"])
 
1635
 
 
1636
if test "$enable_clamdtop" != "no"; then
 
1637
 
 
1638
AC_LIB_FIND([ncurses], [ncurses/ncurses.h],
 
1639
            AC_LANG_PROGRAM([#include <ncurses/ncurses.h>],
 
1640
                            [initscr(); KEY_RESIZE;]),
 
1641
            [CURSES_CPPFLAGS="$INCNCURSES"; CURSES_LIBS="$LTLIBNCURSES";
 
1642
             CURSES_INCLUDE="<ncurses/ncurses.h>"],
 
1643
            [])
 
1644
 
 
1645
if test "X$HAVE_LIBNCURSES" != "Xyes"; then
 
1646
    HAVE_LIBNCURSES=
 
1647
    AC_LIB_FIND([ncurses], [ncurses.h],
 
1648
            AC_LANG_PROGRAM([#include <ncurses.h>],
 
1649
                            [initscr(); KEY_RESIZE;]),
 
1650
            [CURSES_CPPFLAGS="$INCNCURSES"; CURSES_LIBS="$LTLIBNCURSES";
 
1651
             CURSES_INCLUDE="<ncurses.h>"],
 
1652
            [])
 
1653
fi
 
1654
 
 
1655
if test "X$HAVE_LIBNCURSES" != "Xyes"; then
 
1656
    AC_LIB_FIND([pdcurses],[curses.h],
 
1657
                            AC_LANG_PROGRAM([#include <curses.h>],
 
1658
                                            [initscr(); KEY_RESIZE;]),
 
1659
                            [CURSES_CPPFLAGS="$INCPDCURSES";
 
1660
                             CURSES_LIBS="$LTLIBPDCURSES";
 
1661
                             CURSES_INCLUDE="<curses.h>"],
 
1662
                            [AC_MSG_WARN([****** not building clamdtop: ncurses not found])])
 
1663
fi
 
1664
 
 
1665
if test "x$CURSES_LIBS" = "x" -a "$enable_clamdtop" = "yes"; then
 
1666
    AC_MSG_ERROR([
 
1667
 
 
1668
ERROR!  Clamdtop was configured, but not found.  You need to install libncurses5-dev.
 
1669
])
 
1670
fi
 
1671
 
 
1672
fi
 
1673
 
 
1674
AC_DEFINE_UNQUOTED([CURSES_INCLUDE], $CURSES_INCLUDE, [curses header location])
 
1675
AC_SUBST([CURSES_CPPFLAGS])
 
1676
AC_SUBST([CURSES_LIBS])
 
1677
AM_CONDITIONAL([HAVE_CURSES],
 
1678
               [test "X$HAVE_LIBNCURSES" = "Xyes" || test "X$HAVE_LIBPDCURSES" = "Xyes"])
 
1679
 
 
1680
AC_ARG_ENABLE([distcheck-werror],
 
1681
              AC_HELP_STRING([--enable-distcheck-werror],
 
1682
                             [enable warnings as error for distcheck
 
1683
                              @<:@default=no@:>@]),
 
1684
[enable_distcheckwerror=$enableval],[enable_distcheckwerror="no"])
 
1685
 
 
1686
# Enable distcheck warnings and Werror only for gcc versions that support them,
 
1687
# and only after we've run the configure tests.
 
1688
# Some configure tests fail (like checking for cos in -lm) if we enable these
 
1689
# Werror flags for configure too (for example -Wstrict-prototypes makes
 
1690
# configure think that -lm doesn't have cos, hence its in libc).
 
1691
WERR_CFLAGS=
 
1692
WERR_CFLAGS_MILTER=
 
1693
if test "x$enable_distcheckwerror" = "xyes"; then
 
1694
    if test "$distcheck_enable_flags" = "1"; then
 
1695
        WERR_COMMON="-Wno-pointer-sign -Werror-implicit-function-declaration -Werror -Wextra -Wall -Wno-error=strict-aliasing -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 -Wstrict-overflow=1 -Winit-self -Wmissing-include-dirs -Wdeclaration-after-statement -Waggregate-return -Wmissing-format-attribute -Wno-error=missing-format-attribute -Wno-error=type-limits -Wno-error=unused-but-set-variable -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"
 
1696
        WERR_CFLAGS="$WERR_COMMON -Wwrite-strings"
 
1697
        WERR_CFLAGS_MILTER="$WERR_COMMON -Wno-error=format-nonliteral"
 
1698
    fi
 
1699
fi
 
1700
AC_SUBST([WERR_CFLAGS])
 
1701
AC_SUBST([WERR_CFLAGS_MILTER])
 
1702
 
 
1703
AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm],
 
1704
                                    [Enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
 
1705
                                    [enable_llvm=$enableval], [enable_llvm="auto"])
 
1706
 
 
1707
if test "$enable_llvm" != "no"; then
 
1708
    dnl Try to configure subdir, optionally
 
1709
    AC_CONFIG_SUBDIRS_OPTIONAL([libclamav/c++])
 
1710
fi
 
1711
 
 
1712
AC_ARG_ENABLE([sha-collector-for-internal-use], [], [enable_sha_collector="yes"], [enable_sha_collector="no"])
 
1713
if test "$enable_sha_collector" != "no"; then
 
1714
    AC_DEFINE([HAVE__INTERNAL__SHA_COLLECT], 1, [For internal use only - DO NOT DEFINE])
 
1715
fi
 
1716
 
 
1717
AC_OUTPUT([
 
1718
clamscan/Makefile
 
1719
database/Makefile
 
1720
docs/Makefile
 
1721
clamd/Makefile
 
1722
clamdscan/Makefile
 
1723
clamav-milter/Makefile
 
1724
freshclam/Makefile
 
1725
sigtool/Makefile
 
1726
clamconf/Makefile
 
1727
etc/Makefile
 
1728
test/Makefile
 
1729
unit_tests/Makefile
 
1730
clamdtop/Makefile
 
1731
clambc/Makefile
 
1732
Makefile
 
1733
clamav-config
 
1734
libclamav.pc
 
1735
platform.h
 
1736
docs/man/clamav-milter.8
 
1737
docs/man/clamav-milter.conf.5
 
1738
docs/man/clambc.1
 
1739
docs/man/clamconf.1
 
1740
docs/man/clamd.8
 
1741
docs/man/clamd.conf.5
 
1742
docs/man/clamdscan.1
 
1743
docs/man/clamscan.1
 
1744
docs/man/freshclam.1
 
1745
docs/man/freshclam.conf.5
 
1746
docs/man/sigtool.1
 
1747
docs/man/clamdtop.1
 
1748
])
 
1749
 
 
1750
if test "$enable_llvm" = "yes" && test "$subdirfailed" != "no"; then
 
1751
    AC_MSG_ERROR([Failed to configure LLVM, and LLVM was explicitly requested])
 
1752
fi
 
1753
AM_CONDITIONAL([ENABLE_LLVM],
 
1754
               [test "$subdirfailed" != "yes" && test "$enable_llvm" != "no"])
 
1755
no_recursion="yes";
 
1756
AC_OUTPUT([libclamav/Makefile])
 
1757
 
 
1758
# Print a summary of what features we enabled
 
1759
AC_MSG_NOTICE([Summary of detected features follows])
 
1760
 
 
1761
cat <<EOF
 
1762
              OS          : $target_os
 
1763
              pthreads    : $have_pthreads ($THREAD_LIBS)
 
1764
EOF
 
1765
 
 
1766
AC_MSG_NOTICE([Summary of miscellaneous  features])
 
1767
if test "x$CHECK_LIBS" = "x"; then
 
1768
    check_libs="no"
 
1769
else
 
1770
    check_libs="$CHECK_LIBS"
 
1771
fi
 
1772
CL_MSG_STATUS([check       ],[$check_libs],[$enable_check_ut])
 
1773
CL_MSG_STATUS([fanotify    ],[$want_fanotify],[$want_fanotify])
 
1774
if test "x$ac_cv_have_control_in_msghdr" = "xyes"; then
 
1775
    CL_MSG_STATUS([fdpassing   ],[$have_fdpass],[$want_fdpassing])
 
1776
else
 
1777
    CL_MSG_STATUS([fdpassing   ],[n/a],[])
 
1778
fi
 
1779
CL_MSG_STATUS([IPv6        ],[$have_cv_ipv6],[$want_ipv6])
 
1780
 
 
1781
AC_MSG_NOTICE([Summary of optional tools])
 
1782
CL_MSG_STATUS([clamdtop    ],[$CURSES_LIBS],[$enable_clamdtop])
 
1783
CL_MSG_STATUS([milter      ],[yes],[$have_milter])
 
1784
 
 
1785
AC_MSG_NOTICE([Summary of engine performance features)])
 
1786
if test "x$enable_debug" = "xyes"; then
 
1787
    CL_MSG_STATUS([release mode],[no],[debug build])
 
1788
else
 
1789
    CL_MSG_STATUS([release mode],[yes],[yes])
 
1790
fi
 
1791
have_jit="no"
 
1792
if test "$subdirfailed" = "no"; then
 
1793
    have_jit="yes"
 
1794
fi
 
1795
CL_MSG_STATUS([jit         ],[$have_jit],[$enable_llvm])
 
1796
CL_MSG_STATUS([mempool     ],[$have_mempool],[$enable_mempool])
 
1797
 
 
1798
AC_MSG_NOTICE([Summary of engine detection features])
 
1799
CL_MSG_STATUS([autoit_ea06 ],[$have_autoitea06],[])
 
1800
CL_MSG_STATUS([bzip2       ],[$bzip_check],[$want_bzip2])
 
1801
CL_MSG_STATUS([zlib        ],[$ZLIB_HOME],[yes])
 
1802
CL_MSG_STATUS([unrar       ],[$want_unrar],[$want_unrar])
 
1803
if test "x$XML_LIBS" = "x"; then
 
1804
    CL_MSG_STATUS([dmg and xar ],[no],[])
 
1805
else
 
1806
    CL_MSG_STATUS([dmg and xar ],[yes, from $XML_HOME],[])
 
1807
fi
 
1808
 
 
1809
# Yep, downgrading the compiler avoids the bug too:
 
1810
# 4.0.x, and 4.1.0 are the known buggy versions
 
1811
# 3.4 doesn't have the bug
 
1812
if test "x$gcc_check" != "xyes"; then
 
1813
        AC_MSG_WARN([
 
1814
****** Optimizations disabled to avoid compiler bugs
 
1815
****** The resulting binaries will be slow!
 
1816
****** It is recommended to either upgrade or downgrade your compiler
 
1817
])
 
1818
fi
 
1819
 
 
1820
if test "x$cross_compiling" != "xno" || test "x$gcc_check" != "xyes" || test "x$zlib_check" = "xno" || test "x$bzip_check" != "xok" ; then
 
1821
AC_MSG_WARN([
 
1822
****** WARNING:
 
1823
****** You are cross compiling to a different host or you are
 
1824
****** linking to bugged system libraries or you have manually
 
1825
****** disabled important configure checks.
 
1826
****** Please be aware that this build may be badly broken.
 
1827
****** DO NOT REPORT BUGS BASED ON THIS BUILD !!!
 
1828
])
 
1829
fi
 
1830