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

« back to all changes in this revision

Viewing changes to .pc/0003-configure-use-pkg-config-for-check-so-test-is-detect.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" != "no" ; then
 
468
        AC_LIB_FIND([check],[check.h],
 
469
                        AC_LANG_PROGRAM([#include <check.h>],[srunner_create(0)]),
 
470
                        [CHECK_CPPFLAGS="$INCCHECK"; CHECK_LIBS="$LTLIBCHECK"],
 
471
                        [])
 
472
fi
 
473
AC_SUBST([CHECK_CPPFLAGS])
 
474
AC_SUBST([CHECK_LIBS])
 
475
AM_CONDITIONAL([HAVE_LIBCHECK],test "X$HAVE_LIBCHECK" = "Xyes")
 
476
 
 
477
if test "x$CHECK_LIBS" = "x" -a "$enable_check_ut" = "yes"; then
 
478
    AC_MSG_ERROR([
 
479
 
 
480
ERROR!  Check was configured, but not found.  Get it from http://check.sf.net/
 
481
])
 
482
fi
 
483
 
 
484
AC_ARG_ENABLE(coverage,
 
485
              AC_HELP_STRING([--enable-coverage],
 
486
                             [turn on test coverage
 
487
                              @<:@default=no@:>@]),
 
488
[enable_cov=$enableval],[enable_cov="no"])
 
489
 
 
490
if test "x$enable_coverage" = "xyes"; then
 
491
        if test "x$CHECK_LIBS" = "x"; then
 
492
                AC_MSG_ERROR([Coverage testing required, but unit tests not enabled!])
 
493
        fi
 
494
        if test "x$ac_compiler_gnu" != "xyes"; then
 
495
                AC_MSG_ERROR([coverage testing only works if gcc is used])
 
496
        fi
 
497
 
 
498
        CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
 
499
        LDFLAGS="$LDFLAGS -lgcov"
 
500
        AC_CHECK_PROGS(GCOV, gcov, false)
 
501
        AC_CHECK_PROGS(LCOV, lcov, false)
 
502
        AC_CHECK_PROGS(GENHTML, genhtml, false)
 
503
fi
 
504
 
 
505
AM_CONDITIONAL(ENABLE_COVERAGE, test "x$enable_coverage" = "xyes")
 
506
 
 
507
have_pthreads=no
 
508
AC_CHECK_HEADER([pthread.h],[have_pthreads=yes],)
 
509
 
 
510
AM_MAINTAINER_MODE
 
511
dnl Check for zlib
 
512
AC_MSG_CHECKING([for zlib installation])
 
513
AC_ARG_WITH([zlib],
 
514
[  --with-zlib=DIR        path to directory containing zlib library (default=
 
515
                          /usr/local or /usr if not found in /usr/local)],
 
516
[
 
517
if test "$withval"; then
 
518
  ZLIB_HOME="$withval"
 
519
  AC_MSG_RESULT([using $ZLIB_HOME])
 
520
fi
 
521
], [
 
522
ZLIB_HOME=/usr/local
 
523
if test ! -f "$ZLIB_HOME/include/zlib.h"
 
524
then
 
525
  ZLIB_HOME=/usr
 
526
fi
 
527
AC_MSG_RESULT([$ZLIB_HOME])
 
528
])
 
529
 
 
530
CLAMDSCAN_LIBS="$FRESHCLAM_LIBS"
 
531
 
 
532
AC_ARG_ENABLE([zlib-vcheck],
 
533
[  --disable-zlib-vcheck          do not check for buggy zlib version ],
 
534
zlib_check=$enableval, zlib_check="yes")
 
535
 
 
536
if test ! -f "$ZLIB_HOME/include/zlib.h"
 
537
then
 
538
    AC_MSG_ERROR([Please install zlib and zlib-devel packages])
 
539
else
 
540
 
 
541
    vuln=`grep "ZLIB_VERSION \"1.2.0" $ZLIB_HOME/include/zlib.h`
 
542
    if test -z "$vuln"; then
 
543
        vuln=`grep "ZLIB_VERSION \"1.2.1" $ZLIB_HOME/include/zlib.h`
 
544
    fi
 
545
 
 
546
    if test -n "$vuln"; then
 
547
        if test "$zlib_check" = "yes"; then
 
548
            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!)
 
549
        else
 
550
            AC_MSG_WARN([****** This ClamAV installation may be linked against])
 
551
            AC_MSG_WARN([****** a broken zlib version. Please DO NOT report any])
 
552
            AC_MSG_WARN([****** stability problems to the ClamAV developers!])
 
553
        fi
 
554
    fi
 
555
 
 
556
    save_LIBS="$LIBS"
 
557
    if test "$ZLIB_HOME" != "/usr"; then
 
558
        CPPFLAGS="$CPPFLAGS -I$ZLIB_HOME/include"
 
559
        save_LDFLAGS="$LDFLAGS"
 
560
        LDFLAGS="$LDFLAGS -L$ZLIB_HOME/lib"
 
561
        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]))
 
562
        AC_CHECK_LIB([z], [gzopen], [], AC_MSG_ERROR([Your zlib is missing gzopen()]))
 
563
        LDFLAGS="$save_LDFLAGS"
 
564
    else
 
565
        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]))
 
566
        AC_CHECK_LIB([z], [gzopen],[], AC_MSG_ERROR([Your zlib is missing gzopen()]))
 
567
    fi
 
568
    LIBS="$save_LIBS"
 
569
fi
 
570
 
 
571
AC_ARG_ENABLE([bzip2],
 
572
[  --disable-bzip2        disable bzip2 support],
 
573
want_bzip2=$enableval, want_bzip2="yes")
 
574
 
 
575
bzip_check="ok"
 
576
if test "$want_bzip2" = "yes"
 
577
then
 
578
    AC_LIB_LINKFLAGS([bz2])
 
579
    save_LDFLAGS="$LDFLAGS"
 
580
    # Only add -L if prefix is not empty
 
581
    test -z "$LIBBZ2_PREFIX" || LDFLAGS="$LDFLAGS -L$LIBBZ2_PREFIX/$acl_libdirstem";
 
582
 
 
583
    have_bzprefix="no"
 
584
    AC_CHECK_LIB([bz2], [BZ2_bzDecompressInit], [have_bzprefix="yes"])
 
585
    if test "x$have_bzprefix" = "xno"; then
 
586
        AC_DEFINE([NOBZ2PREFIX],1,[bzip funtions do not have bz2 prefix])
 
587
    fi
 
588
    LDFLAGS="$save_LDFLAGS"
 
589
    if test "$HAVE_LIBBZ2" = "yes"; then
 
590
        AC_CHECK_HEADER([bzlib.h],
 
591
                        [AC_C_CVE_2008_1372],
 
592
                        [ac_cv_c_cve_2008_1372="no"])
 
593
        if test "$ac_cv_c_cve_2008_1372" = "bugged"; then
 
594
                AC_MSG_WARN([****** bzip2 libraries are affected by the CVE-2008-1372 bug])
 
595
                AC_MSG_WARN([****** We strongly suggest you to update to bzip2 1.0.5.])
 
596
                AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
 
597
                bzip_check="bugged (CVE-2008-1372)"
 
598
        fi
 
599
        if test "$ac_cv_c_cve_2008_1372" = "linkfailed"; then
 
600
                dnl This shouldn't happen
 
601
                dnl We failed to link but libtool may still be able to link, so don't disable bzip2 just yet
 
602
                AC_MSG_WARN([****** Unable to link bzip2 testcase])
 
603
                AC_MSG_WARN([****** You may be affected by CVE-2008-1372 bug, but I need to be able to link a testcase to verify])
 
604
                AC_MSG_WARN([****** It is recommended to fix your build environment so that we can run the testcase!])
 
605
                AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
 
606
                bzip_check="link failed (CVE-2008-1372)"
 
607
        fi
 
608
 
 
609
        case "$ac_cv_c_cve_2008_1372" in
 
610
        ok|bugged|linkfailed)
 
611
                ;;
 
612
        *)
 
613
                HAVE_LIBBZ2=no
 
614
                ;;
 
615
        esac
 
616
    fi
 
617
 
 
618
    if test "$HAVE_LIBBZ2" = "yes"; then
 
619
        AC_C_CVE_2010_0405
 
620
        if test "$ac_cv_c_cve_2010_0405" = "bugged"; then
 
621
                AC_MSG_WARN([****** bzip2 libraries are affected by the CVE-2010-0405 bug])
 
622
                AC_MSG_WARN([****** We strongly suggest you to update bzip2])
 
623
                AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
 
624
                bzip_check="bugged (CVE-2010-0405)"
 
625
        fi
 
626
        if test "$ac_cv_c_cve_2010_0405" = "linkfailed"; then
 
627
                dnl This shouldn't happen
 
