1 AC_INIT(darkstat, 3.0.0-git)
2 AC_CONFIG_SRCDIR([darkstat.c])
3 AC_CONFIG_HEADER([config.h])
5 RULE="------------------------------------------------------------"
7 # Let user specify CHROOT_DIR, or else autodetect it, or else die.
8 AC_ARG_WITH(chroot-dir, AS_HELP_STRING([--with-chroot-dir],
9 [specify the chroot directory (default: /var/empty)]),
11 [# Find an "empty" directory to serve as the chroot.
13 AC_MSG_CHECKING([for $_chd])
14 if test -d $_chd ; then
15 AC_MSG_RESULT(found it)
17 AC_MSG_RESULT(not there - what a shitty Unix)
19 AC_MSG_CHECKING([for $_chd])
20 if test -d $_chd ; then
21 AC_MSG_RESULT(found it)
23 AC_MSG_RESULT(not there either)
24 AC_MSG_ERROR([please specify --with-chroot-dir])
27 AC_DEFINE_UNQUOTED(CHROOT_DIR, "$_chd", [Default chroot directory.])
29 # Allow configure-time override of PRIVDROP_USER.
30 AC_ARG_WITH(privdrop-user, AS_HELP_STRING([--with-privdrop-user],
31 [specify which user to drop privileges to (default: nobody)]),
34 AC_DEFINE_UNQUOTED(PRIVDROP_USER, "$_pdu", [User to privdrop to.])
36 # Checks for programs.
40 # Augment CFLAGS for fun.
41 echo "int main(void){return 1;}" > conftest.$ac_ext
43 AC_MSG_CHECKING(if your C compiler wants a hit off the pipe)
45 CFLAGS="-pipe $CFLAGS"
46 if (eval $ac_link) 2>/dev/null; then
47 AC_MSG_RESULT(sure does)
53 AC_ARG_WITH(mad-warnings, AS_HELP_STRING([--with-mad-warnings],
54 [turn on lots of compile-time warnings, this needs GCC and is only
55 really useful for development]),
56 [if test "$withval" = yes ; then
57 AC_MSG_CHECKING(if your C compiler throws mad warnings)
59 CFLAGS="$CFLAGS -Wall -Wredundant-decls -Wnested-externs \
60 -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
61 -Winline -Wcast-qual -W -Wbad-function-cast -Wcast-align \
62 -Wchar-subscripts -Wshadow -Wwrite-strings \
63 -Wuninitialized -Winline"
64 if (eval $ac_link) 2>/dev/null; then
65 AC_MSG_RESULT(sure does)
72 rm -f conftest.$ac_objext conftest.$ac_ext
77 AC_CHECK_LIB(z, deflate,, [
81 I can't link to zlib. You really can't have a modern
82 operating system without zlib.
84 If you are using a package-based operating system (like
85 something with RPMs), see if there is a zlib-devel package
86 that you can install, to provide the zlib headers and
91 AC_MSG_ERROR([can't find usable zlib])])
96 # Must do at least socket and nsl before checking for libpcap.
97 AC_CHECK_LIB(nsl, gethostbyname)
98 AC_CHECK_LIB(socket, socket)
99 AC_CHECK_LIB(resolv, inet_aton)
104 AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
105 [prefix to libpcap installation]),
106 [if test "$withval" = yes ; then
107 AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
109 if test "$withval" != no ; then
113 if test -n "$PCAP_HOME" ; then
114 LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
115 CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
116 CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
118 CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
121 AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
123 if test -z "$PCAP_BROKEN" ; then
124 AC_CHECK_HEADERS(pcap.h,,
125 [# Couldn't find headers, try include/pcap
126 CPPFLAGS="$CPPFLAGS2"
127 AC_MSG_NOTICE([checking in include/pcap])
128 unset ac_cv_header_pcap_h
129 AC_CHECK_HEADERS(pcap.h,
130 AC_MSG_RESULT([I hate you.]),
134 if test -n "$PCAP_BROKEN" ; then
138 darkstat absolutely requires libpcap to be installed. If
139 it's installed into a prefix that isn't being picked up by
140 configure, for example /usr/local, re-run configure and add
141 --with-pcap=/usr/local
143 If you are using a package-based operating system (like
144 something with RPMs), see if there is a pcap-devel or
145 libpcap-devel package that you can install, to provide the
146 pcap headers and libraries.
148 Failing all of the above, go to http://www.tcpdump.org/ and
149 download the source distribution of libpcap and build it
154 AC_MSG_ERROR([can't find usable libpcap])
159 # A real OS will have setproctitle()
160 AC_CHECK_LIB(c, setproctitle,
161 AC_DEFINE(HAVE_SETPROCTITLE, 1,
162 [Define to 1 if you have setproctitle().]))
164 # A real OS will have safe string functions
165 AC_CHECK_LIB(c, strlcpy,
166 AC_DEFINE(HAVE_STRLCPY, 1,
167 [Define to 1 if you have strlcpy().]))
169 AC_CHECK_LIB(c, strlcat,
170 AC_DEFINE(HAVE_STRLCAT, 1,
171 [Define to 1 if you have strlcat().]))
173 # Some OSes (Solaris) need sys/sockio.h for SIOCGIFADDR
174 AC_CHECK_HEADERS(sys/sockio.h)
176 # Some OSes (Solaris) need sys/filio.h for FIONBIO
177 AC_CHECK_HEADERS(sys/filio.h)
179 AC_CONFIG_FILES(Makefile)