1 AC_INIT(darkstat, 3.0.0-git, , , http://unix4lyfe.org/darkstat/)
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_SEARCH_LIBS(gethostbyname, [nsl], [],
205 [AC_MSG_ERROR([gethostbyname() not found])])
206 AC_SEARCH_LIBS(socket, [socket], [],
207 [AC_MSG_ERROR([socket() not found])])
208 AC_SEARCH_LIBS(inet_aton, [resolv], [],
209 [AC_MSG_ERROR([inet_aton() not found])])
211 # Solaris need sys/filio.h for FIONBIO
212 AC_CHECK_HEADERS(sys/filio.h)
214 # GNU/kfreebsd needs net/if_ether.h for ETH_P_IPV6
215 AC_CHECK_HEADERS(net/if_ether.h)
220 AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
221 [prefix to libpcap installation]),
222 [if test "$withval" = yes ; then
223 AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
225 if test "$withval" != no ; then
229 if test -n "$PCAP_HOME" ; then
230 LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
231 CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
232 CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
234 CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
237 AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
239 if test -z "$PCAP_BROKEN" ; then
240 AC_CHECK_HEADERS(pcap.h,,
241 [# Couldn't find headers, try include/pcap
242 CPPFLAGS="$CPPFLAGS2"
243 AC_MSG_NOTICE([checking in include/pcap])
244 unset ac_cv_header_pcap_h
245 AC_CHECK_HEADERS(pcap.h,
246 AC_MSG_RESULT([I hate you.]),
250 if test -n "$PCAP_BROKEN" ; then
254 darkstat absolutely requires libpcap to be installed. If
255 it's installed into a prefix that isn't being picked up by
256 configure, for example /usr/local, re-run configure and add
257 --with-pcap=/usr/local
259 If you are using a package-based operating system (like
260 something with RPMs), see if there is a pcap-devel or
261 libpcap-devel package that you can install, to provide the
262 pcap headers and libraries.
264 Failing all of the above, go to http://www.tcpdump.org/ and
265 download the source distribution of libpcap and build it
270 AC_MSG_ERROR([can't find usable libpcap])
275 # A real OS will have setproctitle()
276 AC_SEARCH_LIBS(setproctitle, [bsd],
277 AC_DEFINE(HAVE_SETPROCTITLE, 1,
278 [Define to 1 if you have setproctitle().]))
280 # A real OS will have safe string functions
281 AC_SEARCH_LIBS(strlcpy, [bsd],
282 AC_DEFINE(HAVE_STRLCPY, 1,
283 [Define to 1 if you have strlcpy().]))
285 AC_SEARCH_LIBS(strlcat, [bsd],
286 AC_DEFINE(HAVE_STRLCAT, 1,
287 [Define to 1 if you have strlcat().]))
290 AC_CONFIG_FILES([Makefile darkstat.8])