628
                dnl We failed to link but libtool may still be able to link, so don't disable bzip2 just yet
 
629
                AC_MSG_WARN([****** Unable to link bzip2 testcase])
 
630
                AC_MSG_WARN([****** You may be affected by CVE-2010-0405 bug, but I need to be able to link a testcase to verify])
 
631
                AC_MSG_WARN([****** It is recommended to fix your build environment so that we can run the testcase!])
 
632
                AC_MSG_WARN([****** Please do not report stability problems to the ClamAV developers!])
 
633
                bzip_check="link failed (CVE-2010-0405)"
 
634
        fi
 
635
 
 
636
        case "$ac_cv_c_cve_2010_0405" in
 
637
        ok|bugged|linkfailed)
 
638
                LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS $LTLIBBZ2"
 
639
                AC_DEFINE([HAVE_BZLIB_H],1,[have bzip2])
 
640
                ;;
 
641
        *)
 
642
                AC_MSG_WARN([****** bzip2 support disabled])
 
643
                ;;
 
644
        esac
 
645
 
 
646
    else
 
647
        AC_MSG_WARN([****** bzip2 support disabled])
 
648
    fi
 
649
fi
 
650
 
 
651
AM_CONDITIONAL([HAVE_LIBBZ2], test "x$HAVE_LIBBZ2" = "xyes")
 
652
 
 
653
AC_ARG_ENABLE([unrar],
 
654
[  --disable-unrar        do not build libclamunrar and libclamunrar_iface ],
 
655
want_unrar=$enableval, want_unrar="yes")
 
656
AM_CONDITIONAL([ENABLE_UNRAR],[test "$want_unrar" = "yes"])
 
657
 
 
658
dnl libxml2
 
659
want_xml="auto"
 
660
AC_ARG_ENABLE([xml],
 
661
[  --disable-xml          disable DMG and XAR support],
 
662
want_xml=$enableval, want_xml="auto")
 
663
 
 
664
XML_HOME=""
 
665
if test "X$want_xml" != "Xno"; then
 
666
  AC_MSG_CHECKING([for libxml2 installation])
 
667
  AC_ARG_WITH([xml],
 
668
  [  --with-xml=DIR       path to directory containing libxml2 library (default=
 
669
                          /usr/local or /usr if not found in /usr/local)],
 
670
  [
 
671
  if test "$withval"
 
672
  then
 
673
    XML_HOME="$withval"
 
674
    AC_MSG_RESULT([using $XML_HOME])
 
675
  else
 
676
    AC_MSG_ERROR([cannot assign blank value to --with-xml])
 
677
  fi
 
678
  ], [
 
679
  XML_HOME=/usr/local
 
680
  if test ! -x "$XML_HOME/bin/xml2-config"
 
681
  then
 
682
    XML_HOME=/usr
 
683
    if test ! -x "$XML_HOME/bin/xml2-config"
 
684
    then
 
685
      XML_HOME=""
 
686
    fi
 
687
  fi
 
688
  if test "x$XML_HOME" != "x"; then
 
689
    AC_MSG_RESULT([$XML_HOME])
 
690
  else
 
691
    AC_MSG_RESULT([not found])
 
692
  fi
 
693
  ])
 
694
fi
 
695
 
 
696
found_xml="no"
 
697
XMLCONF_VERSION=""
 
698
XML_CPPFLAGS=""
 
699
XML_LIBS=""
 
700
if test "x$XML_HOME" != "x"; then
 
701
  AC_MSG_CHECKING([xml2-config version])
 
702
  XMLCONF_VERSION="`$XML_HOME/bin/xml2-config --version`"
 
703
  if test "x%XMLCONF_VERSION" != "x"; then
 
704
    AC_MSG_RESULT([$XMLCONF_VERSION])
 
705
    found_xml="yes"
 
706
    XML_CPPFLAGS="`$XML_HOME/bin/xml2-config --cflags`"
 
707
    XML_LIBS="`$XML_HOME/bin/xml2-config --libs`"
 
708
  else
 
709
    AC_MSG_ERROR([xml2-config failed])
 
710
  fi
 
711
fi
 
712
 
 
713
working_xml="no"
 
714
if test "X$found_xml" != "Xno"; then
 
715
  AC_MSG_CHECKING([for xmlreader.h in $XML_HOME])
 
716
 
 
717
  if test ! -f "$XML_HOME/include/libxml2/libxml/xmlreader.h"; then
 
718
    AC_MSG_RESULT([not found])
 
719
  else
 
720
    AC_MSG_RESULT([found])
 
721
    save_LIBS="$LIBS"
 
722
    save_CPPFLAGS="$CPPFLAGS"
 
723
    CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
 
724
    save_LDFLAGS="$LDFLAGS"
 
725
    LDFLAGS="$LDFLAGS $XML_LIBS"
 
726
 
 
727
    AC_CHECK_LIB([xml2], [xmlTextReaderRead], [working_xml="yes"], [working_xml="no"])
 
728
 
 
729
    CPPFLAGS="$save_CPPFLAGS"
 
730
    LDFLAGS="$save_LDFLAGS"
 
731
    LIBS="$save_LIBS"
 
732
  fi
 
733
fi
 
734
 
 
735
if test "$working_xml" = "yes"; then
 
736
  AC_DEFINE([HAVE_LIBXML2],1,[Define to 1 if you have the 'libxml2' library (-lxml2).])
 
737
  AC_SUBST(XML_CPPFLAGS)
 
738
  AC_SUBST(XML_LIBS)
 
739
  AC_MSG_NOTICE([Compiling and linking with libxml2 from $XML_HOME])
 
740
else
 
741
  if test "$want_xml" = "yes"; then
 
742
     AC_MSG_ERROR([****** Please install libxml2 packages!])
 
743
  else
 
744
    if test "$want_xml" != "no"; then
 
745
      AC_MSG_NOTICE([****** libxml2 support unavailable])
 
746
    fi
 
747
  fi
 
748
  XML_CPPFLAGS=""
 
749
  XML_LIBS=""
 
750
  AC_SUBST(XML_CPPFLAGS)
 
751
  AC_SUBST(XML_LIBS)
 
752
fi
 
753
 
 
754
AC_ARG_ENABLE([getaddrinfo],
 
755
[  --disable-getaddrinfo          disable support for getaddrinfo],
 
756
want_getaddrinfo=$enableval, want_getaddrinfo="yes")
 
757
 
 
758
if test "$want_getaddrinfo" = "yes"
 
759
then
 
760
    AC_MSG_CHECKING([for getaddrinfo])
 
761
    AC_CACHE_VAL([have_cv_gai],[
 
762
                AC_TRY_RUN([
 
763
                    #include <sys/types.h>
 
764
                    #include <sys/socket.h>
 
765
                    #include <netdb.h>
 
766
                    #include <unistd.h>
 
767
                    int main(int argc, char **argv)
 
768
                    {
 
769
                            struct addrinfo *res;
 
770
                            int sd;
 
771
 
 
772
                        if(getaddrinfo("127.0.0.1", NULL, NULL, &res) < 0)
 
773
                            return 1;
 
774
                        freeaddrinfo(res);
 
775
 
 
776
                        return 0;
 
777
                    }
 
778
                ],
 
779
                [have_cv_gai=yes],
 
780
                [have_cv_gai=no],
 
781
                [have_cv_gai=no])
 
782
                ])
 
783
    AC_MSG_RESULT([$have_cv_gai])
 
784
    if test "$have_cv_gai" = yes; then
 
785
        AC_DEFINE(HAVE_GETADDRINFO, 1, [have getaddrinfo()])
 
786
    fi
 
787
fi
 
788
 
 
789
AC_ARG_ENABLE([ipv6],
 
790
[  --disable-ipv6          disable IPv6 support],
 
791
want_ipv6=$enableval, want_ipv6="yes")
 
792
 
 
793
if test "$want_ipv6" = "yes"
 
794
then
 
795
    AC_MSG_CHECKING([for IPv6 support])
 
