~ubuntu-branches/ubuntu/saucy/clamav/saucy-backports

« back to all changes in this revision

Viewing changes to configure.ac

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-07-15 01:08:10 UTC
  • mfrom: (0.35.47 sid)
  • Revision ID: package-import@ubuntu.com-20140715010810-ru66ek4fun2iseba
Tags: 0.98.4+dfsg-2~ubuntu13.10.1
No-change backport to saucy (LP: #1341962)

Show diffs side-by-side

added added

removed removed

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