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 # Let user disable debugging symbols so we create smaller binaries.
44 AC_MSG_CHECKING(if we want debug code)
45 AC_ARG_ENABLE(debug, AS_HELP_STRING([--disable-debug],
46 [turn off debugging code and asserts]),
47 [if test "x$enableval" = "xno" ; then
48 CFLAGS="$CFLAGS -DNDEBUG -g0"
50 elif test "x$enableval" = "xyes" ; then
53 CFLAGS="$CFLAGS -g$enableval"
54 AC_MSG_RESULT(sure ($enableval))
56 [AC_MSG_RESULT(sure)])
58 # Augment CFLAGS for fun.
59 echo "int main(void){return 1;}" > conftest.$ac_ext
61 AC_MSG_CHECKING(if your C compiler wants a hit off the pipe)
63 CFLAGS="-pipe $CFLAGS"
64 if (eval $ac_link) 2>/dev/null; then
65 AC_MSG_RESULT(sure does)
71 AC_ARG_ENABLE(mad-warnings, AS_HELP_STRING([--enable-mad-warnings],
72 [turn on lots of compile-time warnings, this needs GCC and is only
73 really useful for development]),
74 [if test "x$enableval" = "xyes" ; then
75 AC_MSG_CHECKING(if your C compiler throws mad warnings)
77 CFLAGS="$CFLAGS -fdiagnostics-show-option \
90 -Wdeclaration-after-statement \
91 -Wdisabled-optimization \
100 -Wignored-qualifiers \
102 -Wimplicit-function-declaration \
111 -Wmissing-declarations \
112 -Wmissing-field-initializers \
113 -Wmissing-format-attribute \
114 -Wmissing-include-dirs \
116 -Wmissing-parameter-type \
117 -Wmissing-prototypes \
120 -Wold-style-declaration \
121 -Wold-style-definition \
123 -Wpacked-bitfield-compat \
132 -Wstrict-aliasing -fstrict-aliasing \
133 -Wstrict-overflow=5 -fstrict-overflow \
134 -Wstrict-prototypes \
144 -Wunsafe-loop-optimizations \
153 -Wvolatile-register-var \
157 # the above are valid for gcc version 4.4.3
168 #-Wtraditional-conversion
171 if (eval $ac_link) 2>/dev/null; then
172 AC_MSG_RESULT(sure does)
175 CFLAGS="$save_cflags"
179 rm -f conftest.$ac_objext conftest.$ac_ext
184 AC_CHECK_LIB(z, deflate,, [
188 I can't link to zlib. You really can't have a modern
189 operating system without zlib.
191 If you are using a package-based operating system (like
192 something with RPMs), see if there is a zlib-devel package
193 that you can install, to provide the zlib headers and
198 AC_MSG_ERROR([can't find usable zlib])])
203 # Must do at least socket and nsl before checking for libpcap.
204 AC_CHECK_LIB(nsl, gethostbyname)
205 AC_CHECK_LIB(socket, socket)
206 AC_CHECK_LIB(resolv, inet_aton)
211 AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
212 [prefix to libpcap installation]),
213 [if test "$withval" = yes ; then
214 AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
216 if test "$withval" != no ; then
220 if test -n "$PCAP_HOME" ; then
221 LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
222 CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
223 CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
225 CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
228 AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
230 if test -z "$PCAP_BROKEN" ; then
231 AC_CHECK_HEADERS(pcap.h,,
232 [# Couldn't find headers, try include/pcap
233 CPPFLAGS="$CPPFLAGS2"
234 AC_MSG_NOTICE([checking in include/pcap])
235 unset ac_cv_header_pcap_h
236 AC_CHECK_HEADERS(pcap.h,
237 AC_MSG_RESULT([I hate you.]),
241 if test -n "$PCAP_BROKEN" ; then
245 darkstat absolutely requires libpcap to be installed. If
246 it's installed into a prefix that isn't being picked up by
247 configure, for example /usr/local, re-run configure and add
248 --with-pcap=/usr/local
250 If you are using a package-based operating system (like
251 something with RPMs), see if there is a pcap-devel or
252 libpcap-devel package that you can install, to provide the
253 pcap headers and libraries.
255 Failing all of the above, go to http://www.tcpdump.org/ and
256 download the source distribution of libpcap and build it
261 AC_MSG_ERROR([can't find usable libpcap])
266 # A real OS will have setproctitle()
267 AC_CHECK_LIB(c, setproctitle,
268 AC_DEFINE(HAVE_SETPROCTITLE, 1,
269 [Define to 1 if you have setproctitle().]))
271 # A real OS will have safe string functions
272 AC_SEARCH_LIBS(strlcpy, [bsd],
273 AC_DEFINE(HAVE_STRLCPY, 1,
274 [Define to 1 if you have strlcpy().]))
276 AC_SEARCH_LIBS(strlcat, [bsd],
277 AC_DEFINE(HAVE_STRLCAT, 1,
278 [Define to 1 if you have strlcat().]))
280 AC_SEARCH_LIBS(strtonum, [bsd],
281 AC_DEFINE(HAVE_STRTONUM, 1,
282 [Define to 1 if you have strtonum(3).]))
284 # Some OSes (Solaris) need sys/sockio.h for SIOCGIFADDR
285 AC_CHECK_HEADERS(sys/sockio.h)
287 # Some OSes (Solaris) need sys/filio.h for FIONBIO
288 AC_CHECK_HEADERS(sys/filio.h)
290 # GNU/kfreebsd needs net/if_ether.h for ETH_P_IPV6
291 AC_CHECK_HEADERS(net/if_ether.h)
293 AC_CONFIG_FILES([Makefile darkstat.8])