796
    AC_CACHE_VAL([have_cv_ipv6],[
 
797
                AC_TRY_RUN([
 
798
                    #include <sys/types.h>
 
799
                    #include <sys/socket.h>
 
800
                    #include <netdb.h>
 
801
                    #include <unistd.h>
 
802
                    int main(int argc, char **argv)
 
803
                    {
 
804
                            struct addrinfo *res, hints;
 
805
                            int sd;
 
806
 
 
807
                        if((sd = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
 
808
                            return 1;
 
809
                        close(sd);
 
810
                        /* also check if getaddrinfo() handles AF_UNSPEC -- bb#1196 */
 
811
                        memset(&hints, 0, sizeof(hints));
 
812
                        hints.ai_family = AF_UNSPEC;
 
813
                        if(getaddrinfo("127.0.0.1", NULL, &hints, &res) < 0)
 
814
                            return 1;
 
815
                        freeaddrinfo(res);
 
816
                        return 0;
 
817
                    }
 
818
                ],
 
819
                [have_cv_ipv6=yes],
 
820
                [have_cv_ipv6=no],
 
821
                [have_cv_ipv6=no])
 
822
                ])
 
823
    AC_MSG_RESULT([$have_cv_ipv6])
 
824
    if test "$have_cv_ipv6" = yes; then
 
825
        AC_DEFINE(SUPPORT_IPv6, 1, [Support for IPv6])
 
826
    fi
 
827
fi
 
828
 
 
829
AC_C_DNS
 
830
 
 
831
AC_ARG_ENABLE([fanotify],
 
832
[  --disable-fanotify     disable fanotify support (Linux only)],
 
833
want_fanotify=$enableval, want_fanotify="yes")
 
834
 
 
835
dnl AC_FUNC_SETPGRP does not work when cross compiling
 
836
dnl Instead, assume we will have a prototype for setpgrp if cross compiling.
 
837
dnl testcase from gdb/configure.ac
 
838
if test "$cross_compiling" = no; then
 
839
 AC_FUNC_SETPGRP
 
840
else
 
841
 AC_CACHE_CHECK([whether setpgrp takes no argument], [ac_cv_func_setpgrp_void],
 
842
   [AC_TRY_COMPILE([
 
843
#include <unistd.h>
 
844
], [
 
845
 if (setpgrp(1,1) == -1)
 
846
   exit (0);
 
847
 else
 
848
   exit (1);
 
849
], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes)])
 
850
if test $ac_cv_func_setpgrp_void = yes; then
 
851
 AC_DEFINE([SETPGRP_VOID], 1)
 
852
fi
 
853
fi
 
854
 
 
855
AC_ARG_ENABLE([milter],
 
856
[  --enable-milter        build clamav-milter],
 
857
have_milter=$enableval, have_milter="no")
 
858
 
 
859
dnl we need to try to link with iconv, otherwise there could be a 
 
860
dnl mismatch between a 32-bit and 64-bit lib. Detect this at configure time.
 
861
dnl we need to check after zlib/bzip2, because they can change the include path
 
862
AC_ARG_WITH([iconv], [  --with-iconv supports iconv() (default=auto)],
 
863
[
 
864
 case "$withval" in
 
865
         yes|no) wiconv="$withval";;
 
866
         *) AC_MSG_ERROR([--with-iconv does not take an argument]);;
 
867
 esac],
 
868
[ wiconv=auto ])
 
869
if test "X$wiconv" != "Xno"; then
 
870
        AC_CHECK_LIB([iconv], [libiconv_open], LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -liconv")
 
871
        AC_MSG_CHECKING([for iconv])
 
872
        save_LIBS="$LIBS"
 
873
        LIBS="$LIBCLAMAV_LIBS"
 
874
        AC_TRY_LINK([
 
875
                     #include <iconv.h>
 
876
        ],[
 
877
        char** xin,**xout;
 
878
        unsigned long il,ol;
 
879
        int rc;
 
880
        iconv_t iconv_struct = iconv_open("UTF-16BE","UTF-8");
 
881
        rc = iconv(iconv_struct,xin,&il,xout,&ol);
 
882
        iconv_close(iconv_struct);
 
883
],[
 
884
   AC_MSG_RESULT(yes)
 
885
   AC_DEFINE([HAVE_ICONV], 1, [iconv() available])
 
886
],[
 
887
        AC_MSG_RESULT(no)
 
888
])
 
889
        LIBS="$save_LIBS"
 
890
fi
 
891
 
 
892
AC_ARG_ENABLE([pthreads],
 
893
[  --disable-pthreads      disable POSIX threads support],
 
894
have_pthreads=$enableval,)
 
895
 
 
896
AC_ARG_ENABLE([cr],
 
897
[  --disable-cr           do not link with C reentrant library (BSD) ],
 
898
use_cr=$enableval,)
 
899
 
 
900
AC_ARG_ENABLE([id-check],
 
901
[  --enable-id-check      use id utility instead of /etc/passwd parsing],
 
902
use_id=$enableval, use_id="no")
 
903
 
 
904
AC_ARG_ENABLE([yp-check],
 
905
[  --enable-yp-check      use ypmatch utility instead of /etc/passwd parsing],
 
906
use_yp=$enableval, use_yp="no")
 
907
 
 
908
AC_ARG_WITH([user], 
 
909
[  --with-user=uid        name of the clamav user (default=clamav)],
 
910
clamav_user="$withval", clamav_user="clamav")
 
911
 
 
912
AC_ARG_WITH([group], 
 
913
[  --with-group=gid       name of the clamav group (default=clamav)],
 
914
clamav_group="$withval", clamav_group="clamav")
 
915
 
 
916
AC_DEFINE_UNQUOTED([CLAMAVUSER],"$clamav_user",[name of the clamav user])
 
917
AC_DEFINE_UNQUOTED([CLAMAVGROUP],"$clamav_group",[name of the clamav group])
 
918
 
 
919
AC_ARG_ENABLE([clamav],
 
920
[  --disable-clamav       disable test for clamav user/group],
 
921
test_clamav=$enableval, test_clamav=yes)
 
922
 
 
923
AC_ARG_ENABLE([debug],
 
924
[  --enable-debug         enable debug code],
 
925
enable_debug=$enableval, enable_debug="no")
 
926
 
 
927
if test "$enable_debug" = "yes"; then
 
928
  VERSION_SUFFIX="$VERSION_SUFFIX-debug"
 
929
  AC_DEFINE([CL_DEBUG],1,[enable debugging])
 
930
else
 
931
  AC_DEFINE([NDEBUG],1,[disable assertions])
 
932
fi
 
933
 
 
934
AC_ARG_WITH([version], 
 
935
[  --with-version=STR    use custom version string (dev only)],
 
936
VERSION="$withval", )
 
937
 
 
938
AC_ARG_ENABLE([no-cache],
 
939
[  --enable-no-cache      use "Cache-Control: no-cache" in freshclam],
 
940
enable_nocache=$enableval, enable_nocache="no")
 
941
 
 
942
if test "$enable_nocache" = "yes"; then
 
943
  AC_DEFINE([FRESHCLAM_NO_CACHE],1,[use "Cache-Control: no-cache" in freshclam])
 
944
fi
 
945
 
 
946
AC_ARG_ENABLE([dns-fix],
 
947
[  --enable-dns-fix       enable workaround for broken DNS servers (as in SpeedTouch 510)],
 
948
enable_dnsfix=$enableval, enable_dnsfix="no")
 
949
 
 
950
if test "$enable_dnsfix" = "yes"; then
 
951
  AC_DEFINE([FRESHCLAM_DNS_FIX],1,[enable workaround for broken DNS servers])
 
952
fi
 
953
 
 
954
AC_ARG_ENABLE([bigstack],
 
955
[  --enable-bigstack      increase thread stack size],
 
956
enable_bigstack=$enableval, enable_bigstack="no")
 
957
 
 
958
if test "$enable_bigstack" = "yes"; then
 
959
  AC_DEFINE([C_BIGSTACK],1,[Increase thread stack size.])
 
960
fi
 
961
 
 
962
AC_ARG_WITH([dbdir], 
 
963
[  --with-dbdir=path      path to virus database directory],
 
964
db_dir="$withval", db_dir="_default_")
 
965
 
 
966
dnl I had problems with $pkgdatadir thus these funny checks
 
967
if test "$db_dir" = "_default_"
 
968
then
 
969
    if test "$prefix" = "NONE"
 
970
    then
 
971
        db_dir="$ac_default_prefix/share/clamav"
 
972
    else
 
973
        db_dir="$prefix/share/clamav"
 
974
    fi
 
975
fi
 
976
 
 
977
AC_DEFINE_UNQUOTED([DATADIR],"$db_dir", [Path to virus database directory.])
 
978
DBDIR="$db_dir"
 
979
AC_SUBST([DBDIR])
 
980
 
 
981
dnl configure config directory
 
982
cfg_dir=`echo $sysconfdir | grep prefix`
 
983
 
 
984
if test -n "$cfg_dir"; then
 
985
    if test "$prefix" = "NONE"
 
986
    then
 
987
        cfg_dir="$ac_default_prefix/etc"
 
988
    else
 
989
        cfg_dir="$prefix/etc"
 
990
    fi
 
991
else
 
992
    cfg_dir="$sysconfdir"
 
993
fi
 
994
 
 
995
CFGDIR=$cfg_dir
 
996
AC_SUBST([CFGDIR])
 
997
AC_DEFINE_UNQUOTED([CONFDIR],"$cfg_dir",[where to look for the config file])
 
998
 
 
999
dnl check for in_port_t definition
 
1000
AC_MSG_CHECKING([whether in_port_t is defined])
 
1001
AC_TRY_COMPILE([
 
1002
#include <sys/types.h>
 
1003
#include <netinet/in.h>
 
1004
],
 
1005
[in_port_t pt; pt = 0; return pt;],
 
1006
[
 
1007
    AC_MSG_RESULT(yes)
 
1008
    AC_DEFINE([HAVE_IN_PORT_T],1,[in_port_t is defined])
 
1009
],
 
1010
AC_MSG_RESULT(no))
 
1011
 
 
1012
dnl check for in_addr_t definition
 
1013
AC_MSG_CHECKING([for in_addr_t definition])
 
1014
AC_TRY_COMPILE([
 
1015
#include <sys/types.h>
 
1016
#include <netinet/in.h>
 
1017
],
 
1018
[ in_addr_t pt; pt = 0; return pt; ],
 
1019
[
 
1020
    AC_MSG_RESULT(yes)
 
1021
    AC_DEFINE([HAVE_IN_ADDR_T],1,[in_addr_t is defined])
 
1022
],
 
1023
AC_MSG_RESULT(no))
 
1024
 
 
1025
case "$target_os" in
 
1026
linux*)
 
