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 m4_pattern_allow([^AM_DEFAULT_VERBOSITY$])
44 AC_ARG_ENABLE([silent-rules],
45 [ --enable-silent-rules less verbose build output (undo: 'make V=1')
46 --disable-silent-rules verbose build output (undo: 'make V=0')])
47 case $enable_silent_rules in
48 no) AM_DEFAULT_VERBOSITY=1;;
49 *) AM_DEFAULT_VERBOSITY=0;;
51 AC_SUBST([AM_DEFAULT_VERBOSITY])
53 # Let user disable debugging symbols so we create smaller binaries.
54 AC_MSG_CHECKING(if we want debug code)
55 AC_ARG_ENABLE(debug, AS_HELP_STRING([--disable-debug],
56 [turn off debugging code and asserts]),
57 [if test "x$enableval" = "xno" ; then
58 CFLAGS="$CFLAGS -DNDEBUG -g0"
60 elif test "x$enableval" = "xyes" ; then
63 CFLAGS="$CFLAGS -g$enableval"
64 AC_MSG_RESULT(sure ($enableval))
66 [AC_MSG_RESULT(sure)])
68 # Augment CFLAGS for fun.
69 echo "int main(void){return 1;}" > conftest.$ac_ext
71 AC_MSG_CHECKING(if your C compiler wants a hit off the pipe)
73 CFLAGS="-pipe $CFLAGS"
74 if (eval $ac_link) 2>/dev/null; then
75 AC_MSG_RESULT(sure does)
81 AC_MSG_CHECKING(if your C compiler has a link-time optimizer)
82 if test x$GCC = xyes; then
84 CFLAGS="-flto $CFLAGS"
85 if (eval $ac_link) 2>/dev/null; then
86 AC_MSG_RESULT(sure does)
92 AC_MSG_RESULT(skipped)
95 AC_ARG_ENABLE(mad-warnings, AS_HELP_STRING([--enable-mad-warnings],
96 [turn on lots of compile-time warnings, this needs GCC and is only
97 really useful for development]),
98 [if test "x$enableval" = "xyes" ; then
99 AC_MSG_CHECKING(if your C compiler throws mad warnings)
100 save_cflags="$CFLAGS"
101 CFLAGS="$CFLAGS -fdiagnostics-show-option \
107 -Wbad-function-cast \
113 -Wcoverage-mismatch \
114 -Wdeclaration-after-statement \
115 -Wdisabled-optimization \
121 -Wformat-nonliteral \
124 -Wignored-qualifiers \
126 -Wimplicit-function-declaration \
135 -Wmissing-declarations \
136 -Wmissing-field-initializers \
137 -Wmissing-format-attribute \
138 -Wmissing-include-dirs \
140 -Wmissing-parameter-type \
141 -Wmissing-prototypes \
144 -Wold-style-declaration \
145 -Wold-style-definition \
147 -Wpacked-bitfield-compat \
156 -Wstrict-aliasing -fstrict-aliasing \
157 -Wstrict-overflow=5 -fstrict-overflow \
158 -Wstrict-prototypes \
168 -Wunsafe-loop-optimizations \
177 -Wvolatile-register-var \
181 # the above are valid for gcc version 4.4.3
192 #-Wtraditional-conversion
195 if (eval $ac_link) 2>/dev/null; then
196 AC_MSG_RESULT(sure does)
199 CFLAGS="$save_cflags"
203 rm -f conftest.$ac_objext conftest.$ac_ext
208 AC_CHECK_LIB(z, deflate,, [
212 I can't link to zlib. You really can't have a modern
213 operating system without zlib.
215 If you are using a package-based operating system (like
216 something with RPMs), see if there is a zlib-devel package
217 that you can install, to provide the zlib headers and
222 AC_MSG_ERROR([can't find usable zlib])])
227 # Must do at least socket and nsl before checking for libpcap.
228 AC_SEARCH_LIBS(gethostbyname, [nsl], [],
229 [AC_MSG_ERROR([gethostbyname() not found])])
230 AC_SEARCH_LIBS(socket, [socket], [],
231 [AC_MSG_ERROR([socket() not found])])
232 AC_SEARCH_LIBS(inet_aton, [resolv], [],
233 [AC_MSG_ERROR([inet_aton() not found])])
235 # Solaris need sys/filio.h for FIONBIO
236 AC_CHECK_HEADERS(sys/filio.h)
238 # GNU/kfreebsd needs net/if_ether.h for ETH_P_IPV6
239 AC_CHECK_HEADERS(net/if_ether.h)
241 # This is the modern way. Older systems use the ioctl method.
242 AC_CHECK_HEADERS(ifaddrs.h)
244 # Some OSes (Solaris) need sys/sockio.h for SIOCGIFADDR
245 AC_CHECK_HEADERS(sys/sockio.h)
248 AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
249 [prefix to libpcap installation]),
250 [if test "$withval" = yes ; then
251 AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
253 if test "$withval" != no ; then
257 if test -n "$PCAP_HOME" ; then
258 LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
259 CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
260 CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
262 CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
265 AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
267 if test -z "$PCAP_BROKEN" ; then
268 AC_CHECK_HEADERS(pcap.h,,
269 [# Couldn't find headers, try include/pcap
270 CPPFLAGS="$CPPFLAGS2"
271 AC_MSG_NOTICE([checking in include/pcap])
272 unset ac_cv_header_pcap_h
273 AC_CHECK_HEADERS(pcap.h,
274 AC_MSG_RESULT([I hate you.]),
278 if test -n "$PCAP_BROKEN" ; then
282 darkstat absolutely requires libpcap to be installed. If
283 it's installed into a prefix that isn't being picked up by
284 configure, for example /usr/local, re-run configure and add
285 --with-pcap=/usr/local
287 If you are using a package-based operating system (like
288 something with RPMs), see if there is a pcap-devel or
289 libpcap-devel package that you can install, to provide the
290 pcap headers and libraries.
292 Failing all of the above, go to http://www.tcpdump.org/ and
293 download the source distribution of libpcap and build it
298 AC_MSG_ERROR([can't find usable libpcap])
302 # Check for BSD routines.
303 AC_CHECK_FUNC(setproctitle,
304 AC_DEFINE(HAVE_REAL_SETPROCTITLE, 1,
305 [Define to 1 if your C lib has setproctitle().]))
306 AC_CHECK_FUNC(strlcpy,
307 AC_DEFINE(HAVE_REAL_STRLCPY, 1,
308 [Define to 1 if your C lib has strlcpy().]))
309 AC_CHECK_FUNC(strlcat,
310 AC_DEFINE(HAVE_REAL_STRLCAT, 1,
311 [Define to 1 if your C lib has strlcat().]))
313 # We might find these in libbsd.
314 AC_SEARCH_LIBS(setproctitle, [bsd],
315 AC_DEFINE(HAVE_SETPROCTITLE, 1,
316 [Define to 1 if you have setproctitle().]))
317 AC_SEARCH_LIBS(strlcpy, [bsd],
318 AC_DEFINE(HAVE_STRLCPY, 1,
319 [Define to 1 if you have strlcpy().]))
320 AC_SEARCH_LIBS(strlcat, [bsd],
321 AC_DEFINE(HAVE_STRLCAT, 1,
322 [Define to 1 if you have strlcat().]))
325 AC_CONFIG_FILES([Makefile darkstat.8])