1m4_include([version.m4])
2
3dnl Initialize autoconf/automake
4AC_INIT(aide, AIDE_VERSION)
5AC_CANONICAL_TARGET
6AM_INIT_AUTOMAKE([1.10 -Wall -Werror silent-rules subdir-objects serial-tests])
7
8AC_DEFINE_UNQUOTED(AIDEVERSION, "AIDE_VERSION")
9AH_TEMPLATE([AIDEVERSION], [package version])
10
11dnl The name of the configure h-file.
12AM_CONFIG_HEADER(config.h)
13
14dnl Checks for programs.
15AC_PROG_CC_C99
16if test "x$ac_cv_prog_cc_c99" = xno; then
17    AC_MSG_ERROR([AIDE needs a C99 compatible compiler])
18fi
19
20AC_PROG_MAKE_SET
21AC_PROG_RANLIB
22AC_PROG_INSTALL
23AC_PROG_YACC
24if test "x${YACC}" != "xbison -y"; then
25        echo "AIDE requires GNU bison"
26        exit 5
27fi
28
29AC_PROG_LEX
30if test "x${LEX}" != "xflex"; then
31        echo "AIDE requires GNU flex"
32        exit 5
33fi
34AC_CHECK_PROGS(LD, ld)
35
36AC_PATH_TOOL([PKG_CONFIG], [pkg-config], [no])
37AM_PROG_CC_C_O
38
39AC_SYS_LARGEFILE
40
41dnl AC_ARG_PROGRAM
42
43AC_ARG_WITH(extra-includes,
44	AC_HELP_STRING([--with-extra-includes],
45		[Specify additional paths with -I to find headerfiles]),
46	[CPPFLAGS="$CPPFLAGS $withval"]
47)
48AC_ARG_WITH(extra-libs,
49	AC_HELP_STRING([--with-extra-libs],
50		[Specify additional paths with -L to find libraries]),
51	[LDFLAGS="$LDFLAGS $withval"]
52)
53AC_ARG_WITH(extra-link-libs,
54	AC_HELP_STRING([--with-extra-link-libs],
55		[Specify additional libraries to link]),
56	[LIBS="$LIBS $withval"]
57)
58
59dnl Do the right thing for glibc...
60AIDE_DEFS="-D_GNU_SOURCE"
61
62dnl This is borrowed from libtool
63
64if test $ac_cv_prog_gcc = yes; then
65    LD_STATIC_FLAG='-static'
66
67    case "$host_os" in
68    beos* | irix5* | irix6* | osf3* | osf4* | osf5*)
69	# PIC is the default for these OSes.
70	;;
71    aix*)
72	# Below there is a dirty hack to force normal static linking with -ldl
73	# The problem is because libdl dynamically linked with both libc and
74	# libC (AIX C++ library), which obviously doesn't included in libraries
75	# list by gcc. This cause undefined symbols with -static flags.
76	# This hack allows C programs to be linked with "-static -ldl", but
77	# we not sure about C++ programs.
78	LD_STATIC_FLAG="$LD_STATIC_FLAG ${wl}-lC"
79	;;
80    cygwin* | mingw* | os2*)
81	# We can build DLLs from non-PIC.
82	;;
83    amigaos*)
84	# FIXME: we need at least 68020 code to build shared libraries, but
85	# adding the `-m68020' flag to GCC prevents building anything better,
86	# like `-m68040'.
87	## pic_flag='-m68020 -resident32 -malways-restore-a4'
88	;;
89    sysv4*MP*)
90	## if test -d /usr/nec; then
91	## pic_flag=-Kconform_pic
92	## fi
93	;;
94    *)
95	## pic_flag='-fPIC'
96	;;
97    esac
98else
99    # PORTME Check for PIC flags for the system compiler.
100    case "$host_os" in
101    aix3* | aix4*)
102	# All AIX code is PIC.
103	LD_STATIC_FLAG='-bnso -bI:/lib/syscalls.exp'
104	;;
105
106    hpux9* | hpux10* | hpux11*)
107	# Is there a better LD_STATIC_FLAG that works with the bundled CC?
108	## wl='-Wl,'
109	LD_STATIC_FLAG="${wl}-a ${wl}archive"
110	## pic_flag='+Z'
111	;;
112
113    irix5* | irix6*)
114	## wl='-Wl,'
115	LD_STATIC_FLAG='-non_shared'
116	# PIC (with -KPIC) is the default.
117	;;
118
119    cygwin* | mingw* | os2*)
120	# We can build DLLs from non-PIC.
121	;;
122
123    osf3* | osf4* | osf5*)
124	# All OSF/1 code is PIC.
125	## wl='-Wl,'
126	LD_STATIC_FLAG='-non_shared'
127	;;
128
129    sco3.2v5*)
130	## pic_flag='-Kpic'
131	LD_STATIC_FLAG='-dn'
132	## special_shlib_compile_flags='-belf'
133	;;
134
135    solaris*)
136	## pic_flag='-KPIC'
137	LD_STATIC_FLAG='-Bstatic'
138	## wl='-Wl,'
139	;;
140
141    sunos4*)
142	## pic_flag='-PIC'
143	LD_STATIC_FLAG='-Bstatic'
144	## wl='-Qoption ld '
145	;;
146
147    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
148	## pic_flag='-KPIC'
149	LD_STATIC_FLAG='-Bstatic'
150	## wl='-Wl,'
151	;;
152
153    uts4*)
154	## pic_flag='-pic'
155	LD_STATIC_FLAG='-Bstatic'
156	;;
157    sysv4*MP*)
158	if test -d /usr/nec ;then
159	## pic_flag='-Kconform_pic'
160	LD_STATIC_FLAG='-Bstatic'
161	fi
162	;;
163    *)
164	## can_build_shared=no
165	;;
166    esac
167fi
168
169# Check whether static linking has explicitly been disabled
170AC_ARG_ENABLE(static,[  --disable-static        Disable static linking (lowers the security of aide)], [aide_static_choice=$enableval], [aide_static_choice=yes])
171
172dnl Borrowed from dbus
173cc_supports_flag() {
174  AC_MSG_CHECKING(whether $CC supports "$@")
175  Cfile=/tmp/foo${$}
176  touch ${Cfile}.c
177  $CC -c "$@" ${Cfile}.c -o ${Cfile}.o >/dev/null 2>&1
178  rc=$?
179  rm -f ${Cfile}.c ${Cfile}.o
180  case $rc in
181    0) AC_MSG_RESULT(yes);;
182    *) AC_MSG_RESULT(no);;
183  esac
184  return $rc
185}
186
187dnl Borrowed from dbus
188ld_supports_flag() {
189  AC_MSG_CHECKING([whether $LD supports "$@"])
190  AC_TRY_LINK([
191    int one(void) { return 1; }
192    int two(void) { return 2; }
193  ], [ two(); ] , [_ac_ld_flag_supported=yes], [_ac_ld_flag_supported=no])
194
195  if test "$_ac_ld_flag_supported" = "yes"; then
196    rm -f conftest.c
197    touch conftest.c
198    if $CC -c conftest.c; then
199      ld_out=`$LD $@ -o conftest conftest.o 2>&1`
200      ld_ret=$?
201      if test $ld_ret -ne 0 ; then
202        _ac_ld_flag_supported=no
203      elif echo "$ld_out" | egrep 'option ignored|^usage:|unrecognized option|illegal option' >/dev/null ; then
204        _ac_ld_flag_supported=no
205      fi
206    fi
207    rm -f conftest.c conftest.o conftest
208  fi
209
210  AC_MSG_RESULT($_ac_ld_flag_supported)
211  if test "$_ac_ld_flag_supported" = "yes" ; then
212    return 0
213  else
214    return 1
215  fi
216}
217
218if test "$aide_static_choice" != "yes"; then
219  LD_STATIC_FLAG=""
220  EXTRA_LDFLAGS=""
221  EXTRA_CFLAGS=""
222  if test x$CC = "xgcc"; then
223    if ld_supports_flag -z,relro; then
224      EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-z,relro"
225    fi
226    if ld_supports_flag -z,now; then
227      EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-z,now"
228    fi
229    if cc_supports_flag -fPIE -DPIE; then
230      EXTRA_CFLAGS="$EXTRA_CFLAGS -fPIE -DPIE"
231      EXTRA_LDFLAGS="$EXTRA_LDFLAGS -pie"
232    fi
233    dnl Check for some optional warnings
234    if cc_supports_flag -Wundef; then
235      EXTRA_CFLAGS="$EXTRA_CFLAGS -Wundef"
236    fi
237    if cc_supports_flag -Wmissing-format-attribute; then
238      EXTRA_CFLAGS="$EXTRA_CFLAGS -Wmissing-format-attribute"
239    fi
240    if cc_supports_flag -Wshadow; then
241      EXTRA_CFLAGS="$EXTRA_CFLAGS -Wshadow"
242    fi
243    if cc_supports_flag -Wlogical-op; then
244      EXTRA_CFLAGS="$EXTRA_CFLAGS -Wlogical-op"
245    fi
246  fi
247fi
248
249dnl This macro is new in autoconf-2.13
250AC_SEARCH_LIBS(syslog, bsd socket inet, [AC_DEFINE(HAVE_SYSLOG,1,[syslog available?])])
251AC_CHECK_FUNCS(vsyslog)
252
253AC_C_BIGENDIAN([AC_DEFINE(BIG_ENDIAN_HOST,1,[big endian])], [AC_DEFINE(LITTLE_ENDIAN_HOST,1,[little endian])])
254
255AC_CHECK_TYPES([byte, ushort, ulong, u16, u32, u64])
256
257AC_CHECK_SIZEOF(unsigned short, 2)
258AC_CHECK_SIZEOF(unsigned int, 4)
259AC_CHECK_SIZEOF(unsigned long, 4)
260AC_CHECK_SIZEOF(unsigned long long, 8)
261
262AC_CHECK_SIZEOF(int)
263AC_CHECK_SIZEOF(long)
264AC_CHECK_SIZEOF(long long)
265
266AC_CHECK_SIZEOF(uid_t)
267AC_CHECK_SIZEOF(gid_t)
268AC_CHECK_SIZEOF(ino_t)
269AC_CHECK_SIZEOF(nlink_t)
270AC_CHECK_SIZEOF(off_t)
271AC_CHECK_SIZEOF(blkcnt_t)
272
273AC_C_LONG_DOUBLE
274
275AC_HEADER_STDC
276AC_CHECK_FUNCS(strtoll strtoimax readdir)
277AC_CHECK_FUNCS(stricmp strnstr strnlen)
278
279AC_ARG_WITH([mmap],
280	[AC_HELP_STRING([--with-mmap],
281		[use mmap @<:@default=check@:>@])],
282	[],
283	[with_mmap=check]
284)
285
286AS_IF([test "x$with_mmap" != xno],
287	[AC_CHECK_FUNCS(mmap)]
288	compoptionstring="${compoptionstring}WITH_MMAP\\n"
289)
290
291AC_CHECK_FUNCS(fcntl ftruncate posix_fadvise asprintf snprintf \
292	vasprintf vsnprintf va_copy __va_copy)
293
294# Linux has the O_NOATIME flag, sometimes
295AC_CACHE_CHECK([for open/O_NOATIME], db_cv_open_o_noatime, [
296echo "test for working open/O_NOATIME" > __o_noatime_file
297AC_TRY_RUN([
298#include <sys/types.h>
299#include <fcntl.h>
300#ifndef O_NOATIME
301#if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
302#define O_NOATIME 01000000
303#else
304#define O_NOATIME 0
305#endif
306#endif
307main() {
308int c, fd = open("__o_noatime_file", O_RDONLY | O_NOATIME, 0);
309exit ((!O_NOATIME) || (fd == -1) || (read(fd, &c, 1) != 1));
310}], [db_cv_open_o_noatime=yes], [db_cv_open_o_noatime=no],
311AC_TRY_LINK([
312#include <sys/types.h>
313#include <fcntl.h>
314#ifndef O_NOATIME
315#if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
316#define O_NOATIME 01000000
317#else
318#define O_NOATIME 0
319#endif
320#endif], [
321	open("__o_noatime_file", O_RDONLY | O_NOATIME, 0);
322], [db_cv_open_o_noatime=yes], [db_cv_open_o_noatime=no]))
323rm -f __o_noatime_file])
324if test "$db_cv_open_o_noatime" = yes; then
325	AC_DEFINE(HAVE_O_NOATIME)
326	AH_TEMPLATE(HAVE_O_NOATIME, [Define to 1 if you have the O_NOATIME flag.])
327fi
328
329AC_CHECK_HEADERS(syslog.h inttypes.h fcntl.h ctype.h)
330
331PCRELIB="-lpcre"
332if test "$aide_static_choice" == "yes"; then
333    PCRELIB="$PCRELIB -pthread"
334fi
335AC_CHECK_LIB(pcre, pcre_exec, [
336    compoptionstring="${compoptionstring}WITH_PCRE\\n"
337    ], [AC_MSG_ERROR([You don't have pcre library properly installed.])]
338    )
339AC_SUBST(PCRELIB)
340
341AC_ARG_WITH([locale],
342	[AC_HELP_STRING([--with-locale],
343		[use locale stuff])],
344	[],
345	[with_locale=no]
346)
347
348AS_IF([test "x$with_locale" != xno],
349	[AC_CHECK_HEADERS(libintl.h,
350		[AC_DEFINE(USE_LOCALE,1,[Define if LOCALE support should be used])
351		AIDE_USE_LOCALE=""
352		compoptionstring="${compoptionstring}WITH_LOCALE\\n"
353dnl        	AC_DEFINE_UNQUOTED(LOCALEDIR,"$prefix/lib/locale",[Localedir to use])],
354	)]
355)
356
357AC_SUBST(AIDE_USE_LOCALE)
358
359AC_ARG_WITH([syslog_ident],
360	AC_HELP_STRING([--with-syslog-ident],
361	[syslog ident]),
362  	[AC_DEFINE_UNQUOTED(AIDE_IDENT,"$withval",[syslog ident])]
363		compoptionstring="${compoptionstring}AIDE_IDENT=${withval}\\n",
364  	[AC_DEFINE_UNQUOTED(AIDE_IDENT,"aide",[syslog ident])]
365)
366
367AC_ARG_WITH([syslog_facility],
368	AC_HELP_STRING([--with-syslog-facility],
369		[Specify syslog facility, see man syslog for options]),
370	[AC_DEFINE_UNQUOTED(AIDE_SYSLOG_FACILITY,$withval,[syslog facility])]
371	compoptionstring="${compoptionstring}AIDE_SYSLOG_FACILITY=${withval}\\n",
372	[AC_DEFINE_UNQUOTED(AIDE_SYSLOG_FACILITY,LOG_LOCAL0,[syslog facility])]
373)
374
375AC_ARG_WITH([syslog_logopt],
376	AC_HELP_STRING([--with-syslog-logopt],
377		[Specify syslog logopt, see man syslog for options]),
378	[AC_DEFINE_UNQUOTED(AIDE_LOGOPT,$withval,[syslog logopt])],
379	[AC_DEFINE_UNQUOTED(AIDE_LOGOPT,LOG_CONS,[syslog logopt])]
380)
381
382AC_ARG_WITH([syslog_priority],
383	AC_HELP_STRING([--with-syslog-priority],
384		[Specify syslog priority, see man syslog for options]),
385	[AC_DEFINE_UNQUOTED(SYSLOG_PRIORITY,$withval,[syslog priority])]
386	compoptionstring="${compoptionstring}SYSLOG_PRIORITY=${withval}\\n",
387	[AC_DEFINE_UNQUOTED(SYSLOG_PRIORITY,LOG_NOTICE,[syslog priority])]
388)
389
390
391AC_ARG_WITH([zlib],
392	AC_HELP_STRING([--with-zlib],
393		[use zlib compression]),
394	,
395	[with_zlib=yes]
396)
397
398AC_MSG_CHECKING(for posix-acl-support)
399AC_ARG_WITH([posix-acl],
400	[AC_HELP_STRING([--with-posix-acl],
401		[use POSIX ACLs (no checking)])],
402	[],
403	[with_posix_acl_support=no]
404)
405
406AS_IF([test "x$with_posix_acl_support" != xno],
407	[AC_DEFINE(WITH_POSIX_ACL,1,[use POSIX ACLs])
408	AC_DEFINE(WITH_ACL,1,[use ACL])
409	ACLLIB="-lacl"
410	compoptionstring="${compoptionstring}WITH_POSIX_ACL\\n"
411	AC_MSG_RESULT(yes)],
412	[AC_MSG_RESULT(no)]
413)
414
415AC_SUBST(ACLLIB)
416
417AC_MSG_CHECKING(for selinux-support)
418AC_ARG_WITH([selinux],
419	[AC_HELP_STRING([--with-selinux],
420		[use SELinux (no checking)])],
421	[with_selinux_support="$withval"],
422	[with_selinux_support=no]
423)
424
425AS_IF([test "x$with_selinux_support" != xno],
426    AC_DEFINE(WITH_SELINUX,1,[use SELinux])
427    [AC_MSG_RESULT(yes)
428    if test "x$PKG_CONFIG" != xno && $PKG_CONFIG --exists libselinux; then
429        if test "$aide_static_choice" == "yes"; then
430            SELINUXLIB=$(${PKG_CONFIG} --libs libselinux --static)
431        else
432            SELINUXLIB=$(${PKG_CONFIG} --libs libselinux)
433        fi
434    else
435    SELINUXLIB="-lselinux"
436    if test "$aide_static_choice" == "yes"; then
437        saveLIBS=$LIBS
438        LIBS="-static $SELINUXLIB"
439        AC_SEARCH_LIBS([lgetfilecon_raw], [], [], [SELINUXLIB="$SELINUXLIB -lpthread"])
440        LIBS=$saveLIBS
441    fi
442    fi
443	compoptionstring="${compoptionstring}WITH_SELINUX\\n"
444    ],
445	[AC_MSG_RESULT(no)]
446)
447
448AC_SUBST(SELINUXLIB)
449
450
451AC_MSG_CHECKING(for prelink-support)
452AC_ARG_WITH([prelink],
453            [AC_HELP_STRING([--with-prelink],[use prelink (no checking)])],
454            [case $with_prelink in
455		yes) AC_DEFINE_UNQUOTED(PRELINK_PATH, "/usr/sbin/prelink", [path to prelink])
456		     AC_DEFINE(WITH_PRELINK,1,[use prelink])
457		     ELFLIB="-lelf"
458		     compoptionstring="${compoptionstring}WITH_PRELINK\\n"
459		     AC_MSG_RESULT([/usr/sbin/prelink])
460		     ;;
461		no)  AC_MSG_RESULT(no)
462		     ;;
463		*)   AC_DEFINE_UNQUOTED(PRELINK_PATH, "$with_prelink", [path to prelink])
464		     AC_DEFINE(WITH_PRELINK,1,[use prelink])
465		     ELFLIB="-lelf"
466		     compoptionstring="${compoptionstring}WITH_PRELINK\\n"
467		     AC_MSG_RESULT([$with_prelink])
468		     ;;
469	     esac],
470	    [with_prelink=no
471			AC_MSG_RESULT(no)
472			]
473)
474AC_SUBST(ELFLIB)
475
476AC_MSG_CHECKING(for xattr-support)
477AC_ARG_WITH([xattr],
478	[AC_HELP_STRING([--with-xattr],
479		[use xattr (no checking)])],
480	[with_xattr_support="$withval"],
481	[with_xattr_support=no]
482)
483
484AS_IF([test "x$with_xattr_support" != xno],
485	[AC_DEFINE(WITH_XATTR,1,[use xattr])
486	ATTRLIB=-lattr
487	compoptionstring="${compoptionstring}WITH_XATTR\\n"
488	AC_MSG_RESULT(yes)],
489	[AC_MSG_RESULT(no)]
490)
491
492AC_SUBST(ATTRLIB)
493
494AC_MSG_CHECKING(for capabilities-support)
495AC_ARG_WITH([capabilities],
496        [AC_HELP_STRING([--with-capabilities],
497                [use caps (no checking)])],
498        [with_capabilities_support="$withval"],
499        [with_capabilities_support=no]
500)
501
502AS_IF([test "x$with_capabilities_support" != xno],
503        [AC_DEFINE(WITH_CAPABILITIES,1,[use capabilities])
504        CAPLIB=-lcap
505        compoptionstring="${compoptionstring}WITH_CAPABILITIES\\n"
506        AC_MSG_RESULT(yes)],
507        [AC_MSG_RESULT(no)]
508)
509
510AC_SUBST(CAPLIB)
511
512AC_MSG_CHECKING(for e2fsattrs-support)
513AC_ARG_WITH([e2fsattrs],
514	[AC_HELP_STRING([--with-e2fsattrs],
515		[use e2fsattrs (no checking)])],
516	[with_e2fsattrs_support="$withval"],
517	[with_e2fsattrs_support=no]
518)
519
520AS_IF([test "x$with_e2fsattrs_support" != xno],
521	[AC_DEFINE(WITH_E2FSATTRS,1,[use e2fsattrs])
522	E2FSATTRSLIB=-le2p
523	compoptionstring="${compoptionstring}WITH_E2FSATTRS\\n"
524	AC_MSG_RESULT(yes)],
525	[AC_MSG_RESULT(no)]
526)
527
528AC_SUBST(E2FSATTRSLIB)
529
530PKG_CHECK_MODULES(CHECK, [check >= 0.9.4], , [AC_MSG_RESULT([Check not found (testing via 'make check' disabled)])])
531AM_CONDITIONAL(HAVE_CHECK, [test "x$CHECK_LIBS" != "x"])
532
533AC_ARG_WITH([config_file],
534	AC_HELP_STRING([--with-config-file=config-file],
535    [specify default config file (use --without-config-file to disable default config file)]),
536    [with_config_file=$withval],[with_config_file=yes])
537
538if test "$with_config_file" != "no"; then
539    if test "$with_config_file" != "yes"; then
540        config_file=$with_config_file
541    else
542        if test "x$sysconfdir" != x'${prefix}/etc'; then
543            config_file=`eval echo "$sysconfdir/aide.conf"`
544        elif test "x$prefix" != xNONE; then
545            config_file="$prefix/etc/aide.conf"
546        else
547            config_file="$ac_default_prefix/etc/aide.conf"
548        fi
549    fi
550    AC_DEFINE_UNQUOTED(CONFIG_FILE,"$config_file",[Location of configuration file])
551fi
552
553AC_ARG_ENABLE([default_db],
554	AC_HELP_STRING([--disable-default-db],
555    [do not set default values for database_in and database_out config options]),
556    [enable_default_db=$enableval],[enable_default_db=yes])
557
558if test "$enable_default_db" == "yes"; then
559
560if test "x$sysconfdir" != x'${prefix}/etc'; then
561	evalled_sysconfdir=`eval echo "$sysconfdir"`
562	default_db="$evalled_sysconfdir/aide.db"
563	default_db_out="$evalled_sysconfdir/aide.db.new"
564elif test "x$prefix" != xNONE; then
565	default_db="$prefix/etc/aide.db"
566	default_db_out="$prefix/etc/aide.db.new"
567else
568	default_db="$ac_default_prefix/etc/aide.db"
569	default_db_out="$ac_default_prefix/etc/aide.db.new"
570fi
571
572AC_DEFINE_UNQUOTED(DEFAULT_DB,"file:$default_db",[Default location of signature database])
573AC_DEFINE_UNQUOTED(DEFAULT_DB_OUT,"file:$default_db_out",[Default output location for newly-generated signature database])
574
575fi
576
577dnl Do the library tests with the static flag
578LDFLAGS="$LDFLAGS $LD_STATIC_FLAG"
579if test x$with_zlib = xyes; then
580  AC_CHECK_HEADERS(zlib.h,[],
581 	[AC_MSG_ERROR([You don't have zlib properly installed. Install it or try --without-zlib.])])
582  save_LDFLAGS=$LDFLAGS
583  AC_CHECK_LIB(z, deflate,[],
584 	  [AC_MSG_ERROR([You don't have zlib properly installed. Install it or try --without-zlib.])]
585  )
586  AC_DEFINE(WITH_ZLIB,1,[use zlib])
587  compoptionstring="${compoptionstring}WITH_ZLIB\\n"
588fi
589
590AC_ARG_WITH([curl],
591 AS_HELP_STRING([--with-curl],
592  [use curl library for http, https and ftp database backend (default: no)]),
593 [with_curl=$withval], [with_curl=no])
594AS_IF([test "x$with_curl" = "xyes"], [
595       if test "$aide_static_choice" == "yes"; then
596           PKG_CHECK_MODULES_STATIC(CURL, [libcurl], , [AC_MSG_RESULT([libcurl not found by pkg-config - Try --without-curl or add directory containing libcurl.pc to PKG_CONFIG_PATH environment variable])])
597        else
598           PKG_CHECK_MODULES(CURL, [libcurl], , [AC_MSG_RESULT([libcurl not found by pkg-config - Try --without-curl or add directory containing libcurl.pc to PKG_CONFIG_PATH environment variable])])
599        fi
600        AC_DEFINE(WITH_CURL,1,[Define to 1 if libcurl is available])
601        compoptionstring="${compoptionstring}WITH_CURL\\n"
602])
603AM_CONDITIONAL(USE_CURL, [test "x$CURL_LIBS" != "x"])
604
605AC_ARG_WITH(mhash,
606	AC_HELP_STRING([--with-mhash],
607		[use libmhash, needed for hmacs @<:@default=check@:>@]),
608	[],
609	[with_mhash=check]
610)
611
612AS_IF([test "x$with_mhash" != xno],
613	AC_CHECK_LIB([mhash],[mhash_get_block_size],
614		[CRYPTLIB="${CRYPTLIB} -lmhash"
615		compoptionstring="${compoptionstring}WITH_MHASH\\n"
616		with_mhash=yes
617		AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
618		[[#include <mhash.h>
619		int i=MHASH_WHIRLPOOL;
620		]])],AC_DEFINE(HAVE_MHASH_WHIRLPOOL,1,[mhash has whirlpool]))
621		AC_DEFINE(WITH_MHASH,1,[use mhash library])],
622		[AC_MSG_WARN(No mhash means no hmac.)]
623	)
624)
625
626AC_ARG_WITH([gcrypt],
627	[AC_HELP_STRING([--with-gcrypt],
628		[use gcrypt library])],
629		[],
630		[if test "x$with_mhash" != xyes; then
631			with_gcrypt=check
632		else
633			with_gcrypt=no
634		fi]
635)
636
637AS_IF([test "x$with_gcrypt" != xno],
638	[AC_DEFINE(WITH_GCRYPT,1,[use gcrypt library])
639	if test "x$with_mhash" = xyes; then
640		AC_MSG_ERROR([Using gcrypt together with mhash makes no sense. To disable mhash use --without-mhash])
641	fi
642	AC_CHECK_LIB([gpg-error], [gpg_strerror],
643		[saveLIBS="$LIBS"
644		LIBS="$LIBS -lgpg-error"
645		AC_CHECK_LIB([gcrypt], [gcry_md_hash_buffer],[],
646			AC_MSG_ERROR([Aide requires mhash or libcrypt to be installed with static libraries.])
647		)
648		LIBS="$saveLIBS"],
649		[AC_MSG_ERROR([You need to have libgpg-error.a installed to use libgcrypt.])]
650	)
651	CRYPTLIB="${CRYPTLIB} -lgcrypt -lgpg-error"
652	with_gcrypt=yes
653	compoptionstring="${compoptionstring}WITH_GCRYPT\\n"],
654	[with_gcrypt=no]
655)
656
657AC_SUBST(CRYPTLIB)
658
659# Check for Linux auditing API
660#
661AC_ARG_WITH([audit],
662	[AC_HELP_STRING([--with-audit],
663		[use audit library])],
664	[],
665	[with_audit=no]
666)
667
668AS_IF([test "x$with_audit" != xno],
669	[AC_DEFINE(WITH_AUDIT,1,[use audit library])
670	AC_CHECK_HEADER(libaudit.h,,
671		AC_MSG_ERROR(You don't have libaudit properly installed. Install it if you need it.)
672	)
673	AUDITLIB="-laudit"
674	if test "$aide_static_choice" == "yes"; then
675		saveLIBS=$LIBS
676		LIBS="-static $AUDITLIB"
677		AC_CHECK_LIB([audit], [audit_log_user_message], [], [
678			LIBS="$LIBS -lcap-ng"
679			AC_CHECK_LIB([cap-ng], [audit_log_user_message], [AUDITLIB="$AUDITLIB -lcap-ng"],
680			AC_MSG_ERROR([You don't have libaudit properly installed. Install it or try --without-audit.])
681			, [])
682		], [])
683		LIBS=$saveLIBS
684	fi
685	compoptionstring="${compoptionstring}WITH_AUDIT\\n"],
686	[with_audit=no]
687)
688AC_SUBST(AUDITLIB)
689
690extrasub="s&@AIDEVERSION@&$PACKAGE_VERSION&;t t"
691
692AC_DEFINE_UNQUOTED(AIDECOMPILEOPTIONS, "${compoptionstring}",[Compile-time options displayed in -v output])
693
694dnl Add in the optional compiler features
695LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
696CFLAGS="$CFLAGS $EXTRA_CFLAGS"
697
698AC_SUBST(AIDE_DEFS)
699AC_OUTPUT(Makefile)
700
701