1027
    AC_DEFINE([C_LINUX],1,[target is linux])
 
1028
    if test "$have_pthreads" = "yes"; then
 
1029
        THREAD_LIBS="-lpthread"
 
1030
        TH_SAFE="-thread-safe"
 
1031
        if test "$want_fanotify" = "yes"; then
 
1032
            AC_CHECK_HEADER([linux/fanotify.h],AC_DEFINE([FANOTIFY],1,[use fanotify]),)
 
1033
        fi
 
1034
    fi
 
1035
    ;;
 
1036
kfreebsd*-gnu)
 
1037
    AC_DEFINE([C_KFREEBSD_GNU],1,[target is kfreebsd-gnu])
 
1038
    if test "$have_pthreads" = "yes"; then
 
1039
       THREAD_LIBS="-lpthread"
 
1040
       TH_SAFE="-thread-safe"
 
1041
    fi
 
1042
    ;;
 
1043
solaris*)
 
1044
    CLAMDSCAN_LIBS="$CLAMDSCAN_LIBS -lresolv"
 
1045
    FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lresolv"
 
1046
    if test "$have_pthreads" = "yes"; then
 
1047
        THREAD_LIBS="-lpthread"
 
1048
        CLAMD_LIBS="$CLAMD_LIBS -lresolv"
 
1049
        CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lresolv"
 
1050
        TH_SAFE="-thread-safe"
 
1051
    fi
 
1052
    AC_DEFINE([C_SOLARIS],1,[os is solaris])
 
1053
    ;;
 
1054
freebsd[[45]]*)
 
1055
    if test "$have_pthreads" = "yes"; then
 
1056
        THREAD_LIBS="-pthread -lc_r"
 
1057
        TH_SAFE="-thread-safe"
 
1058
    fi
 
1059
    AC_DEFINE([C_BSD],1,[os is freebsd 4 or 5])
 
1060
    ;;
 
1061
freebsd*)
 
1062
    if test "$have_pthreads" = "yes"; then
 
1063
        THREAD_LIBS="-lthr"
 
1064
        TH_SAFE="-thread-safe"
 
1065
    fi
 
1066
    AC_DEFINE([C_BSD],1,[os is freebsd 6])
 
1067
    ;;
 
1068
dragonfly*)
 
1069
    if test "$have_pthreads" = "yes"; then
 
1070
        THREAD_LIBS="-pthread"
 
1071
        TH_SAFE="-thread-safe"
 
1072
    fi
 
1073
    AC_DEFINE([C_BSD],1,[os is dragonfly])
 
1074
    ;;
 
1075
openbsd*)
 
1076
    if test "$have_pthreads" = "yes"; then
 
1077
        THREAD_LIBS="-pthread"
 
1078
        CLAMD_LIBS="$CLAMD_LIBS -pthread"
 
1079
        CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -pthread"
 
1080
        TH_SAFE="-thread-safe"
 
1081
    fi
 
1082
    AC_DEFINE([C_BSD],1,[os is OpenBSD])
 
1083
    ;;
 
1084
bsdi*)
 
1085
    if test "$have_pthreads" = "yes"; then
 
1086
        THREAD_LIBS="-pthread"
 
1087
        TH_SAFE="-thread-safe"
 
1088
    fi
 
1089
    AC_DEFINE([C_BSD],1,[os is BSDI BSD/OS])
 
1090
    ;;
 
1091
netbsd*)
 
1092
     if test "$have_pthreads" = "yes"; then
 
1093
        THREAD_LIBS="-lpthread"
 
1094
     fi
 
1095
    AC_DEFINE([C_BSD],1,[os is NetBSD])
 
1096
    ;;
 
1097
bsd*)
 
1098
    AC_MSG_RESULT([Unknown BSD detected. Disabling thread support.])
 
1099
    have_pthreads="no"
 
1100
    AC_DEFINE([C_BSD],1,[os is bsd flavor])
 
1101
    ;;
 
1102
beos*)
 
1103
    AC_MSG_RESULT([BeOS detected. Disabling thread support.])
 
1104
    have_pthreads="no"
 
1105
    AC_DEFINE([C_BEOS],1,[os is beos])
 
1106
    ;;
 
1107
x86:Interix*)
 
1108
    AC_DEFINE([C_INTERIX],1,[os is Interix])
 
1109
    ;;
 
1110
darwin*)
 
1111
    AC_DEFINE([C_BSD],1,[os is bsd flavor])
 
1112
    AC_DEFINE([C_DARWIN],1,[os is darwin])
 
1113
    AC_DEFINE([BIND_8_COMPAT],1,[enable bind8 compatibility])
 
1114
    AC_DEFINE([CLAMAUTH],1,[use ClamAuth])
 
1115
    use_netinfo="yes"
 
1116
    ;;
 
1117
os2*)
 
1118
    CLAMDSCAN_LIBS="$CLAMDSCAN_LIBS -lsyslog"
 
1119
    FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lsyslog"
 
1120
    CLAMD_LIBS="$CLAMD_LIBS -lsyslog"
 
1121
    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsyslog"
 
1122
    if test "$have_pthreads" = "yes"; then
 
1123
        THREAD_LIBS="-lpthread"
 
1124
        TH_SAFE="-thread-safe"
 
1125
    fi
 
1126
    AC_DEFINE([C_OS2],1,[os is OS/2])
 
1127
    ;;
 
1128
sco*)
 
1129
    dnl njh@bandsman.sco.uk: SCO Unix port
 
1130
    dnl FRESHCLAM_LIBS="-lsocket"
 
1131
    dnl CLAMD_LIBS="-lsocket"
 
1132
    dnl CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsocket"
 
1133
    ;;
 
1134
hpux*)
 
1135
    if test "$have_pthreads" = "yes"; then
 
1136
        THREAD_LIBS="-lpthread"
 
1137
        TH_SAFE="-thread-safe"
 
1138
    fi
 
1139
    AC_DEFINE([C_HPUX],1,[os is hpux])
 
1140
    if test "$have_mempool" = "yes"; then
 
1141
        LDFLAGS="$LDFLAGS -Wl,+pd,1M"
 
1142
    fi
 
1143
    ;;
 
1144
aix*)
 
1145
    if test "$have_pthreads" = "yes"; then
 
1146
        THREAD_LIBS="-lpthread"
 
1147
        TH_SAFE="-thread-safe"
 
1148
        AC_DEFINE([_THREAD_SAFE],1,[thread safe])
 
1149
    fi
 
1150
    AC_DEFINE([C_AIX],1,[os is aix])
 
1151
    ;;
 
1152
*-*-osf*)
 
1153
    if test "$have_pthreads" = "yes"; then
 
1154
        THREAD_LIBS="-pthread"
 
1155
        TH_SAFE="-thread-safe"
 
1156
        AC_DEFINE([_POSIX_PII_SOCKET],1,[POSIX compatibility])
 
1157
    fi
 
1158
    AC_DEFINE([C_OSF],1,[os is osf/tru64])
 
1159
    ;;
 
1160
nto-qnx*)
 
1161
    AC_DEFINE([C_QNX6],1,[os is QNX 6.x.x])
 
1162
    ;;
 
1163
irix*)
 
1164
    if test "$have_pthreads" = "yes"; then
 
1165
        THREAD_LIBS="-lpthread"
 
1166
        TH_SAFE="-thread-safe"
 
1167
    fi
 
1168
    LIBS="$LIBS -lgen"
 
1169
    AC_DEFINE([C_IRIX],1,[os is irix])
 
1170
    ;;
 
1171
interix*)
 
1172
    AC_DEFINE([C_INTERIX],1,[os is interix])
 
