1156283Srwatson#                                               -*- Autoconf -*-
2156283Srwatson# Process this file with autoconf to produce a configure script.
3156283Srwatson
4156283SrwatsonAC_PREREQ(2.59)
5292432SbruefferAC_INIT([OpenBSM], [1.2-alpha4], [trustedbsd-audit@TrustedBSD.org],[openbsm])
6243750SrwatsonAC_CONFIG_MACRO_DIR([m4])
7156283SrwatsonAC_CONFIG_SRCDIR([bin/auditreduce/auditreduce.c])
8156283SrwatsonAC_CONFIG_AUX_DIR(config)
9243750SrwatsonAC_CONFIG_MACRO_DIR([m4])
10156283SrwatsonAC_CONFIG_HEADER([config/config.h])
11156283SrwatsonAM_MAINTAINER_MODE
12156283Srwatson
13185573Srwatson# --with-native-includes forces the use of the system bsm headers.
14185573SrwatsonAC_ARG_WITH([native-includes],
15185573Srwatson[AS_HELP_STRING([--with-native-includes],
16185573Srwatson[Use the system native include files instead of those included with openbsm.])],
17185573Srwatson[
18185573SrwatsonAC_DEFINE(USE_NATIVE_INCLUDES,, Define to use native include files)
19185573Srwatsonuse_native_includes=true
20185573Srwatson],
21185573Srwatson[use_native_includes=false])
22185573SrwatsonAM_CONDITIONAL(USE_NATIVE_INCLUDES, $use_native_includes)
23185573Srwatson
24185573SrwatsonAC_PATH_PROGS(MIG, mig)
25185573Srwatson
26156283Srwatson# Checks for programs.
27156283SrwatsonAC_PROG_CC
28156283SrwatsonAC_PROG_INSTALL
29243750SrwatsonAC_PROG_LEX
30156283SrwatsonAC_PROG_LIBTOOL
31292432SbruefferAC_PROG_LN_S
32243750SrwatsonAC_PROG_YACC
33156283Srwatson
34156283SrwatsonAM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
35156283Srwatson
36159248SrwatsonAC_SEARCH_LIBS(dlsym, dl)
37243750SrwatsonAC_SEARCH_LIBS(pthread_create, pthread)
38159248SrwatsonAC_SEARCH_LIBS(clock_gettime, rt)
39243750SrwatsonAC_SEARCH_LIBS(SSL_connect, ssl)
40243750SrwatsonAC_SEARCH_LIBS(humanize_number, util)
41243750SrwatsonAC_SEARCH_LIBS(pidfile_open, util)
42156283Srwatson
43156283Srwatson# Checks for header files.
44156283SrwatsonAC_HEADER_STDC
45156283SrwatsonAC_HEADER_SYS_WAIT
46243750SrwatsonAC_CHECK_HEADERS([mach/mach.h stdint.h pthread_np.h printf.h])
47156283Srwatson
48191273SrwatsonAC_DEFINE([_GNU_SOURCE],,[Use extended API on platforms that require it])
49191273Srwatson
50156283Srwatson# Checks for typedefs, structures, and compiler characteristics.
51156283SrwatsonAC_C_CONST
52156283SrwatsonAC_TYPE_UID_T
53156283SrwatsonAC_TYPE_PID_T
54156283SrwatsonAC_TYPE_SIZE_T
55156283SrwatsonAC_CHECK_MEMBERS([struct stat.st_rdev])
56156283Srwatson
57156283SrwatsonAC_CHECK_MEMBER([struct ipc_perm.__key],
58156283Srwatson[AC_DEFINE(HAVE_IPC_PERM___KEY,, Define if ipc_perm.__key instead of key)],
59156283Srwatson[],[
60156283Srwatson#include <sys/types.h>
61156283Srwatson#include <sys/ipc.h>
62156283Srwatson])
63156283Srwatson
64185573SrwatsonAC_CHECK_MEMBER([struct ipc_perm._key],
65185573Srwatson[AC_DEFINE(HAVE_IPC_PERM__KEY,, Define if ipc_perm._key instead of key)],
66185573Srwatson[],[
67185573Srwatson#include <sys/types.h>
68185573Srwatson#include <sys/ipc.h>
69185573Srwatson])
70185573Srwatson
71156283SrwatsonAC_CHECK_MEMBER([struct ipc_perm.__seq],
72156283Srwatson[AC_DEFINE(HAVE_IPC_PERM___SEQ,, Define if ipc_perm.__seq instead of seq)],
73156283Srwatson[],[
74156283Srwatson#include <sys/types.h>
75156283Srwatson#include <sys/ipc.h>
76156283Srwatson])
77156283Srwatson
78185573SrwatsonAC_CHECK_MEMBER([struct ipc_perm._seq],
79185573Srwatson[AC_DEFINE(HAVE_IPC_PERM__SEQ,, Define if ipc_perm._seq instead of seq)],
80185573Srwatson[],[
81185573Srwatson#include <sys/types.h>
82185573Srwatson#include <sys/ipc.h>
83185573Srwatson])
84185573Srwatson
85243750SrwatsonAC_CHECK_MEMBER([struct sockaddr_storage.ss_len],
86243750Srwatson[AC_DEFINE(HAVE_SOCKADDR_STORAGE_SS_LEN,, Define if sockaddr_storage.ss_len field exists)],
87243750Srwatson[],[
88243750Srwatson#include <sys/types.h>
89243750Srwatson#include <sys/socket.h>
90243750Srwatson])
91243750Srwatson
92156283SrwatsonAC_HEADER_TIME
93156283SrwatsonAC_STRUCT_TM
94156283Srwatson
95156283Srwatson# Checks for library functions.
96156283SrwatsonAC_FUNC_CHOWN
97156283SrwatsonAC_FUNC_FORK
98156283SrwatsonAC_FUNC_MALLOC
99156283SrwatsonAC_FUNC_MKTIME
100156283SrwatsonAC_TYPE_SIGNAL
101156283SrwatsonAC_FUNC_STAT
102156283SrwatsonAC_FUNC_STRFTIME
103243750SrwatsonAC_CHECK_FUNCS([arc4random arc4random_buf bzero cap_enter clock_gettime closefrom faccessat fdopendir fstatat ftruncate getresgid getresuid gettimeofday inet_ntoa jail kqueue memset openat pthread_cond_timedwait_relative_np pthread_condattr_setclock pthread_mutex_lock renameat setproctitle sigtimedwait strchr strerror strlcat strlcpy strndup strrchr strstr strtol strtoul unlinkat vis])
104156283Srwatson
105156283Srwatson# sys/queue.h exists on most systems, but its capabilities vary a great deal.
106159985Srwatson# test for LIST_FIRST and TAILQ_FOREACH_SAFE, which appears to not exist in
107159985Srwatson# all of them, and are necessary for OpenBSM.
108156283SrwatsonAC_TRY_LINK([
109156283Srwatson	#include <sys/queue.h>
110156283Srwatson], [
111156283Srwatson
112159985Srwatson	#ifndef LIST_FIRST
113159985Srwatson	#error LIST_FIRST missing
114159985Srwatson	#endif
115159985Srwatson	#ifndef TAILQ_FOREACH_SAFE
116159985Srwatson	#error TAILQ_FOREACH_SAFE
117159985Srwatson	#endif
118156283Srwatson], [
119156283SrwatsonAC_DEFINE(HAVE_FULL_QUEUE_H,, Define if queue.h includes LIST_FIRST)
120156283Srwatson])
121156283Srwatson
122156283Srwatson# Systems may not define key audit system calls, in which case libbsm cannot
123156283Srwatson# depend on them or it will generate link-time or run-time errors.  Test for
124156283Srwatson# just one.
125156283SrwatsonAC_TRY_LINK([
126186647Srwatson	#include <stddef.h>
127156283Srwatson
128156283Srwatson	extern int auditon(int, void *, int);
129156283Srwatson], [
130156283Srwatson	int err;
131156283Srwatson
132156283Srwatson	err = auditon(0, NULL, 0);
133156283Srwatson], [
134156283SrwatsonAC_DEFINE(HAVE_AUDIT_SYSCALLS,, Define if audit system calls present)
135156283Srwatsonhave_audit_syscalls=true
136156283Srwatson], [
137156283Srwatsonhave_audit_syscalls=false
138156283Srwatson])
139156283SrwatsonAM_CONDITIONAL(HAVE_AUDIT_SYSCALLS, $have_audit_syscalls)
140156283Srwatson
141186647Srwatson#
142243750Srwatson# We rely on the BSD be32toh() and be32enc()-style endian macros to perform
143243750Srwatson# byte order conversions.  Availability of these varies considerably -- in
144243750Srwatson# general, a system might have neither, be32toh(), or be32toh() and be32enc().
145243750Srwatson# There is also variation in which headers are even present, and whether they
146243750Srwatson# are macros or functions.  Try to organise the world into some simpler cases.
147243750Srwatson# The following macros may be set at the end:
148186647Srwatson#
149243750Srwatson# USE_ENDIAN_H
150243750Srwatson# USE_SYS_ENDIAN_H
151243750Srwatson# USE_MACHINE_ENDIAN_H
152243750Srwatson# USE_COMPAT_ENDIAN_H
153243750Srwatson# USE_COMPAT_ENDIAN_ENC_H
154243750Srwatson#
155243750Srwatson# First, decide which system endian.h to use.
156243750Srwatson#
157243750SrwatsonAC_CHECK_HEADERS([endian.h], [
158243750Srwatson	have_endian_h=yes
159243750Srwatson], [
160243750Srwatson	have_endian_h=no
161243750Srwatson])
162243750Srwatson
163243750SrwatsonAC_CHECK_HEADERS([sys/endian.h], [
164243750Srwatson	have_sys_endian_h=yes
165243750Srwatson], [
166243750Srwatson	have_sys_endian_h=no
167243750Srwatson])
168243750Srwatson
169243750SrwatsonAC_CHECK_HEADERS([machine/endian.h], [
170243750Srwatson	have_machine_endian_h=yes
171243750Srwatson], [
172243750Srwatson	have_machine_endian_h=no
173243750Srwatson])
174243750Srwatson
175243750Srwatsonif test $have_endian_h = yes; then
176243750Srwatson	AC_DEFINE(USE_ENDIAN_H,, Define if endian.h should be included)
177243750Srwatsonelif test $have_sys_endian_h = yes; then
178243750Srwatson	AC_DEFINE(USE_SYS_ENDIAN_H,, Define if sys/endian.h should be included)
179243750Srwatsonelif test $have_machine_endian_h = yes; then
180243750Srwatson	AC_DEFINE(USE_MACHINE_ENDIAN_H,, Define if machine/endian.h should be included)
181243750Srwatsonelse
182243750Srwatson	AC_MSG_ERROR([no endian.h])
183243750Srwatsonfi
184243750Srwatson
185243750Srwatson#
186243750Srwatson# Next, decide if we need to supplement with compat headers.
187243750Srwatson#
188186647SrwatsonAC_TRY_LINK([
189243750Srwatson	#ifdef USE_ENDIAN_H
190243750Srwatson	#include <endian.h>
191243750Srwatson	#endif
192243750Srwatson	#ifdef USE_SYS_ENDIAN_H
193186647Srwatson	#include <sys/endian.h>
194243750Srwatson	#endif
195243750Srwatson	#ifdef USE_MACHINE_ENDIAN_H
196243750Srwatson	#include <machine/endian.h>
197243750Srwatson	#endif
198243750Srwatson], [
199243750Srwatson	(void)be32toh(0);
200243750Srwatson], [], [
201243750Srwatson	AC_DEFINE(USE_COMPAT_ENDIAN_H,, Define if compat/endian.h is required)
202243750Srwatson	AC_MSG_RESULT([using compat/endian.h])
203243750Srwatson])
204243750Srwatson
205243750SrwatsonAC_TRY_LINK([
206243750Srwatson	#ifdef USE_ENDIAN_H
207243750Srwatson	#include <endian.h>
208243750Srwatson	#endif
209243750Srwatson	#ifdef USE_SYS_ENDIAN_H
210243750Srwatson	#include <sys/endian.h>
211243750Srwatson	#endif
212243750Srwatson	#ifdef USE_MACHINE_ENDIAN_H
213243750Srwatson	#include <machine/endian.h>
214243750Srwatson	#endif
215243750Srwatson	#ifdef USE_COMPAT_ENDIAN_H
216243750Srwatson	#include "compat/endian.h"
217243750Srwatson	#endif
218186647Srwatson	#include <stdlib.h>
219186647Srwatson], [
220244265Srwatson	int i;
221244265Srwatson
222244265Srwatson	i = bswap16(0);
223244265Srwatson	i = bswap32(0);
224244265Srwatson	i = bswap64(0);
225243750Srwatson	be32enc(NULL, 0);
226244265Srwatson	i = htole64(0);
227244265Srwatson	i = le64toh(0);
228243750Srwatson], [], [
229243750Srwatson	AC_DEFINE(USE_COMPAT_ENDIAN_ENC_H,, Define if compat/endian_enc.h is required)
230243750Srwatson	AC_MSG_RESULT([using compat/endian_enc.h])
231186647Srwatson])
232186647Srwatson
233185573Srwatson# Check to see if Mach IPC is used for trigger messages.  If so, use Mach IPC
234185573Srwatson# instead of the default for sending trigger messages to the audit components.
235185573SrwatsonAC_CHECK_FILE([/usr/include/mach/audit_triggers.defs], [
236185573SrwatsonAC_DEFINE(USE_MACH_IPC,, Define if uses Mach IPC for Triggers messages)
237185573Srwatsonuse_mach_ipc=true
238185573Srwatson], [
239185573Srwatsonuse_mach_ipc=false
240185573Srwatson])
241185573SrwatsonAM_CONDITIONAL(USE_MACH_IPC, $use_mach_ipc)
242185573Srwatson
243156283SrwatsonAC_CONFIG_FILES([Makefile
244156283Srwatson                 bin/Makefile
245156283Srwatson                 bin/audit/Makefile
246156283Srwatson                 bin/auditd/Makefile
247243750Srwatson                 bin/auditdistd/Makefile
248159248Srwatson                 bin/auditfilterd/Makefile
249156283Srwatson                 bin/auditreduce/Makefile
250156283Srwatson                 bin/praudit/Makefile
251156283Srwatson                 bsm/Makefile
252186647Srwatson                 libauditd/Makefile
253156283Srwatson                 libbsm/Makefile
254159248Srwatson                 modules/Makefile
255159248Srwatson                 modules/auditfilter_noop/Makefile
256156283Srwatson                 man/Makefile
257185573Srwatson                 sys/Makefile
258185573Srwatson                 sys/bsm/Makefile
259159248Srwatson                 test/Makefile
260159248Srwatson                 test/bsm/Makefile
261156283Srwatson                 tools/Makefile])
262156283Srwatson
263156283SrwatsonAC_OUTPUT
264