1 AC_INIT(darkstat, 3.0.715, , , 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, these are GCC-specific and only
97 really useful for development]),
98 [if test "x$enableval" = "xyes" ; then
99 AC_MSG_CHECKING(if your C compiler can emit certain warnings)
100 save_cflags="$CFLAGS"
101 CFLAGS="$CFLAGS -fdiagnostics-show-option \
105 -Wbad-function-cast \
110 -Wdeclaration-after-statement \
111 -Wdisabled-optimization \
116 -Wformat-nonliteral \
120 -Wimplicit-function-declaration \
127 -Wmissing-declarations \
128 -Wmissing-field-initializers \
129 -Wmissing-format-attribute \
130 -Wmissing-include-dirs \
132 -Wmissing-prototypes \
135 -Wold-style-definition \
145 -Wstrict-aliasing -fstrict-aliasing \
146 -Wstrict-overflow=5 -fstrict-overflow \
147 -Wstrict-prototypes \
155 -Wunsafe-loop-optimizations \
163 -Wvolatile-register-var \
166 # The above are valid for gcc version 4.2.1.
168 if (eval $ac_link) 2>/dev/null; then
171 AC_MSG_CHECKING(if your C compiler can emit certain other warnings)
172 save_cflags="$CFLAGS"
176 -Wcoverage-mismatch \
178 -Wignored-qualifiers \
180 -Wmissing-parameter-type \
181 -Wold-style-declaration \
182 -Wpacked-bitfield-compat \
187 # The above are valid for gcc version 4.4.3.
188 # We skip the following entirely:
200 #-Wtraditional-conversion
203 if (eval $ac_link) 2>/dev/null; then
207 CFLAGS="$save_cflags"
212 CFLAGS="$save_cflags"
216 rm -f conftest.$ac_objext conftest.$ac_ext
221 AC_CHECK_LIB(z, deflate,, [
225 I can't link to zlib. You really can't have a modern
226 operating system without zlib.
228 If you are using a package-based operating system (like
229 something with RPMs), see if there is a zlib-devel package
230 that you can install, to provide the zlib headers and
235 AC_MSG_ERROR([can't find usable zlib])])
240 # Must do at least socket and nsl before checking for libpcap.
241 AC_SEARCH_LIBS(gethostbyname, [nsl], [],
242 [AC_MSG_ERROR([gethostbyname() not found])])
243 AC_SEARCH_LIBS(socket, [socket], [],
244 [AC_MSG_ERROR([socket() not found])])
245 AC_SEARCH_LIBS(hstrerror, [resolv], [],
246 [AC_MSG_ERROR([hstrerror() not found])])
248 # Solaris need sys/filio.h for FIONBIO
249 AC_CHECK_HEADERS(sys/filio.h)
251 # Debian GNU/kFreeBSD needs net/if_ether.h for ETH_P_IPV6
252 AC_CHECK_HEADERS(net/if_ether.h)
254 # This is the modern way. Older systems use the ioctl method.
255 AC_CHECK_HEADERS(ifaddrs.h)
257 # Some OSes (Solaris) need sys/sockio.h for SIOCGIFADDR
258 AC_CHECK_HEADERS(sys/sockio.h)
261 AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
262 [prefix to libpcap installation]),
263 [if test "$withval" = yes ; then
264 AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
266 if test "$withval" != no ; then
270 if test -n "$PCAP_HOME" ; then
271 LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
272 CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
273 CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
275 CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
278 AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
280 if test -z "$PCAP_BROKEN" ; then
281 AC_CHECK_HEADERS(pcap.h,,
282 [# Couldn't find headers, try include/pcap
283 CPPFLAGS="$CPPFLAGS2"
284 AC_MSG_NOTICE([checking in include/pcap])
285 unset ac_cv_header_pcap_h
286 AC_CHECK_HEADERS(pcap.h,
287 AC_MSG_RESULT([I hate you.]),
291 if test -n "$PCAP_BROKEN" ; then
295 darkstat absolutely requires libpcap to be installed. If
296 it's installed into a prefix that isn't being picked up by
297 configure, for example /usr/local, re-run configure and add
298 --with-pcap=/usr/local
300 If you are using a package-based operating system (like
301 something with RPMs), see if there is a pcap-devel or
302 libpcap-devel package that you can install, to provide the
303 pcap headers and libraries.
305 Failing all of the above, go to http://www.tcpdump.org/ and
306 download the source distribution of libpcap and build it
311 AC_MSG_ERROR([can't find usable libpcap])
314 # If not in libc, we might find these in libbsd.
315 AC_SEARCH_LIBS(setproctitle, [bsd],
316 AC_DEFINE(HAVE_SETPROCTITLE, 1,
317 [Define to 1 if you have setproctitle().]))
318 AC_SEARCH_LIBS(strlcpy, [bsd],
319 AC_DEFINE(HAVE_STRLCPY, 1,
320 [Define to 1 if you have strlcpy().]))
321 AC_SEARCH_LIBS(strlcat, [bsd],
322 AC_DEFINE(HAVE_STRLCAT, 1,
323 [Define to 1 if you have strlcat().]))
325 AC_CHECK_HEADERS(bsd/string.h)
326 AC_CHECK_HEADERS(bsd/unistd.h)
328 AC_CONFIG_FILES([Makefile darkstat.8])