1173
    if test "$test_clamav" = "yes"; then
 
1174
        if test ! -r /etc/passwd; then
 
1175
           test_clamav="no"
 
1176
        fi
 
1177
    fi
 
1178
    if test "$have_pthreads" = "yes"; then
 
1179
        THREAD_LIBS="-lpthread"
 
1180
        TH_SAFE="-thread-safe"
 
1181
    fi
 
1182
    ;;
 
1183
gnu*)
 
1184
    AC_DEFINE([C_GNU_HURD],1,[target is gnu-hurd])
 
1185
    if test "$have_pthreads" = "yes"; then
 
1186
       THREAD_LIBS="-lpthread"
 
1187
       TH_SAFE="-thread-safe"
 
1188
    fi
 
1189
    ;;
 
1190
*)
 
1191
    ;;
 
1192
esac
 
1193
 
 
1194
AC_SUBST([LIBCLAMAV_LIBS])
 
1195
AC_SUBST([CLAMD_LIBS])
 
1196
AC_SUBST([CLAMAV_MILTER_LIBS])
 
1197
AC_SUBST([FRESHCLAM_LIBS])
 
1198
AC_SUBST([CLAMDSCAN_LIBS])
 
1199
AC_SUBST([TH_SAFE])
 
1200
AC_SUBST([THREAD_LIBS])
 
1201
 
 
1202
dnl --enable-milter
 
1203
if test "$have_milter" = "yes"; then
 
1204
    dnl libmilter checking code adapted from spamass-milter by
 
1205
    dnl Tom G. Christensen <tgc@statsbiblioteket.dk>
 
1206
 
 
1207
    dnl Check for libmilter and it's header files in the usual locations
 
1208
    save_LIBS="$LIBS"
 
1209
    CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread"
 
1210
    if test -d /usr/lib/libmilter ; then
 
1211
        CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -L/usr/lib/libmilter"
 
1212
    fi
 
1213
    LIBS="$LIBS -lmilter $CLAMAV_MILTER_LIBS"
 
1214
    AC_CHECK_LIB([milter],[mi_stop],[CLAMAV_MILTER_LIBS="-lmilter $CLAMAV_MILTER_LIBS"],[
 
1215
        dnl Older sendmails require libsm or libsmutil for support functions
 
1216
        AC_SEARCH_LIBS([strlcpy], [sm smutil], [test "$ac_cv_search_strlcpy" = "none required" || CLAMAV_MILTER_XLIB="$ac_cv_search_strlcpy"])
 
1217
        LIBS="$save_LIBS $CLAMAV_MILTER_LIBS $CLAMAV_MILTER_XLIB"
 
1218
        $as_unset ac_cv_lib_milter_mi_stop
 
1219
        AC_CHECK_LIB([milter],[mi_stop],[CLAMAV_MILTER_LIBS="-lmilter $CLAMAV_MILTER_XLIB $CLAMAV_MILTER_LIBS"],[
 
1220
            AC_MSG_ERROR([Cannot find libmilter])
 
1221
        ])
 
1222
    ])
 
1223
    LIBS="$save_LIBS"
 
1224
    AC_CHECK_HEADERS([libmilter/mfapi.h],[have_milter="yes"],[
 
1225
        AC_MSG_ERROR([Please install mfapi.h from the sendmail distribution])
 
1226
    ])
 
1227
fi
 
1228
 
 
1229
AM_CONDITIONAL([BUILD_CLAMD],[test "$have_pthreads" = "yes"])
 
1230
AM_CONDITIONAL([HAVE_MILTER],[test "$have_milter" = "yes"])
 
1231
 
 
1232
if test "$have_pthreads" = "yes"
 
1233
then
 
1234
    save_LIBS="$LIBS"
 
1235
    LIBS="$THREAD_LIBS $LIBS"
 
1236
    AC_CHECK_FUNCS([sched_yield pthread_yield])
 
1237
    LIBS="$save_LIBS"
 
1238
    AC_DEFINE([BUILD_CLAMD], 1, "build clamd")
 
1239
    dnl define these here, so we don't forget any system
 
1240
    AC_DEFINE([CL_THREAD_SAFE],1,[thread safe])
 
1241
    AC_DEFINE([_REENTRANT],1,[thread safe])
 
1242
fi
 
1243
 
 
1244
AC_CHECK_FUNCS([enable_extended_FILE_stdio])
 
1245
 
 
1246
dnl Check for readdir_r and number of its arguments
 
1247
dnl Code from libwww/configure.in
 
1248
 
 
1249
AC_MSG_CHECKING([for readdir_r])
 
1250
if test -z "$ac_cv_readdir_args"; then
 
1251
    AC_TRY_COMPILE(
 
1252
    [
 
1253
#include <sys/types.h>
 
1254
#include <dirent.h>
 
1255
    ],
 
1256
    [
 
1257
    struct dirent dir, *dirp;
 
1258
    DIR *mydir;
 
1259
    dirp = readdir_r(mydir, &dir);
 
1260
    ], ac_cv_readdir_args=2)
 
1261
fi
 
1262
if test -z "$ac_cv_readdir_args"; then
 
1263
    AC_TRY_COMPILE(
 
1264
        [
 
1265
#include <sys/types.h>
 
1266
#include <dirent.h>
 
1267
    ],
 
1268
    [
 
1269
        struct dirent dir, *dirp;
 
1270
        DIR *mydir;
 
1271
        int rc;
 
1272
        rc = readdir_r(mydir, &dir, &dirp);
 
1273
    ], ac_cv_readdir_args=3)
 
1274
fi
 
1275
 
 
1276
AC_ARG_ENABLE([readdir_r],
 
1277
[  --enable-readdir_r               enable support for readdir_r],
 
1278
enable_readdir_r=$enableval, enable_readdir_r="no")
 
1279
 
 
1280
if test "$enable_readdir_r" = "no"; then
 
1281
    AC_MSG_RESULT(support disabled)
 
1282
elif test -z "$ac_cv_readdir_args"; then
 
1283
    AC_MSG_RESULT(no)
 
1284
else
 
1285
    if test "$ac_cv_readdir_args" = 2; then
 
1286
        AC_DEFINE([HAVE_READDIR_R_2],1,[readdir_r takes 2 arguments])
 
1287
    elif test "$ac_cv_readdir_args" = 3; then
 
1288
        AC_DEFINE([HAVE_READDIR_R_3],1,[readdir_r takes 3 arguments])
 
1289
    fi
 
1290
    AC_MSG_RESULT([yes, and it takes $ac_cv_readdir_args arguments])
 
1291
fi
 
1292
 
 
1293
AC_MSG_CHECKING([for ctime_r])
 
1294
if test "$ac_cv_func_ctime_r" = "yes"; then
 
1295
    AC_TRY_COMPILE([
 
1296
        #include <time.h>
 
1297
    ],[
 
1298
        char buf[31];
 
1299
        time_t t;
 
1300
        ctime_r(&t, buf, 30);
 
1301
    ],[
 
1302
        ac_cv_ctime_args=3
 
1303
        AC_DEFINE([HAVE_CTIME_R_3],1,[ctime_r takes 3 arguments])
 
1304
    ],[
 
1305
        ac_cv_ctime_args=2
 
1306
        AC_DEFINE([HAVE_CTIME_R_2],1,[ctime_r takes 2 arguments])
 
1307
    ])
 
1308
 
 
1309
    AC_MSG_RESULT([yes, and it takes $ac_cv_ctime_args arguments])
 
1310
fi
 
1311
 
 
1312
dnl Determine socklen_t type. Code from lftp.
 
1313
AC_MSG_CHECKING([for socklen_t])
 
1314
AC_CACHE_VAL([ac_cv_socklen_t],
 
1315
[
 
1316
    ac_cv_socklen_t=no
 
1317
    AC_TRY_COMPILE([
 
1318
        #include <sys/types.h>
 
1319
        #include <sys/socket.h>
 
1320
    ],
 
1321
    [
 
1322
        socklen_t len;
 
1323
        getpeername(0,0,&len);
 
1324
    ],
 
1325
    [
 
1326
        ac_cv_socklen_t=yes
 
1327
    ])
 
1328
])
 
1329
AC_MSG_RESULT([$ac_cv_socklen_t])
 
1330
    if test $ac_cv_socklen_t = no; then
 
1331
    AC_MSG_CHECKING([for socklen_t equivalent])
 
1332
    AC_CACHE_VAL([ac_cv_socklen_t_equiv],
 
1333
    [
 
1334
        ac_cv_socklen_t_equiv=int
 
1335
        for t in int size_t unsigned long "unsigned long"; do
 
1336
            AC_TRY_COMPILE([
 
1337
                #include <sys/types.h>
 
1338
                #include <sys/socket.h>
 
1339
            ],
 
1340
            [
 
1341
                $t len;
 
1342
                getpeername(0,0,&len);
 
1343
            ],
 
1344
            [
 
1345
                ac_cv_socklen_t_equiv="$t"
 
1346
                break
 
1347
            ])
 
1348
        done
 
1349
    ])
 
