source: trunk/configure.ac@ 393

Last change on this file since 393 was 389, checked in by katerina, 13 years ago

Fix for ticket #286 (Combination of --with-gpg and --enable-nocl incorrectly handled by configure).

File size: 78.2 KB
Line 
1dnl We want to override the standard _AC_INIT_PARSE_ARGS
2dnl
3AU_ALIAS([_AC_INIT_PARSE_ARGS], [SH_INIT_PARSE_ARGS])
4AU_ALIAS([_AC_INIT_help], [SH_INIT_HELP])
5
6AC_INIT(src/samhain.c)
7
8
9AC_ARG_VAR([LIBS], [libraries to link against, e.g. -lintl])
10
11dnl
12dnl start
13dnl
14AM_INIT_AUTOMAKE(samhain, 3.0.1)
15AC_DEFINE([SAMHAIN], 1, [Application is samhain])
16AC_CANONICAL_HOST
17
18dnl
19dnl checks for programs
20dnl
21
22AC_PROG_CC
23if test "$host" != "$build"; then
24 AC_CHECK_PROGS(BUILD_CC, gcc cc)
25else
26 BUILD_CC=$CC
27fi
28AC_PROG_CPP
29AC_PROG_INSTALL
30AC_PROG_LN_S
31AC_PROG_AWK
32SH_PROG_LD
33AC_PATH_PROG(cmd_hostname,hostname)
34AC_SUBST(cmd_hostname)
35AC_SUBST(BUILD_CC)
36
37AC_HEADER_STDC
38dnl
39dnl first one is a dummy because of an autoconf bug
40dnl (no HAVE_... for first one)
41dnl
42AC_CHECK_HEADERS([sys/ipc.h sys/msg.h sys/uio.h fcntl.h])
43
44
45AC_MSG_CHECKING([for OS specific issues])
46mydebugflag=no
47myneedg3=no
48uid_cast="signed long"
49selectconfig=linux
50mynetbsd=no
51sh_use_lcaps="undef"
52dnmalloc_ok=yes
53sh_use_pie=yes
54
55case "$host_os" in
56
57 *linux*)
58 sh_use_lcaps="yes"
59 AC_DEFINE(HOST_IS_LINUX)
60 AC_DEFINE(HAVE_EXT2_IOCTLS)
61 AC_MSG_RESULT([use ioctl to get e2fs flags])
62 case "$host_cpu" in
63 i*86*)
64 AC_DEFINE(HOST_IS_I86LINUX)
65 ;;
66 x86_64)
67 AC_DEFINE([HOST_IS_64LINUX], 1, [Define if host OS is 64bit Linux])
68 ;;
69 *)
70 ;;
71 esac
72 ;;
73
74 *osf*)
75 AC_DEFINE([HOST_IS_OSF], 1, [Define if host OS is OSF])
76 if test "x$GCC" != "xyes"; then
77 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
78 CFLAGS="$CFLAGS -O2 -assume noaligned_objects"
79 myneedg3=yes
80 AC_MSG_RESULT([compiler needs assume noaligned_objects])
81 else
82 AC_MSG_RESULT([none])
83 fi
84 ;;
85
86 *cygwin*)
87 AC_DEFINE(HOST_IS_CYGWIN)
88 AC_DEFINE([USE_REGISTRY_CHECK], 1, [Define for registry check])
89 dnmalloc_ok=no
90 AC_MSG_RESULT([no trusted paths and no dnmalloc])
91 ;;
92
93 *darwin*|*apple*)
94 AC_DEFINE(HOST_IS_DARWIN)
95 dnmalloc_ok=no
96 AC_MSG_RESULT([check resource forks, no dnmalloc])
97 ;;
98
99 *freebsd8*|*freebsd9*)
100 AC_DEFINE(HOST_IS_FREEBSD)
101 selectconfig=freebsd
102 case "$host_cpu" in
103 amd64|x86_64)
104 dnmalloc_ok=no
105 AC_MSG_RESULT([no dnmalloc])
106 ;;
107 *)
108 AC_MSG_RESULT([none])
109 ;;
110 esac
111 ;;
112
113 *freebsd7*)
114 AC_DEFINE(HOST_IS_FREEBSD)
115 selectconfig=freebsd
116 case "$host_cpu" in
117 amd64|x86_64)
118 sh_use_pie=no
119 dnmalloc_ok=no
120 AC_MSG_RESULT([no dnmalloc and broken compiler toolchain])
121 ;;
122 *)
123 AC_MSG_RESULT([none])
124 ;;
125 esac
126 ;;
127
128 *freebsd*)
129 AC_DEFINE(HOST_IS_FREEBSD)
130 selectconfig=freebsd
131 AC_MSG_RESULT([none])
132 ;;
133
134 *openbsd*)
135 AC_DEFINE([HOST_IS_OPENBSD], 1, [Define if host OS is OPENBSD])
136 selectconfig=freebsd
137 dnmalloc_ok=no
138 AC_MSG_RESULT([dnmalloc does not work with pthreads])
139 ;;
140
141 *netbsd*)
142 mynetbsd=yes
143 selectconfig=netbsd
144 AC_MSG_RESULT([bug with libresolve])
145 ;;
146
147 *solaris*)
148 selectconfig=solaris
149 AC_DEFINE(HOST_IS_SOLARIS)
150 case "$host_cpu" in
151 i*86)
152 AC_DEFINE(HOST_IS_I86SOLARIS)
153 AC_MSG_RESULT([vsnprintf prototype])
154 ;;
155 *)
156 AC_MSG_RESULT([none])
157 ;;
158 esac
159 if test "x$GCC" != "xyes"; then
160 if test ! -z "`echo "$CFLAGS" | grep "\-g" 2> /dev/null`" ; then
161 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
162 fi
163 if test -z "`echo "$CFLAGS" | grep "\-xO2" 2> /dev/null`"; then
164 CFLAGS="$CFLAGS -xO2"
165 fi
166 if test -z "`echo "$CFLAGS" | grep "\-Xa" 2> /dev/null`"; then
167 CFLAGS="$CFLAGS -Xa"
168 fi
169 LIBS="-lc $LIBS"
170 fi
171 ;;
172
173
174 *sun*)
175 selectconfig=solaris
176 AC_DEFINE(HOST_IS_SOLARIS)
177 AC_MSG_RESULT([none])
178 ;;
179
180 *aix*)
181 AC_DEFINE(HOST_IS_AIX)
182 selectconfig=aix5.2.0
183 uid_cast="unsigned long"
184 if test "x$GCC" != "xyes"; then
185 if test ! -z "`echo "$CFLAGS" | grep "\-g" 2> /dev/null`" ; then
186 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
187 fi
188 if test -z "`echo "$CFLAGS" | grep "\-O3" 2> /dev/null`"; then
189 CFLAGS="$CFLAGS -O3"
190 fi
191 if test -z "`echo "$CFLAGS" | grep "\-qstrict" 2> /dev/null`"; then
192 CFLAGS="$CFLAGS -qstrict"
193 fi
194 AC_MSG_RESULT([AIX size_t in the accept call and optimize O3 qstrict])
195 else
196 AC_MSG_RESULT([AIX size_t in the accept call])
197 fi
198 ;;
199
200 *hpux*)
201 AC_MSG_RESULT([HPUX need _XOPEN_SOURCE_EXTENDED for h_errno])
202 AC_DEFINE(HOST_IS_HPUX)
203 if test "x$GCC" != "xyes"; then
204 if test ! -z "`echo "$CFLAGS" | grep "\-g" 2> /dev/null`" ; then
205 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
206 fi
207 if test -z "`echo "$CFLAGS" | grep "\+O2" 2> /dev/null`"; then
208 CFLAGS="$CFLAGS +O2"
209 fi
210 fi
211 ;;
212
213 *ultrix*)
214 AC_MSG_RESULT([ULTRIX getcwd uses popen])
215 AC_DEFINE(HAVE_BROKEN_GETCWD)
216 ;;
217
218 *)
219 AC_MSG_RESULT([none])
220 ;;
221esac
222
223AC_SUBST(selectconfig)
224AC_DEFINE_UNQUOTED(UID_CAST, ${uid_cast})
225
226
227
228dnl *****************************************
229dnl
230dnl checks for header files
231dnl
232dnl *****************************************
233
234AC_HEADER_DIRENT
235AC_HEADER_MAJOR
236AC_HEADER_TIME
237dnl used in minilzo.c
238AC_HEADER_STAT
239AC_DECL_SYS_SIGLIST
240
241AC_CHECK_HEADERS(stddef.h libgen.h sched.h malloc.h sys/uio.h \
242 sys/mman.h sys/param.h sys/inotify.h \
243 sys/vfs.h mntent.h \
244 sys/select.h sys/socket.h netinet/in.h \
245 regex.h glob.h fnmatch.h \
246 linux/ext2_fs.h linux/fs.h ext2fs/ext2_fs.h asm/segment.h \
247 elf.h linux/elf.h auparse.h \
248 paths.h arpa/nameser.h arpa/nameser_compat.h \
249 rpc/rpcent.h rpc/rpc.h sys/statvfs.h,
250 [],
251 [],
252 [#include <sys/types.h>]
253)
254
255
256AC_CHECK_HEADER(utmpx.h, sh_utmpx="yes", sh_utmpx="no")
257if test "x$sh_utmpx" = "xyes"; then
258 if cat "/usr/include/utmpx.h" 2>&5 |
259 egrep "WTMPX_FILE" >/dev/null 2>&1; then
260 AC_DEFINE(HAVE_UTMPX_H)
261 AC_EGREP_HEADER(ut_host, utmpx.h, AC_DEFINE(HAVE_UTHOST) )
262 AC_EGREP_HEADER(ut_addr, utmpx.h, AC_DEFINE(HAVE_UTADDR) )
263 AC_EGREP_HEADER(ut_addr_v6, utmpx.h, AC_DEFINE(HAVE_UTADDR_V6) )
264 AC_EGREP_HEADER(ut_xtime,utmpx.h, AC_DEFINE(HAVE_UTXTIME) )
265 AC_EGREP_HEADER(ut_type, utmpx.h, AC_DEFINE(HAVE_UTTYPE) )
266 else
267 AC_EGREP_HEADER(ut_addr, utmp.h, AC_DEFINE(HAVE_UTADDR) )
268 AC_EGREP_HEADER(ut_host, utmp.h, AC_DEFINE(HAVE_UTHOST) )
269 AC_EGREP_HEADER(ut_type, utmp.h, AC_DEFINE(HAVE_UTTYPE) )
270 fi
271else
272 AC_EGREP_HEADER(ut_host, utmp.h, AC_DEFINE(HAVE_UTHOST) )
273 AC_EGREP_HEADER(ut_type, utmp.h, AC_DEFINE(HAVE_UTTYPE) )
274fi
275
276dnl
277dnl figure out where acct.h lives
278dnl and whether fields are int/comp_t
279dnl
280dnl GNU Accounting Utilities
281dnl Copyright (C) 1993, 1996, 1997, 2003, 2005 Free Software Foundation, Inc.
282dnl The GNU Accounting Utilities are free software; you can redistribute
283dnl them and/or modify them under the terms of the GNU General Public
284dnl License as published by the Free Software Foundation; either version
285dnl 2, or (at your option) any later version.
286dnl
287AC_CHECK_HEADER(sys/acct.h,
288 AC_DEFINE(HAVE_SYS_ACCT_H, ,
289 [Define if you have the <sys/acct.h> header file.])
290 AC_HEADER_EGREP(ac_utime, sys/acct.h,
291 AC_DEFINE(HAVE_ACUTIME, ,
292 [Define if <sys/acct.h> has the AC_UTIME field.])
293 AC_HEADER_EGREP(comp_t.*ac_utime, sys/acct.h,
294 AC_DEFINE(ACUTIME_COMPT, ,
295 [Define if <sys/acct.h>'s AC_UTIME field is a COMP_T.]))
296 )
297 AC_HEADER_EGREP(ac_stime, sys/acct.h,
298 AC_DEFINE(HAVE_ACSTIME, ,
299 [Define if <sys/acct.h> has the AC_STIME field.])
300 AC_HEADER_EGREP(comp_t.*ac_stime, sys/acct.h,
301 AC_DEFINE(ACSTIME_COMPT, ,
302 [Define if <sys/acct.h>'s AC_STIME field is a COMP_T.]))
303 )
304 AC_HEADER_EGREP(ac_etime, sys/acct.h,
305 AC_DEFINE(HAVE_ACETIME, ,
306 [Define if <sys/acct.h> has the AC_ETIME field.])
307 AC_HEADER_EGREP(comp_t.*ac_etime, sys/acct.h,
308 AC_DEFINE(ACETIME_COMPT, ,
309 [Define if <sys/acct.h>'s AC_ETIME field is a COMP_T.]))
310 )
311 AC_HEADER_EGREP(ac_io, sys/acct.h,
312 AC_DEFINE(HAVE_ACIO, ,
313 [Define if <sys/acct.h> has the AC_IO field.])
314 AC_HEADER_EGREP(comp_t.*ac_io, sys/acct.h,
315 AC_DEFINE(ACIO_COMPT, ,
316 [Define if <sys/acct.h>'s AC_IO field is a COMP_T.]))
317 )
318 AC_HEADER_EGREP(ac_mem, sys/acct.h,
319 AC_DEFINE(HAVE_ACMEM, ,
320 [Define if <sys/acct.h> has the AC_MEM field.])
321 AC_HEADER_EGREP(comp_t.*ac_mem, sys/acct.h,
322 AC_DEFINE(ACMEM_COMPT, ,
323 [Define if <sys/acct.h>'s AC_MEM field is a COMP_T.]))
324 )
325 AC_HEADER_EGREP(ac_minflt, sys/acct.h,
326 AC_HEADER_EGREP(ac_majflt, sys/acct.h,
327 AC_HEADER_EGREP(ac_swaps, sys/acct.h,
328 AC_DEFINE(HAVE_PAGING, ,
329 [Define if <sys/acct.h> has the AC_MINFLT, AC_MAJFLT and AC_SWAPS fields.])
330 AC_HEADER_EGREP(comp_t.*ac_minflt, sys/acct.h,
331 AC_DEFINE(ACMINFLT_COMPT, ,
332 [Define if <sys/acct.h>'s AC_MINFLT field is a COMP_T.]))
333 AC_HEADER_EGREP(comp_t.*ac_mayflt, sys/acct.h,
334 AC_DEFINE(ACMAJFLT_COMPT, ,
335 [Define if <sys/acct.h>'s AC_MAJFLT field is a COMP_T.]))
336 AC_HEADER_EGREP(comp_t.*ac_swaps, sys/acct.h,
337 AC_DEFINE(ACSWAPS_COMPT, ,
338 [Define if <sys/acct.h>'s AC_SWAPS field is a COMP_T.]))
339 )
340 )
341 )
342 AC_HEADER_EGREP(comp_t, sys/acct.h, AC_DEFINE(HAVE_COMP_T, ,
343 [Define if <sys/acct.h> uses the COMP_T type.]))
344 AC_HEADER_EGREP([struct acct_v3], sys/acct.h, AC_DEFINE(HAVE_ACCT_V3, ,
345 [Define if <sys/acct.h> has struct acct_v3.]))
346 AC_HEADER_EGREP([struct acctv2], sys/acct.h, AC_DEFINE(HAVE_ACCTV2, ,
347 [Define if <sys/acct.h> has struct acctv2.]))
348
349 )
350
351
352dnl need to check because AIX 4.2 does not have it
353dnl
354AC_CHECK_MEMBERS([struct statfs.f_flags],[],[],[
355#ifdef HAVE_SYS_TYPES_H
356#include <sys/types.h>
357#endif
358#ifdef HAVE_SYS_STAT_H
359#include <sys/stat.h>
360#endif
361#ifdef HAVE_SYS_VFS_H
362#include <sys/vfs.h>
363#endif
364#ifdef HAVE_UNISTD_H
365#include <unistd.h>
366#endif
367])
368
369AC_SYS_LARGEFILE
370
371dnl
372dnl check whether _POSIX_SOURCE is required
373dnl
374SAMHAIN_POSIX
375
376
377dnl *****************************************
378dnl
379dnl Checks for library functions.
380dnl
381dnl *****************************************
382AC_FUNC_STRFTIME
383AC_CHECK_FUNCS(memcmp memcpy memmove memset getpwent endpwent \
384 gettimeofday strlcat strlcpy strstr strchr strerror strsignal \
385 seteuid setreuid setresuid lstat getwd getcwd ptrace \
386 usleep setpriority getpeereid nanosleep \
387 strptime basename sched_yield hasmntopt \
388 inet_aton gethostbyname setutent setrlimit gethostname uname \
389 getaddrinfo getnameinfo \
390 initgroups getpagesize \
391 ttyname fchmod writev mmap tzset \
392 getsid getpriority getpgid statvfs \
393 strerror_r getgrgid_r getpwnam_r getpwuid_r \
394 gmtime_r localtime_r rand_r readdir_r strtok_r \
395 mincore posix_fadvise inotify_init1
396)
397AC_CHECK_FUNC(statfs, AC_DEFINE(HAVE_STATFS) statfs="yes", statfs="no")
398SL_CHECK_VA_COPY
399AC_CHECK_FUNCS(vsnprintf, [SL_CHECK_VSNPRINTF])
400AC_CHECK_MLOCK
401SH_STRFTIME_Z
402
403AC_MSG_CHECKING(how to get filesystem type)
404fstype=no
405# The order of these tests is important.
406AC_TRY_CPP([#include <sys/statvfs.h>
407#include <sys/fstyp.h>], AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4)
408if test $fstype = no; then
409AC_TRY_CPP([#include <sys/statfs.h>
410#include <sys/fstyp.h>], AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3)
411fi
412if test $fstype = no; then
413AC_TRY_CPP([#include <sys/statfs.h>
414#include <sys/vmount.h>], AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX)
415fi
416if test $fstype = no; then
417AC_TRY_CPP([#include <mntent.h>], AC_DEFINE(FSTYPE_MNTENT) fstype=4.3BSD)
418fi
419if test $fstype = no; then
420AC_EGREP_HEADER(f_type;, sys/mount.h, AC_DEFINE(FSTYPE_STATFS) fstype=4.4BSD/OSF)
421fi
422if test $fstype = no; then
423AC_TRY_CPP([#include <sys/mount.h>
424#include <sys/fs_types.h>], AC_DEFINE(FSTYPE_GETMNT) fstype=Ultrix)
425fi
426AC_MSG_RESULT($fstype)
427
428sh_libsocket=
429
430dnl Solaris needs -lsocket and -lnsl. Unisys system includes
431dnl gethostbyname in libsocket but needs libnsl for socket.
432AC_CHECK_LIB(nsl, gethostbyname)
433AC_CHECK_LIB(socket, socket, ac_need_libsocket=1, ac_try_nsl=1)
434if test x$ac_need_libsocket = x1; then
435 LIBS="$LIBS -lsocket"
436 sh_libsocket="-lsocket"
437fi
438if test x$ac_try_nsl = x1; then
439 AC_CHECK_LIB(nsl, gethostbyname, ac_need_libnsl=1)
440 if test x$ac_need_libnsl = x1
441 then
442 LIBS="$LIBS -lnsl"
443 fi
444fi
445AC_SUBST(sh_libsocket)
446
447AC_CHECK_LIB(socket, res_search, [
448 AC_CHECK_LIB(resolv, dn_skipname)
449 AC_CHECK_LIB(resolv, __dn_skipname)
450 if test x$ac_need_libsocket = x1; then
451 :
452 else
453 LIBS="$LIBS -lsocket"
454 fi
455 ], [
456 AC_CHECK_LIB(resolv, res_search, [
457 LIBS="$LIBS -lresolv"
458 ], [
459 AC_CHECK_LIB(resolv, dn_skipname)
460 AC_CHECK_LIB(resolv, __dn_skipname)
461 ])
462 ])
463
464sh_auparse=no
465
466if test "x$ac_cv_header_auparse_h" = "xyes"
467then
468 AC_CHECK_LIB(auparse, auparse_find_field, [
469 LIBS="$LIBS -lauparse"
470 sh_auparse=yes
471 AC_DEFINE(HAVE_AUPARSE_LIB, 1, [Define if you have the auparse lib])
472 ])
473fi
474
475dnl arguments for accept
476
477dnl check for Unix98 socklen_t (found on
478dnl xemacs-patches mailing list, written
479dnl by Martin Buchholz)
480dnl
481dnl On Darwin(MacOSX) socklen_t needs to be
482dnl an int (see accept man page), on all other
483dnl unix systems we need a size_t.
484
485AC_MSG_CHECKING(for socklen_t)
486AC_TRY_COMPILE([
487#ifdef HAVE_SYS_TYPES_H
488#include <sys/types.h>
489#endif
490#ifdef HAVE_SYS_SOCKET_H
491#include <sys/socket.h>
492#endif
493 socklen_t x;
494], [],[
495 AC_MSG_RESULT(yes)
496 AC_DEFINE_UNQUOTED([ACCEPT_TYPE_ARG3],[socklen_t], [type of arg3 of accept])
497 AC_DEFINE([HAVE_SOCKLEN_T], 1, [Define if you have socklen_t])
498],[
499 AC_TRY_COMPILE([
500#ifdef HAVE_SYS_TYPES_H
501#include <sys/types.h>
502#endif
503#ifdef HAVE_SYS_SOCKET_H
504#include <sys/socket.h>
505#endif
506 int accept (int, struct sockaddr *, size_t *);
507 ],[],[
508 AC_MSG_RESULT(size_t)
509 AC_DEFINE_UNQUOTED([ACCEPT_TYPE_ARG3],[size_t], [type of arg3 of accept])
510 ], [
511 AC_MSG_RESULT(int)
512 AC_DEFINE_UNQUOTED([ACCEPT_TYPE_ARG3],[int], [type of arg3 of accept])
513 ]
514 )
515])
516
517dnl *****************************************
518dnl checks for extended attribute or ACL
519dnl support
520dnl *****************************************
521
522sh_CHECK_XATTR
523sh_CHECK_POSIX_ACL
524
525dnl *****************************************
526dnl checks for typedefs
527dnl *****************************************
528
529AC_C_LONG_DOUBLE
530SH_CHECK_TYPEDEF(long long, HAVE_LONG_LONG)
531SH_CHECK_TYPEDEF(uint16_t, HAVE_UINT16_T)
532SH_CHECK_TYPEDEF(uint64_t, HAVE_UINT64_T)
533if test "$sh_HAVE_LONG_LONG" = "yes"; then
534 AC_CHECK_SIZEOF(unsigned long long, 4)
535 sh_sizeof_unsigned_long_long=`echo "$ac_cv_sizeof_unsigned_long_long" | sed 's%[^0-9]%%g'`
536 if test "$sh_sizeof_unsigned_long_long" = "8"; then
537 AC_DEFINE(HAVE_LONG_LONG_64, 1, [Define if you have 64bit long long])
538 fi
539fi
540
541AC_CHECK_TYPE(ptrdiff_t, long)
542AC_TYPE_SIZE_T
543AC_CHECK_SIZEOF(char *, 4)
544AC_CHECK_SIZEOF(size_t, 4)
545
546AC_CHECK_SIZEOF(unsigned long, 4)
547AC_CHECK_SIZEOF(unsigned int, 4)
548AC_CHECK_SIZEOF(unsigned short, 2)
549
550
551sh_sizeof_unsigned_long=`echo "$ac_cv_sizeof_unsigned_long" | sed 's%[^0-9]%%g'`
552if test "$sh_sizeof_unsigned_long" = "4"; then
553 AC_DEFINE(HAVE_LONG_32)
554fi
555if test "$sh_sizeof_unsigned_long" = "8"; then
556 AC_DEFINE(HAVE_LONG_64)
557fi
558sh_sizeof_unsigned_int=`echo "$ac_cv_sizeof_unsigned_int" | sed 's%[^0-9]%%g'`
559if test "$sh_sizeof_unsigned_int" = "4"; then
560 AC_DEFINE(HAVE_INT_32)
561fi
562sh_sizeof_unsigned_short=`echo "$ac_cv_sizeof_unsigned_short" | sed 's%[^0-9]%%g'`
563if test "$sh_sizeof_unsigned_short" = "4"; then
564 AC_DEFINE(HAVE_SHORT_32)
565fi
566
567dnl
568dnl check for 64 bit programming environment
569dnl
570SAMHAIN_64
571
572
573dnl *****************************************
574dnl checks for structures
575dnl *****************************************
576
577AC_STRUCT_TM
578
579dnl
580dnl from e2fsprogs
581dnl
582AC_MSG_CHECKING(whether struct stat has a st_flags field)
583AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
584 AC_TRY_COMPILE([#include <sys/stat.h>],
585 [struct stat stat; stat.st_flags = 0;],
586 [e2fsprogs_cv_struct_st_flags=yes],
587 [e2fsprogs_cv_struct_st_flags=no]))
588AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
589if test "$e2fsprogs_cv_struct_st_flags" = yes; then
590 AC_MSG_CHECKING(whether st_flags field is useful)
591 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags_immut,
592 AC_TRY_COMPILE([#include <sys/stat.h>],
593 [struct stat stat; stat.st_flags |= UF_IMMUTABLE;],
594 [e2fsprogs_cv_struct_st_flags_immut=yes],
595 [e2fsprogs_cv_struct_st_flags_immut=no]))
596 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags_immut)
597 if test "$e2fsprogs_cv_struct_st_flags_immut" = yes; then
598 AC_DEFINE(HAVE_STAT_FLAGS)
599 fi
600fi
601
602dnl
603dnl from dbus
604dnl
605AC_MSG_CHECKING(for struct cmsgcred)
606AC_TRY_COMPILE([
607#include <sys/types.h>
608#include <sys/socket.h>
609],[
610struct cmsgcred cred;
611
612cred.cmcred_pid = 0;
613],sh_have_struct_cmsgcred=yes,sh_have_struct_cmsgcred=no)
614AC_MSG_RESULT($sh_have_struct_cmsgcred)
615
616if test x$sh_have_struct_cmsgcred = xyes; then
617 AC_DEFINE(HAVE_STRUCT_CMSGCRED,1,[Have cmsgcred structure])
618fi
619
620AC_MSG_CHECKING(for struct fcred)
621AC_TRY_COMPILE([
622#include <sys/param.h>
623#include <sys/socket.h>
624#include <sys/ucred.h>
625],[
626struct fcred sockcred;
627],sh_have_struct_fcred=yes,sh_have_struct_fcred=no)
628AC_MSG_RESULT($sh_have_struct_fcred)
629
630if test x$sh_have_struct_fcred = xyes; then
631 AC_DEFINE(HAVE_STRUCT_FCRED,1,[Have fcred structure])
632fi
633
634AC_MSG_CHECKING(for struct sockcred)
635AC_TRY_COMPILE([
636#include <sys/param.h>
637#include <sys/socket.h>
638#include <sys/ucred.h>
639],[
640struct sockcred sockcred;
641],sh_have_struct_sockcred=yes,sh_have_struct_sockcred=no)
642AC_MSG_RESULT($sh_have_struct_sockcred)
643
644if test x$sh_have_struct_sockcred = xyes; then
645 AC_DEFINE(HAVE_STRUCT_SOCKCRED,1,[Have sockcred structure])
646fi
647
648AC_MSG_CHECKING(for SO_PEERCRED)
649AC_TRY_COMPILE([
650#include <sys/types.h>
651#include <sys/socket.h>
652],[
653int test = SO_PEERCRED;
654],sh_have_SO_PEERCRED=yes,sh_have_SO_PEERCRED=no)
655AC_MSG_RESULT($sh_have_SO_PEERCRED)
656
657if test x$sh_have_SO_PEERCRED = xyes; then
658 AC_DEFINE(HAVE_SO_PEERCRED,1,[Have SO_PEERCRED define])
659fi
660
661
662dnl *****************************************
663dnl checks for compiler characteristics
664dnl *****************************************
665AC_C_INLINE
666AC_C_CONST
667AC_C_BIGENDIAN
668AC_C_RESTRICT
669
670AM_SA_SIGACTION_WORKS
671
672AC_ARG_ENABLE(ssp,
673 [ --disable-ssp disable the GCC stack protector],
674 [],
675 [enable_ssp=yes;]
676)
677
678if test "x$GCC" = "xyes"; then
679
680 if test x"${enable_ssp}" = xno; then
681 :
682 else
683 GCC_STACK_PROTECT_LIB
684 GCC_STACK_PROTECT_CC
685dnl GCC_STACK_CHECK_CC
686 GCC_PIE_CC
687 fi
688
689fi
690
691dnl *****************************************
692dnl
693dnl checks for system services
694dnl
695dnl *****************************************
696
697dnl
698dnl check for /proc filesystem
699dnl
700if test -d "/proc/$$"
701then
702 AC_DEFINE([HAVE_PROCFS],[1],[Define if you have a proc fs])
703fi
704
705dnl
706dnl check for GNU gmp
707dnl
708AC_CHECK_LIB(gmp, __gmpz_init, [sh_have_gmp=yes], [sh_have_gmp=no])
709if test "x${sh_have_gmp}" = xno
710then
711 AC_CHECK_LIB(gmp, mpz_init, [sh_have_gmp=yes], [sh_have_gmp=no])
712fi
713if test "x${sh_have_gmp}" = xyes
714then
715 # LIBS="-lgmp $LIBS"
716 AC_DEFINE(HAVE_LIBGMP, 1, [Have GNU gmp library])
717fi
718AC_CHECK_HEADERS(gmp.h)
719
720AC_MSG_CHECKING([for ps])
721PS=
722for ff in /usr/ucb /bin /usr/bin; do
723 if test -x "$ff/ps"; then
724 PS="$ff/ps"
725 AC_MSG_RESULT([$PS])
726 break
727 fi
728done
729if test x$PS = x
730then
731 AC_MSG_RESULT([no])
732 AC_MSG_ERROR([Cannot find ps in any of /usr/ucb /bin /usr/bin])
733fi
734AC_DEFINE_UNQUOTED([PSPATH], _("$PS"), [Path to ps])
735
736AC_MSG_CHECKING([how to use ps])
737$PS ax >/dev/null 2>&1
738if test $? -eq 0; then
739 case "$host_os" in
740 *openbsd*)
741 one=`$PS akx | wc -l`
742 ;;
743 *)
744 one=`$PS ax | wc -l`
745 ;;
746 esac
747else
748 one=0
749fi
750$PS -e >/dev/null 2>&1
751if test $? -eq 0; then
752 two=`$PS -e | wc -l`
753else
754 two=0
755fi
756if test $one -ge $two
757then
758 case "$host_os" in
759 *openbsd*)
760 PSARG="akx"
761 ;;
762 *)
763 PSARG="ax"
764 ;;
765 esac
766else
767 PSARG="-e"
768fi
769AC_DEFINE_UNQUOTED([PSARG], _("$PSARG"), [Argument for ps])
770AC_MSG_RESULT([$PS $PSARG])
771
772dnl *****************************************
773dnl
774dnl enable features
775dnl
776dnl *****************************************
777
778AC_ARG_ENABLE(db-reload,
779 [ --enable-db-reload enable database reload on SIGHUP [[no]]],
780 [
781 if test "x${enable_db_reload}" = xyes; then
782 AC_DEFINE(RELOAD_DATABASE)
783 fi
784 ]
785)
786
787AC_ARG_ENABLE(xml-log,
788 [ --enable-xml-log enable XML logfile format [[no]]],
789 [
790 if test "x${enable_xml_log}" = xyes; then
791 AC_DEFINE(SH_USE_XML)
792 fi
793 ]
794)
795
796
797AC_ARG_ENABLE(mail,
798 [ --disable-mail disable the internal SMTP mailer],
799 [
800 if test "x${enable_mail}" = xno; then
801 :
802 else
803 AC_DEFINE(SH_WITH_MAIL)
804 fi
805 ],
806 [AC_DEFINE(SH_WITH_MAIL)]
807)
808
809AC_ARG_ENABLE(shellexpand,
810 [ --disable-shellexpand disable shell expansion in config file],
811 [
812 if test "x${enable_shellexpand}" = xno; then
813 :
814 else
815 AC_DEFINE(SH_EVAL_SHELL, [1], [Define if you want shell expansion in configuration file])
816 fi
817 ],
818 [AC_DEFINE(SH_EVAL_SHELL, [1], [Define if you want shell expansion in configuration file])]
819)
820
821AC_ARG_ENABLE(external-scripts,
822 [ --disable-external-scripts disable interface to external scripts],
823 [
824 if test "x${enableval}" = xno; then
825 :
826 else
827 AC_DEFINE(WITH_EXTERNAL)
828 fi
829 ],
830 [AC_DEFINE(WITH_EXTERNAL)]
831)
832
833AC_ARG_ENABLE(message-queue,
834 [ --enable-message-queue[[=MODE]] enable SysV message queue [[MODE=0700]]],
835 [
836 if test "x${ac_cv_header_sys_msg_h}" = "xyes"; then
837 if test "x${enable_message_queue}" = xyes; then
838 AC_DEFINE(WITH_MESSAGE_QUEUE)
839 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, 0700)
840 elif test "x${enable_message_queue}" != xno; then
841 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
842 AC_MSG_ERROR([With --enable-message-queue=MODE, MODE must be numeric])
843 echo "${enableval}" | \
844 grep ['0[0123456789][0123456789][0123456789]'] >/dev/null 2>&1 ||
845 AC_MSG_ERROR([With --enable-message-queue=MODE, MODE must be an octal (0nnn) number])
846 AC_DEFINE(WITH_MESSAGE_QUEUE)
847 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, ${enable_message_queue})
848 fi
849 else
850 echo
851 echo "**********************************************"
852 echo
853 AC_MSG_WARN([sys/msg.h missing, --enable-message-queue disabled])
854 echo
855 echo "**********************************************"
856 echo
857 fi
858 ]
859)
860
861AC_ARG_WITH(cflags,
862 [ --with-cflags additional flags to pass to compiler],
863 [
864 if test "x$withval" != "xno" ; then
865 CFLAGS="$CFLAGS $withval"
866 fi
867 ]
868)
869AC_ARG_WITH(libs,
870 [ --with-libs additional libraries to link with],
871 [
872 if test "x$withval" != "xno" ; then
873 LIBS="$LIBS $withval"
874 fi
875 ]
876)
877
878
879#
880# this is from ssh
881#
882AC_MSG_CHECKING(whether to use libwrap)
883LIBWRAP_LIB=""
884LIBWRAP_INC=""
885AC_ARG_WITH(libwrap,
886[ --with-libwrap[=PATH] Compile in libwrap (TCP Wrappers) support],
887[ AC_MSG_RESULT($withval)
888 case "$withval" in
889 no)
890 ;;
891 ""|yes)
892 LIBWRAP_LIB="-lwrap"
893 ;;
894 *)
895 if test -d "$withval"; then
896 LIBWRAP_LIB="-L$withval -lwrap"
897 changequote(<<, >>)dnl
898 sh_libwrap_inc=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
899 LIBWRAP_INC="-I${sh_libwrap_inc}/include"
900 changequote([, ])dnl
901 else
902 LIBWRAP_LIB="-lwrap"
903 changequote(<<, >>)dnl
904 sh_libwrap_inc=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
905 LIBWRAP_INC="-I${sh_libwrap_inc}"
906 changequote([, ])dnl
907 fi
908 ;;
909 esac
910 if test -n "$LIBWRAP_LIB"; then
911 # OLDLIBS="$LIBS"
912 LIBS="$LIBWRAP_LIB $LIBS"
913 # OLDCFLAGS="$CFLAGS"
914 CFLAGS="$CFLAGS $LIBWRAP_INC"
915 AC_CHECK_HEADER(tcpd.h,
916 [],
917 [ AC_MSG_ERROR([Could not find tcpd.h for libwrap. You need to install tcp_wrappers.]) ])
918 AC_TRY_LINK([ #include <tcpd.h>
919 int allow_severity; int deny_severity; ],
920 [ hosts_access((struct request_info *) 0); ],
921 [ AC_DEFINE(SH_USE_LIBWRAP,1,[Build with tcp wrapper support]) ],
922 [ AC_MSG_ERROR([Could not find the libwrap library.]) ])
923 fi ],
924 AC_MSG_RESULT(no)
925)
926
927
928dnl
929dnl NETWORK OPTIONS
930dnl
931AC_ARG_ENABLE(network,
932 [ --enable-network=[[client|server]] compile client or server [[no]]],
933 [
934 if test "x$enable_network" = xclient; then
935 mytclient="-DSH_WITH_CLIENT"
936 yulectl_prg=
937 setpwd_prg="samhain_setpwd"
938 sh_main_prg="samhain"
939 if test "x${sh_have_gmp}" = xyes
940 then
941 LIBS="-lgmp $LIBS"
942 fi
943dnl AC_CHECK_HEADER(sys/capability.h,
944dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
945dnl [sh_use_lcaps="no"])
946 elif test "x$enable_network" = xserver; then
947 mytclient="-DSH_WITH_SERVER"
948 yulectl_prg="yulectl"
949 setpwd_prg="samhain_setpwd"
950 sh_main_prg="yule"
951 if test "x${sh_have_gmp}" = xyes
952 then
953 LIBS="-lgmp $LIBS"
954 fi
955 sh_use_lcaps="undef"
956 elif test "x$enable_network" = xno; then
957 mytclient="-DSH_STANDALONE"
958 yulectl_prg=
959 setpwd_prg=
960 sh_main_prg="samhain"
961dnl AC_CHECK_HEADER(sys/capability.h,
962dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
963dnl [sh_use_lcaps="no"])
964 else
965 AC_MSG_ERROR([With --enable-network=WHAT, WHAT must be client, server, or no])
966 fi
967 ],
968 [
969 mytclient="-DSH_STANDALONE"
970 setpwd_prg=
971 yulectl_prg=
972 sh_main_prg="samhain"
973dnl AC_CHECK_HEADER(sys/capability.h,
974dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
975dnl [sh_use_lcaps="no"])
976 ],
977)
978
979AC_SUBST(setpwd_prg)
980AC_SUBST(yulectl_prg)
981AC_SUBST(sh_main_prg)
982AC_SUBST(mytclient)
983
984# needed for the rpm spec
985clmytclient=`echo ${mytclient} | sed s%\-%%`
986AC_SUBST(clmytclient)
987
988sh_no_gcc_static=no
989
990AC_ARG_ENABLE(static,
991 [ --enable-static enable static linking [[no]]],
992 [
993 if test x$enable_static = xyes; then
994 if test x"$mynetbsd" = xyes
995 then
996 tmp_LIBS=`echo $LIBS | sed 's%\-lresolv%%' `
997 LIBS="${tmp_LIBS}"
998 fi
999 if test x"${sh_auparse}" = xyes
1000 then
1001 tmp_LIBS=`echo $LIBS | sed 's%\-lauparse%%' `
1002 LIBS="${tmp_LIBS}"
1003 fi
1004 AC_DEFINE(SH_COMPILE_STATIC, 1, [Define if compiling static])
1005 if test "x$GCC" = "xyes"; then
1006 sh_no_gcc_static=no
1007 LDFLAGS="$LDFLAGS -static"
1008 else
1009 sh_no_gcc_static=yes
1010 case "$host_os" in
1011
1012 *aix*)
1013 LDFLAGS="$LDFLAGS -bnso -bI:/lib/syscalls.exp"
1014 ;;
1015
1016 *hpux*)
1017 LDFLAGS="$LDFLAGS -Wl,-a,archive"
1018 ;;
1019
1020 *osf*)
1021 LDFLAGS="$LDFLAGS -non_shared"
1022 ;;
1023
1024 *irix*)
1025 LDFLAGS="$LDFLAGS -non_shared"
1026 ;;
1027
1028 *sco*)
1029 LDFLAGS="$LDFLAGS -dn"
1030 ;;
1031
1032 *sun*)
1033 LDFLAGS="$LDFLAGS -Bstatic"
1034 ;;
1035
1036 *solaris*)
1037 LDFLAGS="$LDFLAGS -Bstatic"
1038 ;;
1039
1040 *)
1041 echo "***********************************************"
1042 echo "*"
1043 echo "* Don't know how to enable static linking"
1044 echo "* with your compiler. Please set the environment"
1045 echo "* variable LDFLAGS to:"
1046 echo "* ${LDFLAGS} + the static linking flag"
1047 echo "* and run configure again"
1048 echo "*"
1049 echo "***********************************************"
1050 ;;
1051
1052 esac
1053 fi
1054 fi
1055 ]
1056)
1057
1058if test x"${mytclient}" = x-DSH_STANDALONE -o x"${mytclient}" = x-DSH_WITH_CLIENT;
1059then
1060dnl For threaded modules
1061 ACX_PTHREAD
1062 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1063 LIBS="$PTHREAD_LIBS $LIBS"
1064 LDFLAGS="$PTHREAD_CFLAGS $LDFLAGS"
1065 CC="$PTHREAD_CC"
1066dnl For MODI_TXT
1067 CHECK_ZLIB()
1068fi
1069
1070if test x$enable_static = xyes; then
1071 :
1072else
1073 if test x$sh_use_pie = xyes; then
1074 LDFLAGS="$LDFLAGS $PIE_LDFLAGS"
1075 CFLAGS="$CFLAGS $PIE_CFLAGS"
1076 fi
1077fi
1078
1079
1080#
1081# this is from the snort configure.in
1082#
1083AC_DEFUN(FAIL_MESSAGE,[
1084 echo
1085 echo
1086 echo "**********************************************"
1087 echo " ERROR: unable to find" $1
1088 echo " checked in the following places"
1089 for i in `echo $2`; do
1090 echo " $i"
1091 done
1092 echo "**********************************************"
1093 echo
1094 exit
1095])
1096
1097AC_ARG_WITH(libprelude-prefix,
1098 [ --with-libprelude-prefix=PFX Prefix where libprelude is installed (optional)],
1099 libprelude_config_prefix="$withval", libprelude_config_prefix="")
1100
1101AC_MSG_CHECKING(whether to use prelude)
1102AC_ARG_WITH(prelude,
1103 [ --with-prelude Prelude IDS support [[no]]],
1104 [
1105 if test "x${withval}" = "xno"; then
1106 AC_MSG_RESULT(no)
1107 else
1108 AC_MSG_RESULT(yes)
1109 if test x$libprelude_config_prefix != x ; then
1110 if test x${LIBPRELUDE_CONFIG+set} != xset ; then
1111 LIBPRELUDE_CONFIG=$libprelude_config_prefix/bin/libprelude-config
1112 fi
1113 fi
1114
1115 AC_PATH_PROG(LIBPRELUDE_CONFIG, libprelude-config, no)
1116 if test x"$LIBPRELUDE_CONFIG" = "xno" ; then
1117 HAVE_PRELUDE_CONFIG=no
1118 else
1119 HAVE_PRELUDE_CONFIG=yes
1120 fi
1121dnl AC_CHECK_PROG(HAVE_PRELUDE_CONFIG, libprelude-config, yes, no)
1122 if test "$HAVE_PRELUDE_CONFIG" = "yes"; then
1123 sh_libprelude_version=`$LIBPRELUDE_CONFIG --version`
1124 case "$sh_libprelude_version" in
1125 0.8*)
1126 AC_MSG_ERROR([You have Libprelude 0.8, which is too old. Version 0.9.6 or higher is required.])
1127 ;;
1128 *)
1129 AM_PATH_LIBPRELUDE([0.9.6],
1130 [
1131 AC_DEFINE(HAVE_LIBPRELUDE,1,[Have libprelude])
1132 CFLAGS="$CFLAGS $LIBPRELUDE_PTHREAD_CFLAGS"
1133 LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS"
1134 LIBS="$LIBS $LIBPRELUDE_LIBS"
1135 ],
1136 [
1137 AC_MSG_ERROR([Could not find libprelude (if you are using --enable-static, the static library libprelude.a might be missing).])
1138 ])
1139 ;;
1140 esac
1141 else
1142 AC_MSG_ERROR([Could not find libprelude-config.])
1143 fi
1144 fi
1145 ],
1146 [
1147 AC_MSG_RESULT(no)
1148 ]
1149)
1150
1151#
1152# partly based on the snort configure.in
1153#
1154AC_ARG_WITH(database,
1155 [ --with-database=[[mysql|postgresql|oracle|odbc]] database support [[no]]],
1156 [
1157 if test x"$enable_xml_log" != xyes; then
1158 AC_MSG_ERROR([With --with-database, --enable-xml-log is required as well.])
1159 fi
1160 if test "x${withval}" = "xmysql"; then
1161 if test "x$zlib_found" = "x"
1162 then
1163 CHECK_ZLIB()
1164 fi
1165 AC_CHECK_PROG(HAVE_MYSQL_CONFIG, mysql_config, yes, no)
1166 if test "$HAVE_MYSQL_CONFIG" = "yes"; then
1167 sh_mysql_libs="`mysql_config --libs`"
1168 sh_mysql_libs="`eval echo ${sh_mysql_libs}`"
1169 LIBS="$LIBS ${sh_mysql_libs}"
1170 sh_mysql_cflags="`mysql_config --cflags`"
1171 sh_mysql_cflags="`eval echo ${sh_mysql_cflags}`"
1172 CPPFLAGS="$CPPFLAGS ${sh_mysql_cflags}"
1173 else
1174 AC_MSG_CHECKING([for MySQL in /usr /usr/local /usr/local/mysql MYSQL_HOME])
1175 mysql_directory="/usr /usr/local /usr/local/mysql ${MYSQL_HOME}"
1176
1177 for i in $mysql_directory; do
1178 if test -r $i/include/mysql/mysql.h; then
1179 MYSQL_DIR=$i
1180 MYSQL_INC_DIR=$i/include
1181 # we use AC_CHECK_HEADERS to check for mysql/mysql.h
1182 fi
1183 done
1184 if test -z "$MYSQL_DIR"; then
1185 for i in $mysql_directory; do
1186 if test -r $i/include/mysql.h; then
1187 MYSQL_DIR=$i
1188 MYSQL_INC_DIR=$i/include
1189 fi
1190 done
1191 fi
1192
1193 if test -z "$MYSQL_DIR"; then
1194 tmp=""
1195 for i in $mysql_directory; do
1196 tmp="$tmp $i/include $i/include/mysql"
1197 done
1198 FAIL_MESSAGE("mysql headers (mysql.h)", $tmp)
1199 fi
1200
1201 for i in lib lib/mysql; do
1202 str="$MYSQL_DIR/$i/libmysqlclient.*"
1203 for j in `echo $str`; do
1204 if test -r $j; then
1205 MYSQL_LIB_DIR="$MYSQL_DIR/$i"
1206 break 2
1207 fi
1208 done
1209 done
1210
1211 if test -z "$MYSQL_LIB_DIR"; then
1212 for ff in $mysql_directory; do
1213 for i in lib lib/mysql; do
1214 str="$ff/$i/libmysqlclient.*"
1215 for j in `echo $str`; do
1216 if test -r $j; then
1217 MYSQL_LIB_DIR="$ff/$i"
1218 break 3
1219 fi
1220 done
1221 done
1222 done
1223 fi
1224
1225 if test -z "$MYSQL_LIB_DIR"; then
1226 tmp=""
1227 for i in $mysql_directory; do
1228 tmp="$i/lib $i/lib/mysql"
1229 done
1230 FAIL_MESSAGE("mysql library libmysqlclient", $tmp)
1231 fi
1232
1233 AC_MSG_RESULT(yes)
1234 LIBS="$LIBS -L${MYSQL_LIB_DIR} -lmysqlclient"
1235 # CFLAGS="$CFLAGS -I${MYSQL_INC_DIR}"
1236 CPPFLAGS="$CPPFLAGS -I${MYSQL_INC_DIR}"
1237 fi
1238 AC_DEFINE(WITH_MYSQL)
1239 AC_DEFINE(WITH_DATABASE)
1240 if test "x$zlib_found" = "xyes"
1241 then
1242 LIBS="$LIBS -lz -lm"
1243 else
1244 echo
1245
1246 echo " Mysql library was not found or not useable."
1247 echo " Possible reasons include:"
1248 echo " - an old, incompatible version compiled from source"
1249 echo " - on Solaris, libmysql is compiled with the Solaris"
1250 echo " compiler, thus the mysql_config script provides"
1251 echo " compiler options unsuitable for gcc (move"
1252 echo " mysql_config out of your PATH)"
1253 echo " For other problems, check config.log for the error"
1254 echo " message from the compiler."
1255 echo
1256 echo " If your mysql libraries are installed in an"
1257 echo " unusual place, use --with-libs=-L/path/to/libdirectory"
1258 echo " where libdirectory is the directory holding libmysql."
1259 if test x"$enable_static" = xyes; then
1260 echo " Note that for compiling a static binary, you need"
1261 echo " the static libraries, rather than the shared ones."
1262 fi
1263 echo
1264 AC_MSG_ERROR([Could not find libmysql, or it is not useable.])
1265 fi
1266 AC_CHECK_HEADERS(mysql/mysql.h)
1267 elif test "x${withval}" = "xpostgresql"; then
1268 AC_DEFINE(WITH_POSTGRES)
1269 AC_DEFINE(WITH_DATABASE)
1270 #
1271 PGCONF="no"
1272 MY_PATH="${PATH}:/usr/local/bin:/usr/local/pgsql/bin"
1273 OLD_IFS="$IFS"
1274 IFS=":"
1275 for ff in ${MY_PATH}
1276 do
1277 if test -f "$ff/pg_config"
1278 then
1279 PGCONF="$ff/pg_config"
1280 fi
1281 done
1282 IFS="${OLD_IFS}"
1283 #
1284 #
1285 if test "x${PGCONF}" = "xno"
1286 then
1287 AC_MSG_CHECKING(for PostgreSQL in /usr/local/pgsql /usr/pgsql /usr/local /usr PGSQL_HOME)
1288 pgsql_directory="/usr/local/pgsql /usr/pgsql /usr/local /usr ${PGSQL_HOME}"
1289 for i in $pgsql_directory; do
1290 if test -r $i/include/pgsql/libpq-fe.h; then
1291 PGSQL_INC_DIR=$i/include
1292 PGSQL_DIR=$i
1293 # use AC_CHECK_HEADERS to check for pgsql/libpq-fe.h
1294 fi
1295 done
1296 if test -z "$PGSQL_DIR"; then
1297 for i in $pgsql_directory; do
1298 if test -r $i/include/postgresql/libpq-fe.h; then
1299 PGSQL_INC_DIR=$i/include
1300 PGSQL_DIR=$i
1301 fi
1302 done
1303 fi
1304 if test -z "$PGSQL_DIR"; then
1305 for i in $pgsql_directory; do
1306 if test -r $i/include/libpq-fe.h; then
1307 PGSQL_INC_DIR=$i/include
1308 PGSQL_DIR=$i
1309 fi
1310 done
1311 fi
1312
1313 if test -z "$PGSQL_DIR"; then
1314 tmp=""
1315 for i in $pgsql_directory; do
1316 tmp="$tmp $i/include $i/include/pgsql $i/include/postgresql"
1317 done
1318 FAIL_MESSAGE("PostgreSQL header file (libpq-fe.h)", $tmp)
1319 fi
1320
1321 for i in lib lib/pgsql lib/postgresql; do
1322 str="$PGSQL_DIR/$i/libpq.*"
1323 for j in `echo $str`; do
1324 if test -r $j; then
1325 PGSQL_LIB_DIR="$PGSQL_DIR/$i"
1326 break 2
1327 fi
1328 done
1329 done
1330
1331 if test -z "$PGSQL_LIB_DIR"; then
1332 for ff in $pgsql_directory; do
1333 for i in lib lib/pgsql lib/postgresql; do
1334 str="$ff/$i/libpq.*"
1335 for j in `echo $str`; do
1336 if test -r $j; then
1337 PGSQL_LIB_DIR="$ff/$i"
1338 break 3
1339 fi
1340 done
1341 done
1342 done
1343 fi
1344
1345 if test -z "$PGSQL_LIB_DIR"; then
1346 tmp=""
1347 for i in $pgsql_directory; do
1348 tmp="$i/lib $i/lib/pgsql $i/lib/postgresql"
1349 done
1350 FAIL_MESSAGE("postgresql library libpq", $tmp)
1351 fi
1352
1353 AC_MSG_RESULT(yes)
1354
1355 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lm"
1356 if test x"$enable_static" = xyes; then
1357 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lcrypt -lm"
1358 else
1359 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lm"
1360 fi
1361 # CFLAGS="$CFLAGS -I${PGSQL_INC_DIR}"
1362 CPPFLAGS="$CPPFLAGS -I${PGSQL_INC_DIR}"
1363 AC_CHECK_HEADERS(pgsql/libpq-fe.h)
1364 AC_CHECK_HEADERS(postgresql/libpq-fe.h)
1365 else
1366 pg_lib_dir=`${PGCONF} --libdir`
1367 if test x"$enable_static" = xyes; then
1368 LIBS="$LIBS -L${pg_lib_dir} -lpq -lcrypt -lm"
1369 else
1370 LIBS="$LIBS -L${pg_lib_dir} -lpq -lm"
1371 fi
1372 pg_inc_dir=`${PGCONF} --includedir`
1373 # CFLAGS="$CFLAGS -I${pg_inc_dir}"
1374 CPPFLAGS="$CPPFLAGS -I${pg_inc_dir}"
1375 fi
1376 elif test "x${withval}" = "xodbc"; then
1377 AC_MSG_CHECKING(for odbc in /usr /usr/local ODBC_HOME)
1378 odbc_directory="/usr /usr/local"
1379
1380 for i in $odbc_directory; do
1381 if test -r $i/include/sql.h; then
1382 if test -r $i/include/sqlext.h; then
1383 if test -r $i/include/sqltypes.h; then
1384 ODBC_DIR=$i
1385 ODBC_INC_DIR=$i/include
1386 fi
1387 fi
1388 fi
1389 done
1390
1391 if test -z "$ODBC_DIR"; then
1392 tmp=""
1393 for i in $odbc_directory; do
1394 tmp="$tmp $i/include"
1395 done
1396 FAIL_MESSAGE("odbc headers (sql.h sqlext.h sqltypes.h)", $tmp)
1397 fi
1398
1399 str="$ODBC_DIR/lib/libodbc.*"
1400 for j in `echo $str`; do
1401 if test -r $j; then
1402 ODBC_LIB_DIR="$ODBC_DIR/lib"
1403 ODBC_LIB="odbc"
1404 fi
1405 done
1406
1407 if test -z "$ODBC_LIB_DIR"; then
1408 FAIL_MESSAGE("odbc library (libodbc)", "$ODBC_DIR/lib")
1409 fi
1410
1411 AC_MSG_RESULT(yes)
1412 CPPFLAGS="${CPPFLAGS} -I${ODBC_INC_DIR}"
1413 LIBS="${LIBS} -L${ODBC_LIB_DIR} -l$ODBC_LIB"
1414 AC_DEFINE(WITH_ODBC)
1415 AC_DEFINE(WITH_DATABASE)
1416
1417 elif test "x${withval}" = "xoracle"; then
1418 AC_MSG_CHECKING(for oracle in /usr /usr/local ORACLE_HOME)
1419 oracle_directory="/usr /usr/local ${ORACLE_HOME}"
1420 for i in $oracle_directory; do
1421 if test -r $i/rdbms/demo/oci.h; then
1422 ORACLE_DIR=$i
1423 fi
1424 done
1425
1426 if test -z "$ORACLE_DIR"; then
1427 tmp=""
1428 for i in $oracle_directory; do
1429 tmp="$tmp $i/rdbms/demo"
1430 done
1431 FAIL_MESSAGE("OCI header file (oci.h)", $tmp)
1432 else
1433 for i in rdbms/demo rdbms/public network/public; do
1434 ORACLE_CPP_FLAGS="$ORACLE_CPP_FLAGS -I$ORACLE_DIR/$i"
1435 done
1436 ORACLE_LIB_DIR="$ORACLE_DIR/lib"
1437 AC_MSG_RESULT(yes)
1438
1439 CPPFLAGS="${CPPFLAGS} ${ORACLE_CPP_FLAGS}"
1440
1441 ORACLE_LIBS="-lclntsh"
1442 if test -r $ORACLE_LIB_DIR/libwtc9.so; then
1443 ORACLE_LIBS="${ORACLE_LIBS} -lwtc9"
1444 elif test -r $ORACLE_LIB_DIR/libwtc8.so; then
1445 ORACLE_LIBS="${ORACLE_LIBS} -lwtc8"
1446 fi
1447 LIBS="${LIBS} -L${ORACLE_LIB_DIR} ${ORACLE_LIBS}"
1448 if test "x$GCC" != "xyes"; then
1449 CFLAGS="${CFLAGS} -fno-strict-aliasing"
1450 fi
1451 fi
1452 AC_DEFINE(WITH_ORACLE)
1453 AC_DEFINE(WITH_DATABASE)
1454
1455 else
1456 AC_MSG_ERROR([Option --with-database=database used with unsupported database ${withval}])
1457 fi
1458 ]
1459)
1460
1461AC_ARG_WITH(console,
1462 [ --with-console=PATH set path to console device [[/dev/console]]],
1463 [
1464 if test "x${withval}" != xno; then
1465 mycons="$withval"
1466 AC_DEFINE_UNQUOTED(DEFAULT_CONSOLE, _("${mycons}") )
1467 fi
1468 ])
1469
1470AC_ARG_WITH(altconsole,
1471 [ --with-altconsole=PATH set path to second console device [[none]]],
1472 [
1473 if test "x${withval}" != xno; then
1474 myaltcons="$withval"
1475 else
1476 myaltcons="NULL"
1477 fi
1478 ],
1479 [myaltcons="NULL"])
1480AC_DEFINE_UNQUOTED(ALT_CONSOLE, _("${myaltcons}") )
1481
1482AC_ARG_WITH(timeserver,
1483 [ --with-timeserver=HOST set host address for time server [[none]]],
1484 [
1485 if test "x${withval}" != xno; then
1486 mytimeserv="$withval"
1487 AC_DEFINE(HAVE_NTIME)
1488 else
1489 mytimeserv="NULL"
1490 fi
1491 ],
1492 mytimeserv="NULL")
1493AC_DEFINE_UNQUOTED(DEFAULT_TIMESERVER, _("${mytimeserv}") )
1494
1495AC_ARG_WITH(alttimeserver,
1496 [ --with-alttimeserver=HOST set address for backup time server [[none]]],
1497 [
1498 if test "x${withval}" != xno; then
1499 myalttimeserv="$withval"
1500 AC_DEFINE(HAVE_NTIME)
1501 else
1502 myalttimeserv="NULL"
1503 fi
1504 ],
1505 myalttimeserv="NULL")
1506AC_DEFINE_UNQUOTED(ALT_TIMESERVER, _("${myalttimeserv}") )
1507
1508AC_ARG_ENABLE(login-watch,
1509 [ --enable-login-watch watch for login/logout [[no]]],
1510 [
1511 if test "x${enable_login_watch}" = xyes; then
1512 AC_DEFINE(SH_USE_UTMP)
1513 fi
1514 ]
1515)
1516
1517AC_ARG_ENABLE(mounts-check,
1518 [ --enable-mounts-check check mount options on filesystems [[no]]],
1519 [
1520 if test "x${enable_mounts_check}" = xyes; then
1521 AC_DEFINE(SH_USE_MOUNTS)
1522 fi
1523 ]
1524)
1525
1526AC_ARG_ENABLE(logfile-monitor,
1527 [ --enable-logfile-monitor monitor logfiles [[no]]],
1528 [
1529 if test "x${enable_logfile_monitor}" = xyes; then
1530 AC_CHECK_HEADER(pcre.h,
1531 [
1532 AC_DEFINE(USE_LOGFILE_MONITOR, 1, [Define if you want the logfile monitor module.])
1533 LIBS="-lpcre $LIBS"
1534 ],
1535 [
1536 AC_CHECK_HEADER(pcre/pcre.h,
1537 [
1538 AC_DEFINE(USE_LOGFILE_MONITOR, 1, [Define if you want the logfile monitor module.])
1539 AC_DEFINE(HAVE_PCRE_PCRE_H, 1, [Define if you have pcre/pcre.h.])
1540 LIBS="-lpcre $LIBS"
1541 ],
1542 AC_MSG_ERROR([The --enable-logfile-monitor option requires libpcre. For compiling the pcre development package is needed.])
1543 )
1544 ]
1545 )
1546 AC_CHECK_LIB(pcre, pcre_dfa_exec, [
1547 AC_DEFINE([HAVE_PCRE_DFA_EXEC], 1, [Define if you have pcre_dfa_exec])
1548 ], [
1549 AC_MSG_WARN([pcre_dfa_exec not available])
1550 ])
1551 fi
1552 ]
1553)
1554
1555
1556AC_ARG_ENABLE(process-check,
1557 [ --enable-process-check check processes [[no]]],
1558 [
1559 if test "x${enable_process_check}" = xyes; then
1560 AC_CHECK_LIB([rt], [sched_getparam], sh_lrt=yes, sh_lrt=no)
1561 if test x"$sh_lrt" = xyes; then
1562 LIBRT=-lrt
1563 else
1564 LIBRT=
1565 fi
1566 LIBS="$LIBS $LIBRT"
1567 AC_DEFINE(SH_USE_PROCESSCHECK, [1], [Define if you want to check processes])
1568 fi
1569 ]
1570)
1571
1572AC_ARG_ENABLE(port-check,
1573 [ --enable-port-check check ports [[no]]],
1574 [
1575 if test "x${enable_port_check}" = xyes; then
1576 AC_DEFINE(SH_USE_PORTCHECK, [1], [Define if you want to check ports])
1577 fi
1578 ]
1579)
1580
1581AC_ARG_ENABLE(userfiles,
1582 [ --enable-userfiles check for users' config files [[no]]],
1583 [
1584 if test "x${enableval}" = "xyes"; then
1585 AC_DEFINE(SH_USE_USERFILES)
1586 fi
1587 ]
1588)
1589
1590AC_ARG_ENABLE(debug,
1591 [ --enable-debug enable debug options [[no]]],
1592 [
1593 if test "x${enable_debug}" = "xyes"; then
1594 if test "x${mydebugflag}" != "xyes"; then
1595 AC_DEFINE(MEM_DEBUG)
1596 fi
1597 AC_DEFINE(WITH_TPT)
1598 AC_DEFINE(SL_DEBUG)
1599 AC_DEFINE(DNMALLOC_CHECKS, 1, [Debug dnmalloc])
1600 AC_DEFINE(PARANOIA, 0, [Paranoia level for dnmalloc])
1601 AC_DEFINE(SL_FAIL_ON_ERROR)
1602 if test "x${myneedg3}" = "xyes"; then
1603 mydebugdef="-g3"
1604 else
1605 mydebugdef="-g"
1606 fi
1607 mydebugit="yes"
1608 elif test "x${enable_debug}" = "xgdb"; then
1609 if test "x${myneedg3}" = "xyes"; then
1610 mydebugdef="-g3"
1611 else
1612 mydebugdef="-g"
1613 fi
1614 mydebugit="yes"
1615 fi
1616 ]
1617)
1618AC_SUBST(mydebugdef)
1619
1620
1621AC_ARG_ENABLE(ipv6,
1622 [ --disable-ipv6 disable ipv6 support],
1623 [
1624 if test "x${enable_ipv6}" = xno; then
1625 AC_DEFINE(USE_IPV4,1,[Define if you do not want IPv6])
1626 fi
1627 ]
1628)
1629
1630if test "x${dnmalloc_ok}" = "xyes"; then
1631 sh_dnmalloc_enabled=yes
1632else
1633 sh_dnmalloc_enabled=no
1634fi
1635
1636AC_ARG_ENABLE(dnmalloc,
1637 [ --disable-dnmalloc disable dnmalloc],
1638 [
1639 if test "x${enable_dnmalloc}" = xno; then
1640 sh_dnmalloc_enabled=no
1641 else
1642 sh_dnmalloc_enabled=yes
1643 fi
1644 ]
1645)
1646
1647dnl Handle the problem that static linking against libc.a on Linux
1648dnl produces the error "multiple definitions of malloc"
1649dnl
1650if test "x$sh_dnmalloc_enabled" = "xyes"; then
1651 if test x$enable_static = xyes; then
1652 if test "x$sh_no_gcc_static" = "xyes"; then
1653 sh_dnmalloc_enabled=no
1654 else
1655 if test "x$with_gnu_ld" = "xyes"; then
1656 LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition"
1657 else
1658 sh_dnmalloc_enabled=no
1659 fi
1660 fi
1661 fi
1662fi
1663
1664if test "x${sh_dnmalloc_enabled}" = xno; then
1665 AC_DEFINE(USE_SYSTEM_MALLOC,1,[Define if you want to use the system malloc])
1666fi
1667
1668AC_ARG_ENABLE(ptrace,
1669 [ --enable-ptrace use anti-debugger options [[no]]],
1670 [
1671 if test "x${enable_ptrace}" = xyes; then
1672 if test "x$mydebugit" != "xyes"; then
1673 AC_DEFINE(SCREW_IT_UP)
1674 fi
1675 fi
1676 ]
1677)
1678
1679dnl
1680if test "x$GCC" = "xyes"; then
1681 if test ! -z "`echo "$CFLAGS" | grep "\-g\ " 2> /dev/null`" ; then
1682 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
1683 fi
1684
1685dnl if test ! -z "`echo "$CFLAGS" | grep "\-O2" 2> /dev/null`" ; then
1686dnl CFLAGS=`echo $CFLAGS | sed 's%\-O2%\-O3%' `
1687dnl fi
1688
1689 if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
1690 CFLAGS="$CFLAGS -Wall -W "
1691 fi
1692
1693 if test -z "`echo "$CFLAGS" | grep "\-fstrength\-reduce" 2> /dev/null`"
1694 then
1695 if test -z "`echo "$CFLAGS" | grep "\-fno\-strength\-reduce" 2> /dev/null`"
1696 then
1697 CFLAGS="$CFLAGS -fno-strength-reduce"
1698 fi
1699 fi
1700
1701 if test -z "`echo "$CFLAGS" | grep "\-fomit\-frame\-pointer" 2> /dev/null`"
1702 then
1703 if test -z "`echo "$CFLAGS" | grep "\-fno\-omit\-frame\-pointer" 2> /dev/null`"
1704 then
1705 CFLAGS="$CFLAGS -fno-omit-frame-pointer"
1706 fi
1707 fi
1708
1709fi
1710
1711dnl Test whether gcc supports -Wno-empty-body
1712dnl Suppresses warnings from glibc pthread_cleanup_pop
1713dnl
1714GCC_WEMPTY_BODY
1715
1716AC_MSG_CHECKING([which random module to use])
1717AC_ARG_WITH(rnd,
1718 [ --with-rnd=[[egd|unix|dev|default]] random number generator [[default]]],
1719[use_static_rnd=$withval], [use_static_rnd=default] )
1720
1721if test "$use_static_rnd" = no; then
1722 use_static_rnd=default
1723fi
1724
1725case "$use_static_rnd" in
1726 egd | dev | unix | default )
1727 AC_MSG_RESULT($use_static_rnd)
1728 ;;
1729 * )
1730 AC_MSG_RESULT([invalid argument])
1731 AC_MSG_ERROR([Option --with-rnd=module used with unsupported module ${use_static_rnd}])
1732 ;;
1733esac
1734
1735AC_ARG_WITH(egd-socket,
1736 [ --with-egd-socket=NAME EGD socket name],
1737 egd_socket_name="$withval", egd_socket_name="" )
1738AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, _("$egd_socket_name") )
1739
1740dnl
1741dnl See whether the user wants to disable checking for /dev/random
1742
1743try_dev_random=yes
1744
1745case "$use_static_rnd" in
1746dev | default )
1747 try_dev_random=yes
1748 ;;
1749egd)
1750 AC_DEFINE(HAVE_EGD_RANDOM)
1751 try_dev_random=no
1752 ;;
1753unix)
1754 AC_DEFINE(HAVE_UNIX_RANDOM)
1755 try_dev_random=no
1756 ;;
1757esac
1758
1759
1760if test "x$try_dev_random" = "xyes"; then
1761 AC_MSG_CHECKING(whether /dev/random exists)
1762 if test -r "/dev/srandom" && test -c "/dev/srandom"; then
1763 AC_DEFINE(HAVE_URANDOM)
1764 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, _("/dev/srandom") )
1765 AC_MSG_RESULT(yes)
1766 if test -r "/dev/urandom" && test -c "/dev/urandom"; then
1767 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, _("/dev/urandom") )
1768 fi
1769 else
1770 if test -r "/dev/random" && test -c "/dev/random"; then
1771 AC_DEFINE(HAVE_URANDOM)
1772 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, _("/dev/random") )
1773 AC_MSG_RESULT(yes)
1774 if test -r "/dev/urandom" && test -c "/dev/urandom"; then
1775 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, _("/dev/urandom") )
1776 fi
1777 else
1778 AC_MSG_RESULT(no)
1779 AC_DEFINE(HAVE_UNIX_RANDOM)
1780 fi
1781 fi
1782fi
1783
1784
1785AC_ARG_ENABLE(udp,
1786 [ --enable-udp server can listen on port 514/udp [[no]]],
1787 [
1788 if test "x${enable_udp}" = xyes; then
1789 AC_DEFINE(INET_SYSLOG)
1790 fi
1791 ]
1792)
1793
1794myencrypt=yes
1795AC_ARG_ENABLE(encrypt,
1796 [ --disable-encrypt disable client/server encryption],
1797 [
1798 if test "x${enable_encrypt}" = xno; then
1799 myencrypt=no
1800 elif test "x${enable_encrypt}" = "x1"; then
1801 myencrypt=1
1802 fi
1803 ]
1804)
1805if test "x${myencrypt}" = "xyes"; then
1806 AC_DEFINE(SH_ENCRYPT)
1807 AC_DEFINE(SH_ENCRYPT_2)
1808elif test "x${myencrypt}" = "x1"; then
1809 AC_DEFINE(SH_ENCRYPT)
1810fi
1811
1812sh_use_srp_proto=yes
1813AC_ARG_ENABLE(srp,
1814 [ --disable-srp disable SRP for authentication],
1815 [
1816 if test "x${enable_srp}" = xno; then
1817 sh_use_srp_proto=no
1818 fi
1819 ]
1820)
1821if test "x${sh_use_srp_proto}" = xyes; then
1822 AC_DEFINE(USE_SRP_PROTOCOL)
1823fi
1824
1825AC_ARG_WITH(port,
1826 [ --with-port=PORT set port to use for TCP/IP connection [[49777]]],
1827 [
1828 echo "${withval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1829 AC_MSG_ERROR([For --with-port=PORT, PORT must be numeric.])
1830 myport=${withval}
1831 ],
1832 [myport="49777"])
1833AC_DEFINE_UNQUOTED(SH_DEFAULT_PORT, ${myport})
1834AC_SUBST(myport)
1835
1836AC_ARG_WITH(logserver,
1837 [ --with-logserver=HOST set host address for log server [[none]]],
1838 [
1839 case "$withval" in
1840 *.* | localhost)
1841 mylogsrv="$withval"
1842 ;;
1843 *)
1844 mylogsrv="$withval"
1845 ;;
1846 esac
1847 ],
1848 [mylogsrv="NULL"])
1849AC_DEFINE_UNQUOTED(DEFAULT_LOGSERVER, _("${mylogsrv}") )
1850AC_SUBST(mylogsrv)
1851
1852AC_ARG_WITH(altlogserver,
1853 [ --with-altlogserver=HOST set address for backup log server [[none]]],
1854 [
1855 case "$withval" in
1856 *.* | localhost)
1857 myaltlogsrv="$withval"
1858 ;;
1859 *)
1860 myaltlogsrv="$withval"
1861 ;;
1862 esac
1863 ],
1864 [myaltlogsrv="NULL"])
1865AC_DEFINE_UNQUOTED(ALT_LOGSERVER, _("${myaltlogsrv}"))
1866
1867
1868
1869dnl
1870dnl STEALTH OPTIONS
1871dnl
1872nocl_code=
1873xor_code=0
1874AC_ARG_ENABLE(nocl,
1875 [ --enable-nocl=PW no CL parsing unless first CL argument is PW],
1876 [
1877 if test "x${enableval}" != "x"; then
1878 AC_DEFINE(SH_STEALTH_NOCL)
1879 fi
1880 if test "x${enableval}" = "xstop" || test "x${enableval}" = "xstart"; then
1881 AC_MSG_ERROR([For --enable-nocl=PW start/stop/reload/restart/status are reserved words.])
1882 fi
1883 if test "x${enableval}" = "xreload" || test "x${enableval}" = "xrestart"; then
1884 AC_MSG_ERROR([For --enable-nocl=PW start/stop/reload/restart/status are reserved words.])
1885 fi
1886 if test "x${enableval}" = "xstatus"; then
1887 AC_MSG_ERROR([For --enable-nocl=PW start/stop/reload/restart/status are reserved words.])
1888 fi
1889 if test "x${enableval}" = "xno"; then
1890 AC_MSG_ERROR([With --enable-nocl=PW, the use of --enable-nocl=no is ambiguous.])
1891 fi
1892 nocl_code="${enable_nocl}"
1893 ]
1894)
1895AC_DEFINE_UNQUOTED(NOCL_CODE, _("${nocl_code}") )
1896AC_SUBST(nocl_code)
1897AC_ARG_ENABLE(stealth,
1898 [ --enable-stealth=XOR_VAL enable stealth mode [[no]]],
1899 [AC_DEFINE(SH_STEALTH)
1900 if test "x${enableval}" != "xyes"; then
1901 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1902 AC_MSG_ERROR([For --enable-stealth=XOR_VAL, XOR_VAL must be numeric.])
1903 if test "${enableval}" -lt 127 || test "${enableval}" -gt 255; then
1904 if test x"${enableval}" = x0
1905 then
1906 :
1907 else
1908 AC_MSG_ERROR([For --enable-stealth=XOR_VAL, XOR_VAL must be in the range 127 to 255.])
1909 fi
1910 fi
1911 xor_code="${enable_stealth}"
1912 else
1913 xor_code=0
1914 fi
1915 stegin_prg="samhain_stealth"
1916 ],
1917 [
1918 stegin_prg=
1919 ]
1920)
1921AC_ARG_ENABLE(micro-stealth,
1922 [ --enable-micro-stealth=XOR_VAL enable micro stealth mode [[no]]],
1923 [
1924 AC_DEFINE(SH_STEALTH)
1925 AC_DEFINE(SH_STEALTH_MICRO)
1926 if test "x${enableval}" != "xyes"; then
1927 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1928 AC_MSG_ERROR([For --enable-micro-stealth=XOR_VAL, XOR_VAL must be numeric.])
1929 if test "${enableval}" -lt 127 || test "${enableval}" -gt 255; then
1930 if test x"${enableval}" = x0
1931 then
1932 :
1933 else
1934 AC_MSG_ERROR([For --enable-micro-stealth=XOR_VAL, XOR_VAL must be in the range 127 to 255.])
1935 fi
1936 fi
1937 xor_code="${enable_micro_stealth}"
1938 else
1939 xor_code=0
1940 fi
1941 ]
1942)
1943install_name="samhain"
1944INSTALL_NAME="SAMHAIN"
1945AC_ARG_ENABLE(install-name,
1946 [ --enable-install-name=NAME name under which to install [[samhain|yule]]],
1947 [
1948 if test "x${enableval}" != "xyes"; then
1949 install_name="${enableval}"
1950 INSTALL_NAME=`echo "${enableval}" | tr [a-z] [A-Z]`
1951 else
1952 install_name="${sh_main_prg}"
1953 INSTALL_NAME=`echo "${sh_main_prg}" | tr [a-z] [A-Z]`
1954 fi
1955 ],
1956 [
1957 install_name="${sh_main_prg}"
1958 INSTALL_NAME=`echo "${sh_main_prg}" | tr [a-z] [A-Z]`
1959 ]
1960)
1961
1962
1963need_user_install=0
1964
1965AC_ARG_ENABLE(identity,
1966 [ --enable-identity=USER user if dropping root [[daemon]]],
1967 [
1968 if test x"$enableval" = xno; then
1969 myident="daemon"
1970 else
1971 myident="$enableval"
1972 fi
1973 echo "${myident}" | grep ['[^0123456789]'] >/dev/null 2>&1 || \
1974 AC_MSG_ERROR([With --enable-identity=USER, please supply a username, not a UID.])
1975 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1976 grep "^${myident}:" | awk -F: '{ print $3; }'`
1977 if test x"${myident_uid}" = x; then
1978 AC_MSG_WARN([Option --enable-identity used, user ${myident} will be added upon install.])
1979 need_user_install=1
1980 fi
1981 ],
1982 [
1983 for myident in ${install_name} daemon nobody; do
1984 AC_MSG_CHECKING(for user ${myident})
1985 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1986 grep "^${myident}:" | awk -F: '{ print $3; }'`
1987 if test x"${myident_uid}" != x; then
1988 AC_MSG_RESULT(yes)
1989 break;
1990 else
1991 AC_MSG_RESULT(no)
1992 fi
1993 done
1994 if test x"${myident_uid}" = x; then
1995 myident=${install_name}
1996 AC_MSG_WARN([--enable-identity: user ${myident} will be added upon install])
1997 need_user_install=1
1998 fi
1999 ])
2000AC_DEFINE_UNQUOTED(DEFAULT_IDENT, _("${myident}") )
2001AC_SUBST(myident)
2002AC_SUBST(need_user_install)
2003
2004sh_insmod_cmd=": # no kernel module"
2005sh_insmod_pre=": # no kernel module"
2006sh_lkm=""
2007lkm_inc=""
2008khidemap="/boot/System.map"
2009sh_syscalltable="0x0"
2010AC_ARG_ENABLE(khide,
2011 [ --enable-khide=SYSTEM_MAP use kernel module to hide (Linux only)[[/boot/System.map]]],
2012 [
2013 if test "x${enable_khide}" != xno; then
2014 if test "x${enableval}" != "xyes"; then
2015 khidemap="${enableval}"
2016 fi
2017 sh_syscalltable=`egrep '(D|d|R|r) sys_call_table' ${khidemap} | awk '{print $1}'`
2018 if test x"$sh_syscalltable" = x; then
2019 AC_MSG_ERROR([Option --enable-khide cannot be used since the symbol sys_call_table was not found in ${khidemap}.])
2020 fi
2021 sh_syscalltable="0x${sh_syscalltable}"
2022 install_name_len=`echo ${install_name} | awk '{ print(length()); }'`
2023 if test "${install_name_len}" -gt 15 ; then
2024 AC_MSG_ERROR([If --enable-khide is used, install_name must not exceed a length of 15 chars.])
2025 fi
2026 AC_DEFINE(SH_USE_LKM)
2027 AC_DEFINE_UNQUOTED(SH_MAGIC_HIDE, "${install_name}")
2028
2029 # -- NEW --
2030 kernel_version=`uname -r | sed s,2.6.*,LINUX26,`
2031 kernel_numeric=`uname -r | sed 's%-%.%g' | sed 's%_%.%g' | awk -F. '{ print $1*65536+$2*256+$3 }'`
2032 AC_DEFINE_UNQUOTED(SH_KERNEL_NUMERIC, ${kernel_numeric}, [Kernel number])
2033
2034 if test x"$kernel_version" = xLINUX26
2035 then
2036 AC_MSG_CHECKING([for modlist_lock])
2037 sh_modlist_lock=`egrep ['[bd] modlist_lock$'] ${khidemap} | awk '{print $1}'`
2038 if test x"$sh_modlist_lock" = x; then
2039 AC_MSG_RESULT(no)
2040 else
2041 sh_modlist_lock="0x${sh_modlist_lock}"
2042 AC_MSG_RESULT([${sh_modlist_lock}])
2043 AC_DEFINE_UNQUOTED(SH_MODLIST_LOCK, ${sh_modlist_lock}, [The address of the modules list spinlock])
2044 fi
2045
2046 AC_MSG_CHECKING([for module_mutex])
2047 sh_modlist_mutex=`egrep ['[bd] module_mutex$'] ${khidemap} | awk '{print $1}'`
2048 if test x"$sh_modlist_mutex" = x; then
2049 AC_MSG_RESULT(no)
2050 else
2051 sh_modlist_mutex="0x${sh_modlist_mutex}"
2052 AC_MSG_RESULT([${sh_modlist_mutex}])
2053 AC_DEFINE_UNQUOTED(SH_MODLIST_MUTEX, ${sh_modlist_mutex}, [The address of the modules list mutex])
2054 fi
2055
2056 sh_list_modules=`egrep 'd modules$' ${khidemap} | awk '{print $1}'`
2057 if test x"$sh_list_modules" = x; then
2058 AC_MSG_ERROR([Option --enable-khide cannot be used, since the symbol modules was not found in ${khidemap}.])
2059 fi
2060 sh_list_modules="0x${sh_list_modules}"
2061 AC_DEFINE_UNQUOTED(SH_LIST_MODULES, ${sh_list_modules}, [The address of the modules list])
2062
2063 AC_DEFINE(LINUX26, 1, [Define if kernel is 2.6])
2064 sh_insmod_cmd="modprobe ${install_name}_hide"
2065 sh_lkm="samhain_hide.ko"
2066 else
2067 sh_insmod_cmd="insmod ${install_name}_hide; insmod ${install_name}_erase; rmmod ${install_name}_erase"
2068 sh_lkm="samhain_hide.o samhain_erase.o"
2069 fi
2070 # -- END NEW --
2071
2072 kvers=`uname -r`
2073 if test -f /lib/modules/${kvers}/build/include/linux/kernel.h; then
2074 lkm_inc="-I/lib/modules/${kvers}/build/include"
2075 else
2076 AC_MSG_WARN([--enable-khide: /lib/modules/${kvers}/build/include/linux not found])
2077 AC_MSG_WARN([--enable-khide: You may need to install the kernel-source])
2078 AC_MSG_WARN([--enable-khide: headers for the currently-running kernel.])
2079 fi
2080
2081 AC_MSG_CHECKING([for 2.4 vanilla kernel])
2082 sh_is_vanilla_kernel=yes
2083 if test -f /lib/modules/${kvers}/build/include/linux/sched.h; then
2084 grep 'next_task,' /lib/modules/${kvers}/build/include/linux/sched.h >/dev/null 2>&1 || sh_is_vanilla_kernel=no
2085 fi
2086 if test x"${sh_is_vanilla_kernel}" = xno; then
2087 AC_MSG_RESULT(no)
2088 else
2089 AC_MSG_RESULT(yes)
2090 AC_DEFINE(SH_VANILLA_KERNEL)
2091 fi
2092
2093 fi
2094 ]
2095)
2096
2097AC_SUBST(install_name)
2098AC_SUBST(INSTALL_NAME)
2099AC_SUBST(stegin_prg)
2100AC_SUBST(xor_code)
2101
2102AC_DEFINE_UNQUOTED(XOR_CODE, ${xor_code})
2103AC_DEFINE_UNQUOTED(SH_SYSCALLTABLE, ${sh_syscalltable})
2104
2105
2106exepack_state0=`${srcdir}/c_random.sh 2>/dev/null`
2107exepack_state1=`${srcdir}/c_random.sh 2>/dev/null`
2108exepack_state2=`${srcdir}/c_random.sh 2>/dev/null`
2109
2110AC_DEFINE_UNQUOTED(EXEPACK_STATE_0, ${exepack_state0})
2111AC_DEFINE_UNQUOTED(EXEPACK_STATE_1, ${exepack_state1})
2112AC_DEFINE_UNQUOTED(EXEPACK_STATE_2, ${exepack_state2})
2113
2114
2115AC_ARG_ENABLE(suidcheck,
2116 [ --enable-suidcheck check for suid/sgid files [[no]]],
2117 [
2118 if test "x${enableval}" = "xyes"; then
2119 AC_DEFINE(SH_USE_SUIDCHK)
2120 fi
2121 ]
2122)
2123
2124
2125systemmap="/boot/System.map"
2126sh_libkvm=""
2127AC_ARG_WITH(kcheck,
2128 [ --with-kcheck[[=SYSTEM_MAP]] check Linux/FreeBSD/OpenBSD kernel integrity [[/boot/System.map]]],
2129 [
2130 if test "x${withval}" != "xno"; then
2131 AC_DEFINE(SH_USE_KERN)
2132
2133 kernel_numeric=`uname -r | sed 's%-%.%g' | sed 's%_%.%g' | awk -F. '{ print $1*65536+$2*256+$3 }'`
2134 AC_DEFINE_UNQUOTED(SH_KERNEL_NUMBER, ${kernel_numeric}, [Kernel number])
2135
2136 kernelversion=`uname -r`
2137 AC_DEFINE_UNQUOTED(SH_KERNEL_VERSION, _("${kernelversion}"), [Define the kernel version])
2138
2139 if test "x${withval}" != "xyes"; then
2140 systemmap="${withval}"
2141 fi
2142
2143 if test "x${cross_compiling}" = xyes; then
2144 :
2145 elif test "x$selectconfig" = "xfreebsd"; then
2146 LIBS="$LIBS -lkvm"
2147 sh_libkvm="-lkvm"
2148 elif test -f "${systemmap}"; then
2149
2150 test_kmap_open=no
2151
2152 if test -c /dev/kmem; then
2153 AC_MSG_CHECKING([whether /dev/kmem is useable])
2154 dd bs=4 if=/dev/kmem of=/dev/null 2>&1 | grep opening >/dev/null
2155 if test $? -ne 0; then
2156 test_kmap_open=yes
2157 fi
2158 AC_MSG_RESULT([${test_kmap_open}])
2159 fi
2160
2161 if test x"${test_kmap_open}" = xno; then
2162 # need kernel module
2163
2164 if test -f /lib/modules/${kernelversion}/build/include/linux/kernel.h; then
2165 lkm_inc="-I/lib/modules/${kernelversion}/build/include"
2166 else
2167 AC_MSG_WARN([--enable-khide: /lib/modules/${kernelversion}/build/include/linux not found])
2168 AC_MSG_WARN([--enable-khide: You may need to install the kernel-source])
2169 AC_MSG_WARN([--enable-khide: headers for the currently-running kernel.])
2170 fi
2171
2172 AC_MSG_CHECKING([for vmlist_lock])
2173 sh_vmlist_lock=`egrep ['[bdBD] vmlist_lock$'] ${systemmap} | awk '{print $1}'`
2174 if test x"$sh_vmlist_lock" = x; then
2175 AC_MSG_RESULT(no)
2176 else
2177 sh_vmlist_lock="0x${sh_vmlist_lock}"
2178 AC_MSG_RESULT([${sh_vmlist_lock}])
2179 AC_DEFINE_UNQUOTED(SH_VMLIST_LOCK, ${sh_vmlist_lock}, [The address of the vmlist spinlock])
2180 fi
2181
2182 AC_MSG_CHECKING([for vmlist])
2183 sh_vmlist=`egrep ['[bdBD] vmlist$'] ${systemmap} | awk '{print $1}'`
2184 if test x"$sh_vmlist" = x; then
2185 AC_MSG_RESULT(no)
2186 else
2187 sh_vmlist="0x${sh_vmlist}"
2188 AC_MSG_RESULT([${sh_vmlist}])
2189 AC_DEFINE_UNQUOTED(SH_VMLIST, ${sh_vmlist}, [The address of the vmlist])
2190 fi
2191
2192 sh_lkm="${sh_lkm} samhain_kmem.ko"
2193 sh_insmod_pre="modprobe ${install_name}_kmem"
2194
2195 fi
2196 else
2197 AC_MSG_ERROR([Option --with-kcheck=systemmap cannot be used, because system map ${systemmap} does not exist.])
2198 fi
2199 fi
2200 ]
2201)
2202
2203AC_SUBST(lkm_inc)
2204AC_SUBST(sh_lkm)
2205AC_SUBST(sh_insmod_cmd)
2206AC_SUBST(sh_insmod_pre)
2207
2208AC_SUBST(systemmap)
2209AC_SUBST(sh_libkvm)
2210
2211AC_ARG_ENABLE(base,
2212 [ --enable-base=B1,B2 base key (0...2147483647)],
2213 [
2214 AC_MSG_CHECKING(base key setting)
2215 my_key_A=`echo ${enableval} | awk 'BEGIN{FS=","}{print $1}'`
2216 my_key_B=`echo ${enableval} | awk 'BEGIN{FS=","}{print $2}'`
2217 AC_MSG_RESULT(${my_key_A} ${my_key_B})
2218 if test "x${my_key_A}" = x; then
2219 AC_MSG_ERROR([Option --enable-base=B1,B2 used with invalid first base key (zero length).])
2220 fi
2221 if test "x${my_key_B}" = x; then
2222 AC_MSG_ERROR([Option --enable-base=B1,B2 used with invalid second base key (zero length).])
2223 fi
2224 echo "${my_key_A}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
2225 AC_MSG_ERROR([For --enable-base=B1,B2, B1 and B2 must be numeric in the range 0 to 2147483647.])
2226 echo "${my_key_B}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
2227 AC_MSG_ERROR([For --enable-base=B1,B2, B1 and B2 must be numeric in the range 0 to 2147483647.])
2228 ],
2229 [
2230 AC_MSG_CHECKING(base key setting .. collecting entropy)
2231 my_key_1=`${srcdir}/c_random.sh 2>/dev/null`
2232 my_key_2=`${srcdir}/c_random.sh 2>/dev/null`
2233 my_key_3=`${srcdir}/c_random.sh 2>/dev/null`
2234 my_key_4=`${srcdir}/c_random.sh 2>/dev/null`
2235 my_key_A=`expr $my_key_1 \* 32767`
2236 my_key_A=`echo ${my_key_A} | sed 's%^0*%%g' 2>/dev/null`
2237 my_key_A=`expr $my_key_A \+ $my_key_2`
2238 my_key_B=`expr $my_key_3 \* 32767`
2239 my_key_B=`echo ${my_key_B} | sed 's%^0*%%g' 2>/dev/null`
2240 my_key_B=`expr $my_key_B \+ $my_key_4`
2241 AC_MSG_RESULT(${my_key_A} ${my_key_B})
2242 ]
2243 )
2244AC_SUBST(my_key_A)
2245AC_SUBST(my_key_B)
2246
2247dnl low bytes
2248my_key_1=`expr $my_key_A \% 65536`
2249dnl high bytes
2250my_key_2=`expr $my_key_A \/ 65536`
2251dnl low bytes
2252my_key_3=`expr $my_key_B \% 65536`
2253dnl high bytes
2254my_key_4=`expr $my_key_B \/ 65536`
2255
2256dnl echo ${my_key_1} ${my_key_2} ${my_key_3} ${my_key_4}
2257
2258dnl touch ./sh_MK.h
2259dnl echo "#ifndef SH_MK_H" >> ./sh_MK.h
2260dnl echo "#define SH_MK_H" >> ./sh_MK.h
2261dnl ${srcdir}/c_bits.sh ${my_key_1} MKB >> ./sh_MK.h
2262dnl ${srcdir}/c_bits.sh ${my_key_2} MKA >> ./sh_MK.h
2263dnl ${srcdir}/c_bits.sh ${my_key_3} MKC >> ./sh_MK.h
2264dnl ${srcdir}/c_bits.sh ${my_key_4} MKD >> ./sh_MK.h
2265dnl echo "#endif" >> ./sh_MK.h
2266AC_SUBST(my_key_1)
2267AC_SUBST(my_key_2)
2268AC_SUBST(my_key_3)
2269AC_SUBST(my_key_4)
2270
2271AC_MSG_CHECKING(key position)
2272pos_tf_1=`${srcdir}/c_random.sh 2>/dev/null`
2273pos_tf_2=`expr $pos_tf_1 \% 8`
2274pos_tf=`expr $pos_tf_2 + 1`
2275AC_MSG_RESULT(${pos_tf})
2276AC_DEFINE_UNQUOTED(POS_TF, ${pos_tf} )
2277
2278mykeybase=`echo ${my_key_A},${my_key_B}`
2279AC_DEFINE_UNQUOTED(DEFKEY, ${mykeybase} )
2280AC_SUBST(mykeybase)
2281
2282
2283dnl
2284dnl GPG/PGP options
2285dnl
2286
2287AC_ARG_WITH(gpg,
2288 [ --with-gpg=PATH use GnuPG to verify database/config [[no]]],
2289 [
2290 if test "x${withval}" != "xno"; then
2291 if test "x${cross_compiling}" = xyes; then
2292 mygpg="${withval}"
2293 else
2294 if test -f "${withval}"; then
2295 mygpg="${withval}"
2296 mychk0=`${withval} --load-extension tiger --print-md TIGER192 ${withval} 2>/dev/null`
2297 if test "x$?" != "x0"; then
2298 mychktest=no
2299 for sampre in ./samhain ./yule /usr/local/sbin/samhain /usr/local/bin/samhain /usr/bin/samhain /usr/sbin/samhain /usr/local/sbin/yule /usr/local/bin/yule /usr/bin/yule /usr/sbin/yule; do
2300 if test x"${mychktest}" = xyes
2301 then
2302 :
2303 else
2304 if test -f ${sampre}
2305 then
2306 echo "use existing ${sampre} for gpg checksum"
2307 mychk0=`${sampre} -H ${withval} 2>/dev/null`
2308 if test "x$?" != "x0"; then
2309 if test "x${nocl_code}" != "x"; then
2310 mychk0=`echo -H ${withval} | ${sampre} ${nocl_code} 2>/dev/null`
2311 if test "x$?" != "x0"; then
2312 :
2313 else
2314 mychk="${mychk0}"
2315 mychktest=yes
2316 fi
2317 fi
2318 else
2319 mychk="${mychk0}"
2320 mychktest=yes
2321 fi
2322 fi
2323 fi
2324 done
2325 if test x${mychktest} = xno; then
2326 AC_MSG_WARN([--with-gpg: cannot determine TIGER192 checksum of ${withval}])
2327 echo "-------------------------------------------------------------"
2328 echo " Your gpg binary does not support the TIGER192 checksum, "
2329 echo " and I cannot find an existing samhain binary to use instead."
2330 echo " You can:"
2331 echo " (a) run make to compile a samhain binary, then repeat"
2332 echo " ./configure and make"
2333 echo " (b) ignore the failure. The checksum of the gpg binary"
2334 echo " will not get compiled in, thus allowing an attacker"
2335 echo " to replace gpg with a trojan and subverting the gpg"
2336 echo " signature verification of configure and database files."
2337 echo
2338 echo " PLEASE IGNORE THIS MESSAGE IF YOU ALSO USE --with-checksum"
2339 echo "-------------------------------------------------------------"
2340 fi
2341 else
2342 mychk="${mychk0}"
2343 fi
2344 else
2345 AC_MSG_ERROR([--with-gpg: cannot find GnuPG PATH=${withval}])
2346 fi
2347 fi
2348 AC_DEFINE(WITH_GPG)
2349 AC_DEFINE_UNQUOTED(DEFAULT_GPG_PATH, _("${mygpg}") )
2350 AC_SUBST(mygpg)
2351 fi
2352 ]
2353)
2354
2355AC_ARG_WITH(keyid,
2356 [ --with-keyid=KEYID specify KeyID (0x...) for GPG/PGP functions [[none]]],
2357 [
2358 if test "x${withval}" != "x"; then
2359 echo "${withval}" | awk '{if((length($0)==10)||(length($0)==18)){exit 2}else{exit 0}}' &&
2360 AC_MSG_ERROR([--with-keyid:${withval} must be "0x" + 8|16 hex digits])
2361 echo "${withval}" | grep ['[^0][^x][^0123456789ABCDEFabcdef]'] >/dev/null 2>&1 &&
2362 AC_MSG_ERROR([--with-keyid:${withval} must be "0x" + 8|16 hex digits])
2363 mykeyid="$withval"
2364 mykeytag="--default-key"
2365 else
2366 mykeyid=""
2367 mykeytag=""
2368 fi
2369 AC_SUBST(mykeyid)
2370 AC_SUBST(mykeytag)
2371 ]
2372)
2373
2374dnl AC_ARG_WITH(pgp,
2375dnl [ --with-pgp=PATH Use PGP to verify database/config (no).],
2376dnl [myppg="$withval"
2377dnl AC_DEFINE(WITH_PGP)
2378dnl AC_DEFINE_UNQUOTED(DEFAULT_PGP_PATH, _("${myppg}") )
2379dnl ])
2380
2381AC_ARG_WITH(checksum,
2382 [ --with-checksum=CHKSUM compile in gpg/pgp checksum [[yes]]],
2383 [
2384 if test "x${withval}" != "xno"; then
2385 if test "x${withval}" != "xyes"; then
2386 if test "x${mychk}" != "x"; then
2387 if test "x${mychk}" != "x${withval}"; then
2388 AC_MSG_WARN([--with-checksum: possible gpg CHKSUM problem])
2389 AC_MSG_WARN([--with-checksum: CHKSUM=${withval}])
2390 AC_MSG_WARN([--with-checksum: autodetected=${mychk}])
2391 fi
2392 fi
2393 mychk="${withval}"
2394 else
2395 if test "x${mychk}" = "x"; then
2396 AC_MSG_ERROR([Option --with-checksum=CHKSUM: checksum CHKSUM of the gpg binary not specified.])
2397 fi
2398 fi
2399 AC_DEFINE(HAVE_GPG_CHECKSUM)
2400 AC_DEFINE_UNQUOTED(GPG_HASH, _("${mychk}") )
2401 echo "${mychk}" | sed 's,.*:,,g' | sed 's, ,,g' | sed 's,\(.\),\1:,g' | awk '{ split($0, arr, ":"); m = length($1)/2; print "#ifndef CHKSUM_H"; print "#define CHKSUM_H"; print "char gpgchk[50];"; for (i=1; i <= m; i++) printf "gpgchk[%d] = %c%s%c;\n", i-1, 39, arr[i], 39; printf "gpgchk[48] = %c%c0%c;\n", 39, 92, 39; print "#endif"; }' > sh_gpg_chksum.h
2402 fi
2403 ],
2404 [
2405 if test "x${mygpg}" != "x"; then
2406 if test "x${mychk}" != "x"; then
2407 AC_DEFINE(HAVE_GPG_CHECKSUM)
2408 AC_DEFINE_UNQUOTED(GPG_HASH, _("${mychk}") )
2409 echo "${mychk}" | sed 's,.*:,,g' | sed 's, ,,g' | sed 's,\(.\),\1:,g' | awk '{ split($0, arr, ":"); m = length($1)/2; print "#ifndef CHKSUM_H"; print "#define CHKSUM_H"; print "char gpgchk[50];"; for (i=1; i <= m; i++) printf "gpgchk[%d] = %c%s%c;\n", i-1, 39, arr[i], 39; printf "gpgchk[48] = %c%c0%c;\n", 39, 92, 39; print "#endif"; }' > sh_gpg_chksum.h
2410 fi
2411 fi
2412 ]
2413)
2414
2415AC_ARG_WITH(fp,
2416 [ --with-fp=FINGERPRINT compile in public key fingerprint [[no]]],
2417 [
2418 if test "x${withval}" != "xno"; then
2419 if test "x${withval}" != "xyes"; then
2420 withval0=`echo ${withval} | sed 's% %%g'`
2421 echo "${withval0}" | \
2422 grep ['[^0123456789abcdefABCDEF]'] >/dev/null 2>&1 &&
2423 AC_MSG_ERROR([In option --with-fp=FINGERPRINT, there is an invalid character(s) in FINGERPRINT=${withval0}.])
2424 sh_len=`echo ${withval0} | wc -c | sed 's% %%g'`
2425 sh_len0=`expr ${sh_len} \- 1`
2426 if test "x${sh_len0}" = "x40" || test "x${sh_len0}" = "x32"
2427 then
2428 myfp="${withval0}"
2429 AC_DEFINE(USE_FINGERPRINT)
2430 AC_DEFINE_UNQUOTED(SH_GPG_FP, _("${myfp}") )
2431 echo "${myfp}" | sed 's,.*:,,g' | sed 's, ,,g' | sed 's,\(.\),\1:,g' | awk '{ split($0, arr, ":"); m = length($1)/2; print "#ifndef FINGERPRINT_H"; print "#define FINGERPRINT_H"; printf "char gpgfp[%d];\n", m+1; for (i=1; i <= m; i++) printf "gpgfp[%d] = %c%s%c;\n", i-1, 39, arr[i], 39; printf "gpgfp[%d] = %c%c0%c;\n", m, 39, 92, 39; print "#endif"; }' > sh_gpg_fp.h
2432 else
2433 AC_MSG_ERROR([In option --with-fp=FINGERPRINT, the length (${sh_len0}) of FINGERPRINT ${withval0} is incorrect.])
2434 fi
2435 else
2436 AC_MSG_ERROR([For option --with-fp=FINGERPRINT, FINGERPRINT=yes is invalid, please specify a valid key fingerprint.])
2437 fi
2438 fi
2439 ])
2440
2441
2442dnl
2443dnl MAIL OPTIONS
2444dnl
2445
2446AC_ARG_WITH(recipient,
2447 [ --with-recipient=ADDR set recipient(s) for e-mail [[none]]],
2448 [
2449 withval0=`echo ${withval} | sed 's%,% %g'`
2450 for sh_item in ${withval0}
2451 do
2452 case ${sh_item} in
2453 *@localhost)
2454 ;;
2455 *@*.*)
2456 sh_tmp=`echo ${sh_item} | awk '{ if ($1 ~ [/^[a-zA-Z0-9][a-zA-Z0-9\-_\.]*@[a-zA-Z0-9\-\.]+\.([a-zA-Z]+|[0-9]+)$/]) {print 1; } else { print 0}}'`
2457 if test "x${sh_tmp}" != "x1"
2458 then
2459 AC_MSG_ERROR([Option --with-recipient=ADDR used with invalid mail address ${sh_item}.])
2460 fi
2461 ;;
2462 *)
2463 AC_MSG_ERROR([Option --with-recipient=ADDR used with invalid mail address ${sh_item}.])
2464 ;;
2465 esac
2466 done
2467 myrcp="$withval0"
2468 ],
2469 [myrcp="NULL"])
2470AC_DEFINE_UNQUOTED(DEFAULT_MAILADDRESS, _("${myrcp}") )
2471
2472
2473AC_ARG_WITH(sender,
2474 [ --with-sender=SENDER set sender for e-mail [[daemon]]],
2475 [
2476 mysender="${withval}"
2477 ],
2478 [
2479 mysender="daemon"
2480 ])
2481AC_DEFINE_UNQUOTED(DEFAULT_SENDER, _("${mysender}") )
2482
2483
2484dnl
2485dnl PATHS
2486dnl
2487
2488AC_ARG_WITH(trusted,
2489 [ --with-trusted=UID Set uid(s) of trusted users [[0]]],
2490 [
2491 sh_tmp_test=no
2492 sh_tmp=`echo ${withval} | sed 's%,% %g'`
2493 for sh_tmp1 in ${sh_tmp}
2494 do
2495 echo "${sh_tmp1}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
2496 AC_MSG_ERROR([Option --with-trusted=UID used with non-numeric UID in ${withval}.])
2497 if test "x${sh_tmp1}" = "x0"
2498 then
2499 sh_tmp_test=yes
2500 fi
2501 done
2502 if test "x${sh_tmp_test}" = "xno"
2503 then
2504 withval="0,${withval}"
2505 fi
2506 mytrust="${withval}"
2507 ],
2508 [mytrust="0"] )
2509AC_DEFINE_UNQUOTED(SL_ALWAYS_TRUSTED, ${mytrust} )
2510AC_SUBST(mytrust)
2511
2512mytmpdir=
2513
2514AC_ARG_WITH(tmp-dir,
2515 [ --with-tmp-dir=PFX set directory for temporary files [[HOME]]],
2516 [
2517 if test "x${cross_compiling}" = xyes; then
2518 mytmpdir="$withval"
2519 AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${mytmpdir}") )
2520 else
2521 if test -d "${withval}"; then
2522 mytmpdir="$withval"
2523 AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${mytmpdir}") )
2524 else
2525 mytmpdir="$withval"
2526 AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${mytmpdir}") )
2527 AC_MSG_WARN([--with-tmp-dir: tmp directory ${withval} does not exist])
2528 fi
2529 fi
2530 ]
2531)
2532
2533AC_SUBST(mytmpdir)
2534
2535
2536dnl
2537dnl PATH DEFAULTS
2538dnl
2539
2540if test "x${ac_prefix_set}" = xyes
2541then
2542 if test "x${exec_prefix}" = xNONE
2543 then
2544 exec_prefix="${prefix}"
2545 fi
2546
2547 if test "x${prefix}" = xOPT
2548 then
2549 tmp_sbindir="/opt/${install_name}/bin"
2550 tmp_sysconfdir="/etc/opt"
2551 tmp_mandir="/opt/${install_name}/man"
2552 tmp_localstatedir="/var/opt/${install_name}"
2553 elif test "x${prefix}" = xUSR
2554 then
2555 tmp_sbindir="/usr/sbin"
2556 tmp_sysconfdir="/etc"
2557 tmp_mandir="/usr/share/man"
2558 tmp_localstatedir="/var"
2559 else
2560 tmp_sbindir=`eval echo ${sbindir}`
2561 tmp_sysconfdir=`eval echo ${sysconfdir}`
2562 tmp_mandir=`eval echo ${mandir}`
2563 tmp_localstatedir=`eval echo ${localstatedir}`
2564 fi
2565else
2566 prefix=""
2567 if test "x${ac_exec_prefix_set}" = xyes
2568 then
2569 tmp_sbindir=`eval echo ${sbindir}`
2570 else
2571 tmp_sbindir="/usr/local/sbin"
2572 fi
2573 tmp_sysconfdir="/etc"
2574 # share/man -> man (FHS) 11.10.2002
2575 tmp_mandir="/usr/local/man"
2576 tmp_localstatedir="/var"
2577fi
2578
2579
2580if test "x${ac_sbindir_set}" = xyes
2581then
2582 :
2583else
2584 sbindir=`eval echo ${tmp_sbindir}`
2585fi
2586
2587
2588if test "x${ac_sysconfdir_set}" = xyes
2589then
2590 :
2591else
2592 sysconfdir=`eval echo ${tmp_sysconfdir}`
2593fi
2594
2595if test "x${ac_mandir_set}" = xyes
2596then
2597 :
2598else
2599 mandir=`eval echo ${tmp_mandir}`
2600fi
2601
2602if test "x${ac_localstatedir_set}" = xyes
2603then
2604 :
2605else
2606 localstatedir=`eval echo ${tmp_localstatedir}`
2607fi
2608
2609
2610
2611AC_ARG_WITH(config-file,
2612 [ --with-config-file=FILE configuration file [[/etc/{install_name}rc]]],
2613 [
2614 myconffile="${withval}"
2615 changequote(<<, >>)dnl
2616 tmp=`echo ${withval} | sed 's%^REQ_FROM_SERVER%%'`
2617 sysconfdir=`echo ${tmp} | sed 's%/[^/][^/]*$%%'`
2618 myrpmconffile="${tmp}"
2619 changequote([, ])dnl
2620 ],
2621 [
2622 myconffile="${sysconfdir}/${install_name}rc"
2623 myrpmconffile="${myconffile}"
2624 ]
2625)
2626AC_DEFINE_UNQUOTED(DEFAULT_CONFIGFILE, _("${myconffile}") )
2627AC_SUBST(myconffile)
2628AC_SUBST(myrpmconffile)
2629
2630AC_ARG_WITH(log-file,
2631 [ --with-log-file=FILE path of log file [[/var/log/{install_name}_log]]],
2632 [
2633 mylogfile="$withval"
2634 changequote(<<, >>)dnl
2635 mylogdir=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
2636 changequote([, ])dnl
2637 ],
2638 [
2639 if test "x${mytclient}" = "x-DSH_WITH_SERVER"; then
2640 mylogfile="${localstatedir}/log/${install_name}/${install_name}_log"
2641 mylogdir="${localstatedir}/log/${install_name}"
2642 else
2643 mylogfile="${localstatedir}/log/${install_name}_log"
2644 mylogdir="${localstatedir}/log"
2645 fi
2646 ]
2647)
2648AC_DEFINE_UNQUOTED(DEFAULT_ERRFILE, _("${mylogfile}") )
2649AC_DEFINE_UNQUOTED(DEFAULT_LOGDIR, _("${mylogdir}") )
2650AC_SUBST(mylogfile)
2651AC_SUBST(mylogdir)
2652
2653AC_ARG_WITH(pid-file,
2654 [ --with-pid-file=FILE set path of pid file [[/var/run/{install_name}.pid]]],
2655 [
2656 mylockfile="$withval"
2657 changequote(<<, >>)dnl
2658 mylockdir=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
2659 changequote([, ])dnl
2660 ],
2661 [
2662 mylockfile="${localstatedir}/run/${install_name}.pid"
2663 mylockdir="${localstatedir}/run"
2664 ]
2665)
2666AC_DEFINE_UNQUOTED(DEFAULT_ERRLOCK, _("${mylockfile}") )
2667AC_DEFINE_UNQUOTED(DEFAULT_PIDDIR, _("${mylockdir}") )
2668AC_SUBST(mylockfile)
2669AC_SUBST(mylockdir)
2670
2671AC_ARG_WITH(state-dir,
2672 [ --with-state-dir=PFX set state data directory [[/var/lib/{install_name}]]],
2673 [
2674 mydataroot="$withval"
2675 ],
2676 [
2677 mydataroot="${localstatedir}/lib/${install_name}"
2678 ]
2679 )
2680AC_ARG_WITH(data-file,
2681 [ --with-data-file=FILE set path of data file],
2682 [
2683 mydatafile="$withval"
2684 changequote(<<, >>)dnl
2685 tmp=`echo ${withval} | sed 's%^REQ_FROM_SERVER%%'`
2686 mydataroot=`echo ${tmp} | sed 's%/[^/][^/]*$%%'`
2687 myrpmdatafile="${tmp}"
2688 changequote([, ])dnl
2689 if test x"${tmp}" = x
2690 then
2691 echo "No local path in data file ${withval}"
2692 echo "This will not work for initializing the database."
2693 if test x"${withval}" = xREQ_FROM_SERVER
2694 then
2695 echo "It should be REQ_FROM_SERVER/some/local/path"
2696 fi
2697 AC_MSG_ERROR([Option --with-data-file=FILE used with invalid path ${withval}.])
2698 fi
2699 ],
2700 [
2701 mydatafile="${mydataroot}/${install_name}_file"
2702 myrpmdatafile="${mydatafile}"
2703 ])
2704AC_DEFINE_UNQUOTED(DEFAULT_DATA_FILE, _("${mydatafile}") )
2705AC_SUBST(mydatafile)
2706AC_SUBST(myrpmdatafile)
2707
2708AC_DEFINE_UNQUOTED(DEFAULT_DATAROOT, _("${mydataroot}") )
2709AC_SUBST(mydataroot)
2710
2711AC_DEFINE_UNQUOTED(DEFAULT_QDIR, _("${mydataroot}/.quarantine") )
2712AC_SUBST(myqdir)
2713
2714
2715AC_ARG_WITH(html-file,
2716 [ --with-html-file=FILE set path of html file,],
2717 [
2718 myhtmlfile="$withval"
2719 ],
2720 [
2721 myhtmlfile="${mylogdir}/${install_name}.html"
2722 ])
2723AC_DEFINE_UNQUOTED(DEFAULT_HTML_FILE, _("${myhtmlfile}") )
2724AC_SUBST(myhtmlfile)
2725
2726
2727mydefargs=$ac_configure_args
2728# if test -z "`echo "$mydefargs" | grep "\-\-enable\-static" 2> /dev/null`"
2729# then
2730# mydefargs="--enable-static $mydefargs"
2731# fi
2732if test -z "`echo "$mydefargs" | grep "\-\-enable\-base" 2> /dev/null`"
2733then
2734 mydefargs="--enable-base=${mykeybase} $mydefargs"
2735fi
2736AC_SUBST(mydefargs)
2737
2738
2739AC_DEFINE_UNQUOTED(SH_INSTALL_DIR, _("${sbindir}"))
2740AC_DEFINE_UNQUOTED(SH_INSTALL_PATH, _("${sbindir}/${install_name}"))
2741AC_DEFINE_UNQUOTED(SH_INSTALL_NAME, _("${install_name}"))
2742
2743AC_CONFIG_HEADER(config.h)
2744
2745AC_OUTPUT(
2746[
2747Makefile
2748samhain-install.sh
2749init/samhain.startLSB
2750init/samhain.startLinux
2751init/samhain.startGentoo
2752init/samhain.startFreeBSD
2753init/samhain.startSolaris
2754init/samhain.startHPUX
2755init/samhain.startIRIX
2756init/samhain.startMACOSX
2757samhain.spec
2758rules.deb
2759rules.deb-light
2760hp_ux.psf
2761scripts/samhain.spec
2762scripts/redhat_i386.client.spec
2763scripts/samhain.ebuild
2764scripts/samhain.ebuild-light
2765scripts/samhainadmin.pl
2766scripts/yuleadmin.pl
2767scripts/check_samhain.pl
2768deploy.sh
2769],
2770[
2771echo timestamp > stamp-h
2772chmod +x samhain-install.sh
2773chmod +x scripts/samhainadmin.pl
2774chmod +x scripts/yuleadmin.pl
2775chmod +x scripts/check_samhain.pl
2776]
2777)
2778
2779chmod +x deploy.sh
2780
2781if test "x${cross_compiling}" = xyes
2782then
2783
2784echo "--------------------------------------------------------------"
2785echo
2786echo "You are using a cross-compiler. The following system dependent"
2787echo "values may have been set to default values that may be"
2788echo "incorrect for your target system: "
2789echo
2790echo "ac_cv_c_bigendian bigendian byte order ${ac_cv_c_bigendian}"
2791echo "ac_cv_c_long_double long double exists ${ac_cv_c_long_double}"
2792echo "ac_cv_sizeof_char_p size of pointer to char ${ac_cv_sizeof_char_p}"
2793echo "ac_cv_sizeof_char_p size of size_t ${ac_cv_sizeof_size_t}"
2794echo "ac_cv_sizeof_unsigned_int size of unsigned int ${ac_cv_sizeof_unsigned_int}"
2795echo "ac_cv_sizeof_unsigned_long size of unsigned long ${ac_cv_sizeof_unsigned_long}"
2796echo "ac_cv_sizeof_unsigned_short size of unsigned short ${ac_cv_sizeof_unsigned_short}"
2797echo
2798echo "If these values are incorrect, change them in the file "
2799echo "config.cache and run configure again."
2800echo
2801echo "--------------------------------------------------------------"
2802
2803fi
2804
2805if test x${silent} != xyes
2806then
2807
2808 # A=`eval echo ${sbindir}` ; A=`eval echo ${A}`
2809 # B=`eval echo ${myconffile}` ; B=`eval echo ${B}`
2810 # C=`eval echo ${mandir}` ; C=`eval echo ${C}`
2811 # D=`eval echo ${mylockfile}` ; D=`eval echo ${D}`
2812 # E=`eval echo ${mylogfile}` ; E=`eval echo ${E}`
2813 # F=`eval echo ${mydataroot}` ; F=`eval echo ${F}`
2814
2815 echo
2816 echo " samhain has been configured as follows:"
2817 echo " System binaries: ${sbindir}"
2818 echo " Configuration file: ${myconffile}"
2819 echo " Manual pages: ${mandir}"
2820 echo " Data: ${mydataroot}"
2821 echo " PID file: ${mylockfile}"
2822 echo " Log file: ${mylogfile}"
2823 echo " Base key: ${mykeybase}"
2824 if test x"$mykeyid" != x
2825 then
2826 echo " target GPG/PGP key: ${mykeyid}"
2827 fi
2828 echo
2829 if test x"$mytclient" = x"-DSH_WITH_SERVER"
2830 then
2831 echo " Selected rc file: yulerc"
2832 else
2833 echo " Selected rc file: samhainrc.${selectconfig}"
2834 fi
2835
2836fi
2837
Note: See TracBrowser for help on using the repository browser.