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)]),
10 [if test "x$withval" = "xyes"; then
11 AC_MSG_ERROR([please specify --with-chroot-dir=/path/to/darkstat/chroot])
14 [# Find an "empty" directory to serve as the chroot.
16 AC_MSG_CHECKING([for $_chd])
17 if test -d $_chd ; then
18 AC_MSG_RESULT(found it)
20 AC_MSG_RESULT(not there)
22 AC_MSG_CHECKING([for $_chd])
23 if test -d $_chd ; then
24 AC_MSG_RESULT(found it)
26 AC_MSG_RESULT(not there either)
27 AC_MSG_ERROR([please specify --with-chroot-dir=/path/to/darkstat/chroot])
30 AC_DEFINE_UNQUOTED(CHROOT_DIR, "$_chd", [Default chroot directory.])
32 # Allow configure-time override of PRIVDROP_USER.
33 AC_ARG_WITH(privdrop-user, AS_HELP_STRING([--with-privdrop-user],
34 [specify which user to drop privileges to (default: nobody)]),
37 AC_DEFINE_UNQUOTED(PRIVDROP_USER, "$_pdu", [User to privdrop to.])
39 # Checks for programs.
43 # Augment CFLAGS for fun.
44 echo "int main(void){return 1;}" > conftest.$ac_ext
46 AC_MSG_CHECKING(if your C compiler wants a hit off the pipe)
48 CFLAGS="-pipe $CFLAGS"
49 if (eval $ac_link) 2>/dev/null; then
50 AC_MSG_RESULT(sure does)
56 AC_ARG_WITH(mad-warnings, AS_HELP_STRING([--with-mad-warnings],
57 [turn on lots of compile-time warnings, this needs GCC and is only
58 really useful for development]),
59 [if test "$withval" = yes ; then
60 AC_MSG_CHECKING(if your C compiler throws mad warnings)
62 CFLAGS="$CFLAGS -Wall -Wredundant-decls -Wnested-externs \
63 -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
64 -Winline -Wcast-qual -W -Wbad-function-cast -Wcast-align \
65 -Wchar-subscripts -Wshadow -Wwrite-strings \
66 -Wuninitialized -Winline"
67 if (eval $ac_link) 2>/dev/null; then
68 AC_MSG_RESULT(sure does)
75 rm -f conftest.$ac_objext conftest.$ac_ext
80 AC_CHECK_LIB(z, deflate,, [
84 I can't link to zlib. You really can't have a modern
85 operating system without zlib.
87 If you are using a package-based operating system (like
88 something with RPMs), see if there is a zlib-devel package
89 that you can install, to provide the zlib headers and
94 AC_MSG_ERROR([can't find usable zlib])])
99 # Must do at least socket and nsl before checking for libpcap.
100 AC_CHECK_LIB(nsl, gethostbyname)
101 AC_CHECK_LIB(socket, socket)
102 AC_CHECK_LIB(resolv, inet_aton)
107 AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
108 [prefix to libpcap installation]),
109 [if test "$withval" = yes ; then
110 AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
112 if test "$withval" != no ; then
116 if test -n "$PCAP_HOME" ; then
117 LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
118 CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
119 CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
121 CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
124 AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
126 if test -z "$PCAP_BROKEN" ; then
127 AC_CHECK_HEADERS(pcap.h,,
128 [# Couldn't find headers, try include/pcap
129 CPPFLAGS="$CPPFLAGS2"
130 AC_MSG_NOTICE([checking in include/pcap])
131 unset ac_cv_header_pcap_h
132 AC_CHECK_HEADERS(pcap.h,
133 AC_MSG_RESULT([I hate you.]),
137 if test -n "$PCAP_BROKEN" ; then
141 darkstat absolutely requires libpcap to be installed. If
142 it's installed into a prefix that isn't being picked up by
143 configure, for example /usr/local, re-run configure and add
144 --with-pcap=/usr/local
146 If you are using a package-based operating system (like
147 something with RPMs), see if there is a pcap-devel or
148 libpcap-devel package that you can install, to provide the
149 pcap headers and libraries.
151 Failing all of the above, go to http://www.tcpdump.org/ and
152 download the source distribution of libpcap and build it
157 AC_MSG_ERROR([can't find usable libpcap])
162 # A real OS will have setproctitle()
163 AC_CHECK_LIB(c, setproctitle,
164 AC_DEFINE(HAVE_SETPROCTITLE, 1,
165 [Define to 1 if you have setproctitle().]))
167 # A real OS will have safe string functions
168 AC_CHECK_LIB(c, strlcpy,
169 AC_DEFINE(HAVE_STRLCPY, 1,
170 [Define to 1 if you have strlcpy().]))
172 AC_CHECK_LIB(c, strlcat,
173 AC_DEFINE(HAVE_STRLCAT, 1,
174 [Define to 1 if you have strlcat().]))
176 # Some OSes (Solaris) need sys/sockio.h for SIOCGIFADDR
177 AC_CHECK_HEADERS(sys/sockio.h)
179 # Some OSes (Solaris) need sys/filio.h for FIONBIO
180 AC_CHECK_HEADERS(sys/filio.h)
182 AC_CONFIG_FILES(Makefile)