1350
    AC_MSG_RESULT([$ac_cv_socklen_t_equiv])
 
1351
    AC_DEFINE_UNQUOTED([socklen_t], $ac_cv_socklen_t_equiv, [Define to "int" if <sys/socket.h> does not define.])
 
1352
fi
 
1353
 
 
1354
dnl Check for clamav in /etc/passwd
 
1355
if test "$test_clamav" = "yes"
 
1356
then
 
1357
    dnl parse /etc/passwd
 
1358
    if test "$use_id" = "no"
 
1359
    then
 
1360
        AC_MSG_CHECKING([for $clamav_user in /etc/passwd])
 
1361
        if test -r /etc/passwd; then
 
1362
            clamavuser=`cat /etc/passwd|grep "^$clamav_user:"`
 
1363
            clamavgroup=`cat /etc/group|grep "^$clamav_group:"`
 
1364
        fi
 
1365
    else
 
1366
        AC_MSG_CHECKING([for $clamav_user using id])
 
1367
        id $clamav_user > /dev/null 2>&1
 
1368
        if test "$?" = 0 ; then
 
1369
            clamavuser=1
 
1370
            AC_PATH_PROG(GETENT, getent)
 
1371
            if test -n "$GETENT" ; then
 
1372
                clamavgroup=`$GETENT group | grep "^${clamav_group}:"`
 
1373
            else
 
1374
                clamavgroup=`cat /etc/group|grep $clamav_group`
 
1375
            fi
 
1376
        fi
 
1377
    fi
 
1378
 
 
1379
    if test "$use_netinfo" = "yes"
 
1380
    then
 
1381
        if test -x /usr/bin/dscl; then
 
1382
            AC_MSG_CHECKING([for $clamav_user using dscl])
 
1383
            clamavuser=`/usr/bin/dscl . -list /Users |grep ${clamav_user}`
 
1384
            clamavgroup=`/usr/bin/dscl . -list /Groups |grep ${clamav_group}`
 
1385
        else
 
1386
            AC_MSG_CHECKING([for $clamav_user using netinfo])
 
1387
            clamavuser=`/usr/bin/nidump passwd . |grep ${clamav_user}`
 
1388
            clamavgroup=`/usr/bin/nidump group . |grep ${clamav_group}`
 
1389
        fi
 
1390
    fi
 
1391
 
 
1392
    if test "$use_yp" = "yes"
 
1393
    then
 
1394
        AC_MSG_CHECKING([for $clamav_user using ypmatch])
 
1395
        clamavuser=`ypmatch ${clamav_user} passwd`
 
1396
        clamavgroup=`ypmatch ${clamav_group} group`
 
1397
    fi
 
1398
 
 
1399
    if test -z "$clamavuser" || test -z "$clamavgroup"
 
1400
    then
 
1401
        AC_MSG_RESULT(no)
 
1402
        AC_MSG_ERROR([User $clamav_user (and/or group $clamav_group) does not exist. Please read the documentation !])
 
1403
    else
 
1404
        AC_MSG_RESULT([yes, user $clamav_user and group $clamav_group])
 
1405
        CLAMAVUSER="$clamav_user"
 
1406
        CLAMAVGROUP="$clamav_group"
 
1407
        AC_SUBST([CLAMAVUSER])
 
1408
        AC_SUBST([CLAMAVGROUP])
 
1409
    fi
 
1410
fi
 
1411
 
 
1412
dnl check for __attribute__((packed))
 
1413
dnl but only on compilers claiming to be gcc compatible
 
1414
dnl because for example Sun's compiler silently ignores the packed attribute.
 
1415
AC_MSG_CHECKING([for structure packing via __attribute__((packed))])
 
