Debian Codegraph @

configure.ac

raw
1 AC_PREREQ([2.69])
2
3 m4_include([version.m4])
4
5 dnl Initialize autoconf/automake
6 AC_INIT([aide],[AIDE_VERSION])
7 AC_CANONICAL_TARGET
8 AM_INIT_AUTOMAKE([1.10 -Wall -Werror silent-rules subdir-objects serial-tests])
9
10 AC_DEFINE_UNQUOTED(AIDEVERSION, "AIDE_VERSION")
11 AH_TEMPLATE([AIDEVERSION], [package version])
12
13 dnl The name of the configure h-file.
14 AC_CONFIG_HEADERS(include/config.h)
15
16 dnl Checks for programs.
17 AC_PROG_CC
18 if test "x$ac_cv_prog_cc_c99" = xno; then
19 AC_MSG_ERROR([AIDE needs a C99 compatible compiler])
20 fi
21
22 AC_PROG_MAKE_SET
23 AC_PROG_RANLIB
24 AC_PROG_INSTALL
25 AC_PROG_YACC
26 if test "x${YACC}" != "xbison -y"; then
27 echo "AIDE requires GNU bison"
28 exit 5
29 fi
30
31 AC_PROG_LEX(noyywrap)
32 if test "x${LEX}" != "xflex"; then
33 echo "AIDE requires GNU flex"
34 exit 5
35 fi
36 AC_CHECK_PROGS(LD, ld)
37
38 AC_PATH_TOOL([PKG_CONFIG], [pkg-config], [no])
39 AM_PROG_CC_C_O
40
41 AC_SYS_LARGEFILE
42
43 dnl AC_ARG_PROGRAM
44
45 AC_ARG_WITH(extra-includes,
46 AS_HELP_STRING([--with-extra-includes],[Specify additional paths with -I to find headerfiles]),
47 [CPPFLAGS="$CPPFLAGS $withval"]
48 )
49 AC_ARG_WITH(extra-libs,
50 AS_HELP_STRING([--with-extra-libs],[Specify additional paths with -L to find libraries]),
51 [LDFLAGS="$LDFLAGS $withval"]
52 )
53 AC_ARG_WITH(extra-link-libs,
54 AS_HELP_STRING([--with-extra-link-libs],[Specify additional libraries to link]),
55 [LIBS="$LIBS $withval"]
56 )
57
58 dnl Do the right thing for glibc...
59 AIDE_DEFS="-D_GNU_SOURCE"
60
61 dnl This is borrowed from libtool
62
63 if test $ac_cv_c_compiler_gnu = yes; then
64 LD_STATIC_FLAG='-static'
65
66 case "$host_os" in
67 beos* | irix5* | irix6* | osf3* | osf4* | osf5*)
68 # PIC is the default for these OSes.
69 ;;
70 aix*)
71 # Below there is a dirty hack to force normal static linking with -ldl
72 # The problem is because libdl dynamically linked with both libc and
73 # libC (AIX C++ library), which obviously doesn't included in libraries
74 # list by gcc. This cause undefined symbols with -static flags.
75 # This hack allows C programs to be linked with "-static -ldl", but
76 # we not sure about C++ programs.
77 LD_STATIC_FLAG="$LD_STATIC_FLAG ${wl}-lC"
78 ;;
79 cygwin* | mingw* | os2*)
80 # We can build DLLs from non-PIC.
81 ;;
82 amigaos*)
83 # FIXME: we need at least 68020 code to build shared libraries, but
84 # adding the `-m68020' flag to GCC prevents building anything better,
85 # like `-m68040'.
86 ## pic_flag='-m68020 -resident32 -malways-restore-a4'
87 ;;
88 sysv4*MP*)
89 ## if test -d /usr/nec; then
90 ## pic_flag=-Kconform_pic
91 ## fi
92 ;;
93 *)
94 ## pic_flag='-fPIC'
95 ;;
96 esac
97 else
98 # PORTME Check for PIC flags for the system compiler.
99 case "$host_os" in
100 aix3* | aix4*)
101 # All AIX code is PIC.
102 LD_STATIC_FLAG='-bnso -bI:/lib/syscalls.exp'
103 ;;
104
105 hpux9* | hpux10* | hpux11*)
106 # Is there a better LD_STATIC_FLAG that works with the bundled CC?
107 ## wl='-Wl,'
108 LD_STATIC_FLAG="${wl}-a ${wl}archive"
109 ## pic_flag='+Z'
110 ;;
111
112 irix5* | irix6*)
113 ## wl='-Wl,'
114 LD_STATIC_FLAG='-non_shared'
115 # PIC (with -KPIC) is the default.
116 ;;
117
118 cygwin* | mingw* | os2*)
119 # We can build DLLs from non-PIC.
120 ;;
121
122 osf3* | osf4* | osf5*)
123 # All OSF/1 code is PIC.
124 ## wl='-Wl,'
125 LD_STATIC_FLAG='-non_shared'
126 ;;
127
128 sco3.2v5*)
129 ## pic_flag='-Kpic'
130 LD_STATIC_FLAG='-dn'
131 ## special_shlib_compile_flags='-belf'
132 ;;
133
134 solaris*)
135 ## pic_flag='-KPIC'
136 LD_STATIC_FLAG='-Bstatic'
137 ## wl='-Wl,'
138 ;;
139
140 sunos4*)
141 ## pic_flag='-PIC'
142 LD_STATIC_FLAG='-Bstatic'
143 ## wl='-Qoption ld '
144 ;;
145
146 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
147 ## pic_flag='-KPIC'
148 LD_STATIC_FLAG='-Bstatic'
149 ## wl='-Wl,'
150 ;;
151
152 uts4*)
153 ## pic_flag='-pic'
154 LD_STATIC_FLAG='-Bstatic'
155 ;;
156 sysv4*MP*)
157 if test -d /usr/nec ;then
158 ## pic_flag='-Kconform_pic'
159 LD_STATIC_FLAG='-Bstatic'
160 fi
161 ;;
162 *)
163 ## can_build_shared=no
164 ;;
165 esac
166 fi
167
168 # Check whether static linking has explicitly been enabled
169 AC_ARG_ENABLE(static,[ --enable-static enable static linking (might increase the security of aide, see README for details)], [aide_static_choice=$enableval], [aide_static_choice=no])
170
171 dnl Borrowed from dbus
172 cc_supports_flag() {
173 AC_MSG_CHECKING(whether $CC supports "$@")
174 Cfile=/tmp/foo${$}
175 touch ${Cfile}.c
176 $CC -c "$@" ${Cfile}.c -o ${Cfile}.o >/dev/null 2>&1
177 rc=$?
178 rm -f ${Cfile}.c ${Cfile}.o
179 case $rc in
180 0) AC_MSG_RESULT(yes);;
181 *) AC_MSG_RESULT(no);;
182 esac
183 return $rc
184 }
185
186 dnl Borrowed from dbus
187 ld_supports_flag() {
188 AC_MSG_CHECKING([whether $LD supports "$@"])
189 AC_LINK_IFELSE([AC_LANG_PROGRAM([
190 int one(void) { return 1; }
191 int two(void) { return 2; }
192 ], [ two(); ] ) ] , [_ac_ld_flag_supported=yes], [_ac_ld_flag_supported=no])
193
194 if test "$_ac_ld_flag_supported" = "yes"; then
195 rm -f conftest.c
196 touch conftest.c
197 if $CC -c conftest.c; then
198 ld_out=`$LD $@ -o conftest conftest.o 2>&1`
199 ld_ret=$?
200 if test $ld_ret -ne 0 ; then
201 _ac_ld_flag_supported=no
202 elif echo "$ld_out" | egrep 'option ignored|^usage:|unrecognized option|illegal option' >/dev/null ; then
203 _ac_ld_flag_supported=no
204 fi
205 fi
206 rm -f conftest.c conftest.o conftest
207 fi
208
209 AC_MSG_RESULT($_ac_ld_flag_supported)
210 if test "$_ac_ld_flag_supported" = "yes" ; then
211 return 0
212 else
213 return 1
214 fi
215 }
216
217 if test "$aide_static_choice" != "yes"; then
218 LD_STATIC_FLAG=""
219 EXTRA_LDFLAGS=""
220 EXTRA_CFLAGS=""
221 if test x$CC = "xgcc"; then
222 if ld_supports_flag -z,relro; then
223 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-z,relro"
224 fi
225 if ld_supports_flag -z,now; then
226 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-z,now"
227 fi
228 if cc_supports_flag -fPIE -DPIE; then
229 EXTRA_CFLAGS="$EXTRA_CFLAGS -fPIE -DPIE"
230 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -pie"
231 fi
232 dnl Check for some optional warnings
233 if cc_supports_flag -Wundef; then
234 EXTRA_CFLAGS="$EXTRA_CFLAGS -Wundef"
235 fi
236 if cc_supports_flag -Wmissing-format-attribute; then
237 EXTRA_CFLAGS="$EXTRA_CFLAGS -Wmissing-format-attribute"
238 fi
239 if cc_supports_flag -Wshadow; then
240 EXTRA_CFLAGS="$EXTRA_CFLAGS -Wshadow"
241 fi
242 if cc_supports_flag -Wlogical-op; then
243 EXTRA_CFLAGS="$EXTRA_CFLAGS -Wlogical-op"
244 fi
245 fi
246 fi
247
248 dnl This macro is new in autoconf-2.13
249 AC_SEARCH_LIBS(syslog, bsd socket inet, [AC_DEFINE(HAVE_SYSLOG,1,[syslog available?])])
250 AC_CHECK_FUNCS(vsyslog)
251
252 AC_C_BIGENDIAN([AC_DEFINE(BIG_ENDIAN_HOST,1,[big endian])], [AC_DEFINE(LITTLE_ENDIAN_HOST,1,[little endian])])
253
254 AC_CHECK_TYPES([byte, ushort, ulong, u16, u32, u64])
255
256 AC_CHECK_SIZEOF(unsigned short, 2)
257 AC_CHECK_SIZEOF(unsigned int, 4)
258 AC_CHECK_SIZEOF(unsigned long, 4)
259 AC_CHECK_SIZEOF(unsigned long long, 8)
260
261 AC_CHECK_SIZEOF(int)
262
263 AC_CHECK_SIZEOF(long long)
264
265 AC_CHECK_SIZEOF(uid_t)
266 AC_CHECK_SIZEOF(gid_t)
267 AC_CHECK_SIZEOF(ino_t)
268 AC_CHECK_SIZEOF(nlink_t)
269 AC_CHECK_SIZEOF(off_t)
270 AC_CHECK_SIZEOF(blkcnt_t)
271
272 AC_CHECK_FUNCS(strtoll strtoimax readdir)
273 AC_CHECK_FUNCS(stricmp strnstr strnlen)
274
275 AC_CHECK_FUNCS(fcntl ftruncate posix_fadvise asprintf snprintf \
276 vasprintf vsnprintf va_copy __va_copy)
277
278 AC_CHECK_FUNCS(sigabbrev_np)
279 AC_CHECK_HEADERS(sys/prctl.h)
280
281 AC_CHECK_HEADERS(syslog.h inttypes.h fcntl.h ctype.h)
282
283 AIDE_PKG_CHECK_MANDATORY(pcre2, PCRE2, libpcre2-8)
284
285 AX_PTHREAD(compoptionstring="${compoptionstring}use pthread: mandatory\\n", [AC_MSG_ERROR([AIDE requires pthread])])
286
287 AC_ARG_WITH([fstype],
288 AS_HELP_STRING([--without-fstype],
289 [Disable file system type support for restricted rules (Linux only)]),
290 [with_fstype=$withval],
291 [with_fstype=yes]
292 )
293 AC_MSG_CHECKING(for fstype support (Linux only))
294 case "${target_os}" in
295 linux*)
296 if test "x$with_fstype" != xno; then
297 AC_DEFINE(HAVE_FSTYPE,1,[file system type support?])
298 fi
299 AC_MSG_RESULT($with_fstype);
300 ;;
301 *)
302 AC_MSG_RESULT(no);
303 ;;
304 esac
305
306 AIDE_PKG_CHECK(zlib, zlib compression, yes, ZLIB, zlib)
307
308 AIDE_PKG_CHECK([posix-acl], POSIX ACLs, no, POSIX_ACL, libacl, acl)
309 if test "x$with_libacl" = xyes; then
310 AC_DEFINE(WITH_ACL, 1, [use ACL])
311 fi
312
313 AIDE_PKG_CHECK(selinux, SELinux, no, SELINUX, libselinux, selinux, >= 3.4)
314
315 AIDE_PKG_CHECK(xattr, xattr, no, XATTR, libattr, xattrs)
316
317 AIDE_PKG_CHECK(capabilities, POSIX 1003.1e capabilities, no, CAPABILITIES, libcap, caps)
318
319 AIDE_PKG_CHECK(e2fsattrs, e2fsattrs, no, E2FSATTRS, e2p, e2fsattrs)
320
321 AIDE_PKG_CHECK(curl, cURL, no, CURL, libcurl)
322
323 AC_MSG_CHECKING(for Nettle)
324 AC_ARG_WITH([nettle], AS_HELP_STRING([--with-nettle], [use Nettle crypto library (default: check)]), [with_nettle=$withval], [with_nettle=check])
325 AC_MSG_RESULT([$with_nettle])
326
327 AC_MSG_CHECKING(for GNU crypto library)
328 AC_ARG_WITH([gcrypt], AS_HELP_STRING([--with-gcrypt], [use GNU crypto library (default: check)]), [with_gcrypt=$withval], [with_gcrypt=check])
329 AC_MSG_RESULT([$with_gcrypt])
330
331 AIDE_PKG_CHECK_MODULES_OPTIONAL(nettle, NETTLE, nettle, >= 3.7)
332 AS_IF([test x"$with_nettle" = xyes], [
333 AS_IF([test x"$with_gcrypt" = xcheck], [ with_gcrypt=no ])
334 ] )
335 AIDE_PKG_CHECK_MODULES_OPTIONAL(gcrypt, GCRYPT, libgcrypt)
336 AS_IF([test x"$with_nettle" != xno && test x"$with_gcrypt" != xno], [
337 AC_MSG_ERROR([Using gcrypt together with Nettle makes no sense. To disable nettle use --without-nettle])
338 ])
339 AS_IF([test x"$with_nettle" = xno && test x"$with_gcrypt" = xno], [
340 AC_MSG_ERROR([AIDE requires nettle or libcrypt for hashsum calculation])
341 ])
342 compoptionstring="${compoptionstring}use Nettle crypto library: $with_nettle\\n"
343 AM_CONDITIONAL(HAVE_NETTLE, [test "x$NETTLE_LIBS" != "x"])
344 compoptionstring="${compoptionstring}use GNU crypto library: $with_gcrypt\\n"
345 AM_CONDITIONAL(HAVE_GCRYPT, [test "x$GCRYPT_LIBS" != "x"])
346
347 AIDE_PKG_CHECK(audit, Linux Auditing Framework, no, AUDIT, audit)
348
349 AIDE_PKG_CHECK_HEADERS(locale, locale, no, LOCALE, [libintl.h])
350 if test "x$with_locale" = xyes; then
351 AC_DEFINE_UNQUOTED(LOCALEDIR,"$prefix/lib/locale",[Localedir to use])
352 fi
353
354 AIDE_COMPILE_TIME_OPTION(syslog_ident, syslog-ident, syslog ident, "aide")
355 AC_DEFINE_UNQUOTED(AIDE_IDENT, "$with_syslog_ident", [syslog ident])
356
357 AIDE_COMPILE_TIME_OPTION(syslog_logopt, syslog-logopt, syslog logopt, LOG_CONS)
358 AC_DEFINE_UNQUOTED(AIDE_LOGOPT, $with_syslog_logopt, [syslog logopt])
359
360 AIDE_COMPILE_TIME_OPTION(syslog_priority, syslog-priority, syslog priority, LOG_NOTICE)
361 AC_DEFINE_UNQUOTED(AIDE_SYSLOG_PRIORITY, $with_syslog_priority, [syslog priority])
362
363 AIDE_COMPILE_TIME_OPTION(syslog_facility, syslog-facility, default syslog facility, LOG_LOCAL0)
364 AC_DEFINE_UNQUOTED(AIDE_SYSLOG_FACILITY, $with_syslog_facility, [syslog facility])
365
366 PKG_CHECK_MODULES(CHECK, [check >= 0.9.4], , [AC_MSG_RESULT([Check not found (testing via 'make check' disabled)])])
367 AM_CONDITIONAL(HAVE_CHECK, [test "x$CHECK_LIBS" != "x"])
368
369 AC_ARG_WITH([config_file],
370 AS_HELP_STRING([--with-config-file=config-file],[specify default config file (use --without-config-file to disable default config file)]),
371 [with_config_file=$withval],[with_config_file=yes])
372
373 if test "$with_config_file" != "no"; then
374 if test "$with_config_file" != "yes"; then
375 config_file=$with_config_file
376 else
377 if test "x$sysconfdir" != x'${prefix}/etc'; then
378 config_file=`eval echo "$sysconfdir/aide.conf"`
379 elif test "x$prefix" != xNONE; then
380 config_file="$prefix/etc/aide.conf"
381 else
382 config_file="$ac_default_prefix/etc/aide.conf"
383 fi
384 fi
385 AC_DEFINE_UNQUOTED(CONFIG_FILE,"$config_file",[Location of configuration file])
386 fi
387
388 AC_ARG_ENABLE([default_db],
389 AS_HELP_STRING([--disable-default-db],[do not set default values for database_in and database_out config options]),
390 [enable_default_db=$enableval],[enable_default_db=yes])
391
392 if test "$enable_default_db" = "yes"; then
393
394 if test "x$sysconfdir" != x'${prefix}/etc'; then
395 evalled_sysconfdir=`eval echo "$sysconfdir"`
396 default_db="$evalled_sysconfdir/aide.db"
397 default_db_out="$evalled_sysconfdir/aide.db.new"
398 elif test "x$prefix" != xNONE; then
399 default_db="$prefix/etc/aide.db"
400 default_db_out="$prefix/etc/aide.db.new"
401 else
402 default_db="$ac_default_prefix/etc/aide.db"
403 default_db_out="$ac_default_prefix/etc/aide.db.new"
404 fi
405
406 AC_DEFINE_UNQUOTED(DEFAULT_DB,"file:$default_db",[Default location of signature database])
407 AC_DEFINE_UNQUOTED(DEFAULT_DB_OUT,"file:$default_db_out",[Default output location for newly-generated signature database])
408
409 fi
410
411 extrasub="s&@AIDEVERSION@&$PACKAGE_VERSION&;t t"
412
413 AC_DEFINE_UNQUOTED(AIDECOMPILEOPTIONS, "${compoptionstring}",[Compile-time options displayed in -v output])
414
415 dnl Add in the optional compiler features
416 LDFLAGS="$LDFLAGS $LD_STATIC_FLAG $EXTRA_LDFLAGS"
417 CFLAGS="$CFLAGS $EXTRA_CFLAGS"
418
419 AC_SUBST(AIDE_DEFS)
420 AC_CONFIG_FILES([Makefile])
421 AC_OUTPUT