1416
AC_CACHE_VAL([have_cv_attrib_packed],[
 
1417
        AC_TRY_COMPILE(,
 
1418
                [#ifdef __GNUC__
 
1419
                 struct { int i __attribute__((packed)); } s;
 
1420
                 #else
 
1421
                 #error Only checking for packed attribute on gcc-like compilers
 
1422
                 #endif],
 
1423
                [have_cv_attrib_packed=yes],
 
1424
                [have_cv_attrib_packed=no])
 
1425
        ])
 
1426
AC_MSG_RESULT([$have_cv_attrib_packed])
 
1427
 
 
1428
if test "$have_cv_attrib_packed" = no; then
 
1429
        AC_MSG_CHECKING([for structure packing via pragma])
 
1430
        AC_CACHE_VAL([have_cv_pragma_pack],[
 
1431
                AC_TRY_RUN([
 
1432
                            int main(int argc, char **argv) {
 
1433
#pragma pack(1)                 /* has to be in column 1 ! */
 
1434
                        struct { char c; long l; } s;
 
1435
                        return sizeof(s)==sizeof(s.c)+sizeof(s.l) ? 0:1; } ],
 
1436
                        [have_cv_pragma_pack=yes],
 
1437
                        [have_cv_pragma_pack=no])
 
1438
                ])
 
1439
        AC_MSG_RESULT([$have_cv_pragma_pack])
 
1440
        if test "$have_cv_pragma_pack" = yes; then
 
1441
                AC_DEFINE([HAVE_PRAGMA_PACK], 1, "pragma pack")
 
1442
        else
 
1443
                AC_MSG_CHECKING([for structure packing via hppa/hp-ux pragma])
 
1444
                AC_CACHE_VAL([have_cv_pragma_pack_hpux],[
 
1445
                        AC_TRY_RUN([
 
1446
                        /* hppa/hp-ux wants pragma outside of function */
 
1447
#pragma pack 1 /* has to be in column 1 ! */
 
1448
                        struct { char c; long l; } s;
 
1449
                            int main(int argc, char **argv) {
 
1450
                        return sizeof(s)==sizeof(s.c)+sizeof(s.l) ? 0:1; } ],
 
1451
                        [have_cv_pragma_pack_hpux=yes],
 
1452
                        [have_cv_pragma_pack_hpux=no])
 
1453
                ])
 
1454
                AC_MSG_RESULT([$have_cv_pragma_pack_hpux])
 
1455
                AC_DEFINE([HAVE_PRAGMA_PACK_HPPA], 1, "pragma pack hppa/hp-ux style")
 
1456
        fi
 
1457
fi
 
1458
 
 
1459
dnl check for __attribute__((aligned))
 
1460
AC_MSG_CHECKING([for type aligning via __attribute__((aligned))])
 
1461
AC_CACHE_VAL([have_cv_attrib_aligned],[
 
1462
        AC_TRY_COMPILE(,
 
1463
                [typedef int cl_aligned_int __attribute__((aligned));],
 
1464
                [have_cv_attrib_aligned=yes],
 
1465
                [have_cv_attrib_aligned=no])
 
1466
        ])
 
1467
AC_MSG_RESULT([$have_cv_attrib_aligned])
 
1468
 
 
1469
if test "$have_cv_attrib_packed" = no -a "$have_cv_pragma_pack" = no -a "$have_cv_pragma_pack_hpux" = no; then
 
1470
        AC_MSG_ERROR(Need to know how to pack structures with this compiler)
 
1471
fi
 
1472
 
 
1473
if test "$have_cv_attrib_packed" = yes; then
 
1474
        AC_DEFINE([HAVE_ATTRIB_PACKED], 1, [attrib packed])
 
1475
fi
 
1476
 
 
1477
if test "$have_cv_attrib_aligned" = yes; then
 
1478
        AC_DEFINE([HAVE_ATTRIB_ALIGNED], 1, [attrib aligned])
 
1479
fi
 
1480
 
 
1481
dnl Sanity check that struct packing works
 
1482
AC_MSG_CHECKING([that structure packing works])
 
1483
AC_CACHE_VAL([have_cv_struct_pack],[
 
1484
    AC_TRY_RUN([
 
1485
#ifndef HAVE_ATTRIB_PACKED
 
1486
#define __attribute__(x)
 
1487
#endif
 
1488
#ifdef HAVE_PRAGMA_PACK
 
1489
#pragma pack(1) /* has to be in column 1 ! */
 
1490
#endif
 
1491
#ifdef HAVE_PRAGMA_PACK_HPPA
 
1492
#pragma pack 1 /* has to be in column 1 ! */
 
1493
#endif
 
1494
 
 
1495
struct { char c __attribute__((packed)); long l __attribute__((packed)); } s;
 
1496
 
 
1497
#ifdef HAVE_PRAGMA_PACK
 
1498
#pragma pack()
 
1499
#endif
 
1500
#ifdef HAVE_PRAGMA_PACK_HPPA
 
1501
#pragma pack
 
1502
#endif
 
1503
 
 
1504
struct { char c; long l;} s2;
 
1505
 
 
1506
#ifdef HAVE_PRAGMA_PACK
 
1507
#pragma pack(1) /* has to be in column 1 ! */
 
1508
#endif
 
1509
#ifdef HAVE_PRAGMA_PACK_HPPA
 
1510
#pragma pack 1 /* has to be in column 1 ! */
 
1511
#endif
 
1512
 
 
1513
struct { char c; long l; } __attribute__((packed)) s3;
 
1514
 
 
1515
#ifdef HAVE_PRAGMA_PACK
 
1516
#pragma pack()
 
1517
#endif
 
1518
#ifdef HAVE_PRAGMA_PACK_HPPA
 
1519
#pragma pack
 
1520
#endif
 
1521
 
 
1522
    int main(int argc, char **argv) {
 
1523
        if (sizeof(s)!=sizeof(s.c)+sizeof(s.l))
 
1524
            return 1;
 
1525
        if (sizeof(s) != sizeof(s3))
 
1526
            return 2;
 
1527
        return (sizeof(s2) >= sizeof(s)) ? 0 : 3;
 
1528
    }],
 
1529
    [have_cv_struct_pack=yes],
 
1530
    [have_cv_struct_pack=no],
 
1531
    [have_cv_struct_pack=yes])
 
1532
])
 
1533
AC_MSG_RESULT([$have_cv_struct_pack])
 
1534
 
 
1535
if test "$have_cv_struct_pack" = "no"; then
 
1536
    AC_MSG_ERROR([Structure packing seems to be available, but is not working with this compiler])
 
1537
fi
 
1538
 
 
1539
dnl Check if <sys/select.h> needs to be included for fd_set
 
1540
AC_MSG_CHECKING([for fd_set])
 
1541
AC_HEADER_EGREP([fd_mask], [sys/select.h], [have_fd_set=yes])
 
1542
if test "$have_fd_set" = yes; then
 
1543
        AC_DEFINE([HAVE_SYS_SELECT_H], 1, "have <sys/select.h>")
 
1544
        AC_MSG_RESULT([yes, found in sys/select.h])
 
1545
else
 
1546
        AC_TRY_COMPILE([#include <sys/time.h>
 
1547
                        #include <sys/types.h>
 
1548
                        #ifdef HAVE_UNISTD_H
 
1549
                        #include <unistd.h>
 
1550
                        #endif],
 
1551
                [fd_set readMask, writeMask;], have_fd_set=yes, have_fd_set=no)
 
1552
        if test "$have_fd_set" = yes; then
 
1553
                AC_MSG_RESULT([yes, found in sys/types.h])
 
1554
        else
 
1555
                AC_DEFINE([NO_FD_SET], 1, "no fd_set")
 
1556
                AC_MSG_RESULT(no)
 
1557
        fi
 
1558
fi
 
1559
 
 
1560
AC_MSG_CHECKING([default FD_SETSIZE value])
 
1561
AC_TRY_RUN([
 
1562
#include <stdio.h>
 
1563
#include <unistd.h>
 
1564
#include <sys/time.h>
 
1565
#ifdef HAVE_SYS_SELECT_H
 
1566
#include <sys/select.h>
 
1567
#endif
 
1568
#ifdef HAVE_SYS_TYPES_H
 
1569
#include <sys/types.h>
 
1570
#endif
 
1571
#include <errno.h>
 
1572
int main(void) {
 
1573
        FILE *fp = fopen("conftestval", "w");
 
1574
        if(fp) {
 
1575
                if(fprintf (fp, "%d\n", FD_SETSIZE) < 1)  {
 
1576
                        perror("fprintf failed");
 
1577
                        return errno;
 
1578
                }
 
1579
        } else {
 
1580
                perror("fopen failed");
 
1581
                return errno;
 
1582
        }
 
1583
        return 0;
 
1584
}
 
1585
],
 
1586
DEFAULT_FD_SETSIZE=`cat conftestval`,
 
1587
DEFAULT_FD_SETSIZE=256,
 
1588
DEFAULT_FD_SETSIZE=256)
 
1589
AC_MSG_RESULT([$DEFAULT_FD_SETSIZE])
 
1590
AC_DEFINE_UNQUOTED([DEFAULT_FD_SETSIZE], $DEFAULT_FD_SETSIZE, "default FD_SETSIZE value")
 
1591
 
 
1592
AC_MSG_CHECKING([stat64])
 
1593
AC_TRY_RUN([
 
1594
#define _LARGEFILE_SOURCE
 
1595
#define _LARGEFILE64_SOURCE
 
1596
#include <stdio.h>
 
1597
#include <sys/types.h>
 
1598
#include <sys/stat.h>
 
1599
#include <unistd.h>
 
1600
#include <errno.h>
 
1601
 
 
1602
int main(void) {
 
1603
    struct stat64 sb;
 
1604
 
 
1605
    if (stat64(".", &sb) == -1)
 
1606
        return errno;
 
1607
 
 
1608
    return 0;
 
1609
}
 
1610
],
 
1611
[enable_stat64=yes],
 
1612
[enable_stat64=no],
 
1613
[enable_stat64=no],
 
1614
)
 
1615
 
 
1616
if test "$enable_stat64" != "no"; then
 
1617
AC_DEFINE([HAVE_STAT64],1,[enable stat64])
 
1618
CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
 
1619
fi
 
1620
AC_MSG_RESULT([$enable_stat64])
 
1621
 
 
1622
dnl Check signed right shift implementation
 
1623
AC_MSG_CHECKING([whether signed right shift is sign extended])
 
1624
AC_TRY_RUN([int main(void){int a=-1;int b=a>>1;return(a!=b);}],
 
1625
    [have_signed_rightshift_extended=yes],
 
1626
    [have_signed_rightshift_extended=no],
 
1627
    [have_signed_rightshift_extended=no])
 
1628
if test $have_signed_rightshift_extended = yes; then
 
1629
    AC_DEFINE([HAVE_SAR], 1, [Define signed right shift implementation])
 
1630
fi
 
1631
AC_MSG_RESULT([$have_signed_rightshift_extended]);
 
1632
 
 
1633
AC_C_FDPASSING
 
1634
 
 
1635
AC_DEFINE_UNQUOTED([VERSION],"$VERSION",[Version number of package])
 
1636
AC_DEFINE_UNQUOTED([VERSION_SUFFIX],"$VERSION_SUFFIX",[Version suffix for package])
 
1637
 
 
1638
AC_ARG_ENABLE(clamdtop,
 
1639
              AC_HELP_STRING([--enable-clamdtop],
 
1640
                             [Enable 'clamdtop' tool @<:@default=auto@:>@]),
 
1641
[enable_clamdtop=$enableval], [enable_clamdtop="auto"])
 
1642
 
 
1643
if test "$enable_clamdtop" != "no"; then
 
1644
 
 
1645
AC_LIB_FIND([ncurses], [ncurses/ncurses.h],
 
1646
            AC_LANG_PROGRAM([#include <ncurses/ncurses.h>],
 
1647
                            [initscr(); KEY_RESIZE;]),
 
1648
            [CURSES_CPPFLAGS="$INCNCURSES"; CURSES_LIBS="$LTLIBNCURSES";
 
1649
             CURSES_INCLUDE="<ncurses/ncurses.h>"],
 
1650
            [])
 
1651
 
 
1652
if test "X$HAVE_LIBNCURSES" != "Xyes"; then
 
1653
    HAVE_LIBNCURSES=
 
1654
    AC_LIB_FIND([ncurses], [ncurses.h],
 
1655
            AC_LANG_PROGRAM([#include <ncurses.h>],
 
1656
                            [initscr(); KEY_RESIZE;]),
 
1657
            [CURSES_CPPFLAGS="$INCNCURSES"; CURSES_LIBS="$LTLIBNCURSES";
 
1658
             CURSES_INCLUDE="<ncurses.h>"],
 
1659
            [])
 
1660
fi
 
1661
 
 
1662
if test "X$HAVE_LIBNCURSES" != "Xyes"; then
 
1663
    AC_LIB_FIND([pdcurses],[curses.h],
 
1664
                            AC_LANG_PROGRAM([#include <curses.h>],
 
1665
                                            [initscr(); KEY_RESIZE;]),
 
1666
                            [CURSES_CPPFLAGS="$INCPDCURSES";
 
1667
                             CURSES_LIBS="$LTLIBPDCURSES";
 
1668
                             CURSES_INCLUDE="<curses.h>"],
 
1669
                            [AC_MSG_WARN([****** not building clamdtop: ncurses not found])])
 
1670
fi
 
1671
 
 
1672
if test "x$CURSES_LIBS" = "x" -a "$enable_clamdtop" = "yes"; then
 
1673
    AC_MSG_ERROR([
 
1674
 
 
1675
ERROR!  Clamdtop was configured, but not found.  You need to install libncurses5-dev.
 
1676
])
 
1677
fi
 
1678
 
 
1679
fi
 
1680
 
 
1681
AC_DEFINE_UNQUOTED([CURSES_INCLUDE], $CURSES_INCLUDE, [curses header location])
 
1682
AC_SUBST([CURSES_CPPFLAGS])
 
1683
AC_SUBST([CURSES_LIBS])
 
1684
AM_CONDITIONAL([HAVE_CURSES],
 
1685
               [test "X$HAVE_LIBNCURSES" = "Xyes" || test "X$HAVE_LIBPDCURSES" = "Xyes"])
 
1686
 
 
1687
AC_ARG_ENABLE([distcheck-werror],
 
1688
              AC_HELP_STRING([--enable-distcheck-werror],
 
1689
                             [enable warnings as error for distcheck
 
1690
                              @<:@default=no@:>@]),
 
1691
[enable_distcheckwerror=$enableval],[enable_distcheckwerror="no"])
 
1692
 
 
1693
# Enable distcheck warnings and Werror only for gcc versions that support them,
 
1694
# and only after we've run the configure tests.
 
1695
# Some configure tests fail (like checking for cos in -lm) if we enable these
 
1696
# Werror flags for configure too (for example -Wstrict-prototypes makes
 
1697
# configure think that -lm doesn't have cos, hence its in libc).
 
1698
WERR_CFLAGS=
 
1699
WERR_CFLAGS_MILTER=
 
1700
if test "x$enable_distcheckwerror" = "xyes"; then
 
1701
    if test "$distcheck_enable_flags" = "1"; then
 
1702
        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"
 
1703
        WERR_CFLAGS="$WERR_COMMON -Wwrite-strings"
 
1704
        WERR_CFLAGS_MILTER="$WERR_COMMON -Wno-error=format-nonliteral"
 
1705
    fi
 
1706
fi
 
1707
AC_SUBST([WERR_CFLAGS])
 
1708
AC_SUBST([WERR_CFLAGS_MILTER])
 
1709
 
 
1710
AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm],
 
1711
                                    [Enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
 
1712
                                    [enable_llvm=$enableval], [enable_llvm="auto"])
 
1713
 
 
1714
if test "$enable_llvm" != "no"; then
 
1715
    dnl Try to configure subdir, optionally
 
1716
    AC_CONFIG_SUBDIRS_OPTIONAL([libclamav/c++])
 
1717
fi
 
1718
 
 
1719
AC_ARG_ENABLE([sha-collector-for-internal-use], [], [enable_sha_collector="yes"], [enable_sha_collector="no"])
 
1720
if test "$enable_sha_collector" != "no"; then
 
1721
    AC_DEFINE([HAVE__INTERNAL__SHA_COLLECT], 1, [For internal use only - DO NOT DEFINE])
 
1722
fi
 
1723
 
 
1724
AC_OUTPUT([
 
1725
clamscan/Makefile
 
1726
database/Makefile
 
1727
docs/Makefile
 
1728
clamd/Makefile
 
1729
clamdscan/Makefile
 
1730
clamav-milter/Makefile
 
1731
freshclam/Makefile
 
1732
sigtool/Makefile
 
1733
clamconf/Makefile
 
1734
etc/Makefile
 
1735
test/Makefile
 
1736
unit_tests/Makefile
 
1737
clamdtop/Makefile
 
1738
clambc/Makefile
 
1739
Makefile
 
1740
clamav-config
 
1741
libclamav.pc
 
1742
platform.h
 
1743
docs/man/clamav-milter.8
 
1744
docs/man/clamav-milter.conf.5
 
1745
docs/man/clambc.1
 
1746
docs/man/clamconf.1
 
1747
docs/man/clamd.8
 
1748
docs/man/clamd.conf.5
 
1749
docs/man/clamdscan.1
 
1750
docs/man/clamscan.1
 
1751
docs/man/freshclam.1
 
1752
docs/man/freshclam.conf.5
 
1753
docs/man/sigtool.1
 
1754
docs/man/clamdtop.1
 
1755
])
 
1756
 
 
1757
if test "$enable_llvm" = "yes" && test "$subdirfailed" != "no"; then
 
1758
    AC_MSG_ERROR([Failed to configure LLVM, and LLVM was explicitly requested])
 
1759
fi
 
1760
AM_CONDITIONAL([ENABLE_LLVM],
 
1761
               [test "$subdirfailed" != "yes" && test "$enable_llvm" != "no"])
 
1762
no_recursion="yes";
 
1763
AC_OUTPUT([libclamav/Makefile])
 
1764
 
 
1765
# Print a summary of what features we enabled
 
1766
AC_MSG_NOTICE([Summary of detected features follows])
 
1767
 
 
1768
cat <<EOF
 
1769
              OS          : $target_os
 
1770
              pthreads    : $have_pthreads ($THREAD_LIBS)
 
1771
EOF
 
1772
 
 
1773
AC_MSG_NOTICE([Summary of miscellaneous  features])
 
1774
if test "x$CHECK_LIBS" = "x"; then
 
1775
    check_libs="no"
 
1776
else
 
1777
    check_libs="$CHECK_LIBS"
 
1778
fi
 
1779
CL_MSG_STATUS([check       ],[$check_libs],[$enable_check_ut])
 
1780
CL_MSG_STATUS([fanotify    ],[$want_fanotify],[$want_fanotify])
 
1781
if test "x$ac_cv_have_control_in_msghdr" = "xyes"; then
 
1782
    CL_MSG_STATUS([fdpassing   ],[$have_fdpass],[$want_fdpassing])
 
1783
else
 
1784
    CL_MSG_STATUS([fdpassing   ],[n/a],[])
 
1785
fi
 
1786
CL_MSG_STATUS([IPv6        ],[$have_cv_ipv6],[$want_ipv6])
 
1787
 
 
1788
AC_MSG_NOTICE([Summary of optional tools])
 
1789
CL_MSG_STATUS([clamdtop    ],[$CURSES_LIBS],[$enable_clamdtop])
 
1790
CL_MSG_STATUS([milter      ],[yes],[$have_milter])
 
1791
 
 
1792
AC_MSG_NOTICE([Summary of engine performance features)])
 
1793
if test "x$enable_debug" = "xyes"; then
 
1794
    CL_MSG_STATUS([release mode],[no],[debug build])
 
1795
else
 
1796
    CL_MSG_STATUS([release mode],[yes],[yes])
 
1797
fi
 
1798
have_jit="no"
 
1799
if test "$subdirfailed" = "no"; then
 
1800
    have_jit="yes"
 
1801
fi
 
1802
CL_MSG_STATUS([jit         ],[$have_jit],[$enable_llvm])
 
1803
CL_MSG_STATUS([mempool     ],[$have_mempool],[$enable_mempool])
 
1804
 
 
1805
AC_MSG_NOTICE([Summary of engine detection features])
 
1806
CL_MSG_STATUS([autoit_ea06 ],[$have_autoitea06],[])
 
1807
CL_MSG_STATUS([bzip2       ],[$bzip_check],[$want_bzip2])
 
1808
CL_MSG_STATUS([zlib        ],[$ZLIB_HOME],[yes])
 
1809
CL_MSG_STATUS([unrar       ],[$want_unrar],[$want_unrar])
 
1810
if test "x$XML_LIBS" = "x"; then
 
1811
    CL_MSG_STATUS([dmg and xar ],[no],[])
 
1812
else
 
1813
    CL_MSG_STATUS([dmg and xar ],[yes, from $XML_HOME],[])
 
1814
fi
 
1815
 
 
1816
# Yep, downgrading the compiler avoids the bug too:
 
1817
# 4.0.x, and 4.1.0 are the known buggy versions
 
1818
# 3.4 doesn't have the bug
 
1819
if test "x$gcc_check" != "xyes"; then
 
1820
        AC_MSG_WARN([
 
1821
****** Optimizations disabled to avoid compiler bugs
 
1822
****** The resulting binaries will be slow!
 
1823
****** It is recommended to either upgrade or downgrade your compiler
 
1824
])
 
1825
fi
 
1826
 
 
1827
if test "x$cross_compiling" != "xno" || test "x$gcc_check" != "xyes" || test "x$zlib_check" = "xno" || test "x$bzip_check" != "xok" ; then
 
1828
AC_MSG_WARN([
 
1829
****** WARNING:
 
1830
****** You are cross compiling to a different host or you are
 
1831
****** linking to bugged system libraries or you have manually
 
1832
****** disabled important configure checks.
 
1833
****** Please be aware that this build may be badly broken.
 
1834
****** DO NOT REPORT BUGS BASED ON THIS BUILD !!!
 
1835
])
 
1836
fi
 
1837