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_MSG_CHECKING(if your C compiler has a link-time optimizer)
72 if test x$GCC = xyes; then
74 CFLAGS="-flto $CFLAGS"
75 if (eval $ac_link) 2>/dev/null; then
76 AC_MSG_RESULT(sure does)
82 AC_MSG_RESULT(skipped)
85 AC_ARG_ENABLE(mad-warnings, AS_HELP_STRING([--enable-mad-warnings],
86 [turn on lots of compile-time warnings, this needs GCC and is only
87 really useful for development]),
88 [if test "x$enableval" = "xyes" ; then
89 AC_MSG_CHECKING(if your C compiler throws mad warnings)
91 CFLAGS="$CFLAGS -fdiagnostics-show-option \
103 -Wcoverage-mismatch \
104 -Wdeclaration-after-statement \
105 -Wdisabled-optimization \
111 -Wformat-nonliteral \
114 -Wignored-qualifiers \
116 -Wimplicit-function-declaration \
125 -Wmissing-declarations \
126 -Wmissing-field-initializers \
127 -Wmissing-format-attribute \
128 -Wmissing-include-dirs \
130 -Wmissing-parameter-type \
131 -Wmissing-prototypes \
134 -Wold-style-declaration \
135 -Wold-style-definition \
137 -Wpacked-bitfield-compat \
146 -Wstrict-aliasing -fstrict-aliasing \
147 -Wstrict-overflow=5 -fstrict-overflow \
148 -Wstrict-prototypes \
158 -Wunsafe-loop-optimizations \
167 -Wvolatile-register-var \
171 # the above are valid for gcc version 4.4.3
182 #-Wtraditional-conversion
185 if (eval $ac_link) 2>/dev/null; then
186 AC_MSG_RESULT(sure does)
189 CFLAGS="$save_cflags"
193 rm -f conftest.$ac_objext conftest.$ac_ext
198 AC_CHECK_LIB(z, deflate,, [
202 I can't link to zlib. You really can't have a modern
203 operating system without zlib.
205 If you are using a package-based operating system (like
206 something with RPMs), see if there is a zlib-devel package
207 that you can install, to provide the zlib headers and
212 AC_MSG_ERROR([can't find usable zlib])])
217 # Must do at least socket and nsl before checking for libpcap.
218 AC_SEARCH_LIBS(gethostbyname, [nsl], [],
219 [AC_MSG_ERROR([gethostbyname() not found])])
220 AC_SEARCH_LIBS(socket, [socket], [],
221 [AC_MSG_ERROR([socket() not found])])
222 AC_SEARCH_LIBS(inet_aton, [resolv], [],
223 [AC_MSG_ERROR([inet_aton() not found])])
225 # Solaris need sys/filio.h for FIONBIO
226 AC_CHECK_HEADERS(sys/filio.h)
228 # GNU/kfreebsd needs net/if_ether.h for ETH_P_IPV6
229 AC_CHECK_HEADERS(net/if_ether.h)
234 AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
235 [prefix to libpcap installation]),
236 [if test "$withval" = yes ; then
237 AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
239 if test "$withval" != no ; then
243 if test -n "$PCAP_HOME" ; then
244 LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
245 CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
246 CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
248 CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
251 AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
253 if test -z "$PCAP_BROKEN" ; then
254 AC_CHECK_HEADERS(pcap.h,,
255 [# Couldn't find headers, try include/pcap
256 CPPFLAGS="$CPPFLAGS2"
257 AC_MSG_NOTICE([checking in include/pcap])
258 unset ac_cv_header_pcap_h
259 AC_CHECK_HEADERS(pcap.h,
260 AC_MSG_RESULT([I hate you.]),
264 if test -n "$PCAP_BROKEN" ; then
268 darkstat absolutely requires libpcap to be installed. If
269 it's installed into a prefix that isn't being picked up by
270 configure, for example /usr/local, re-run configure and add
271 --with-pcap=/usr/local
273 If you are using a package-based operating system (like
274 something with RPMs), see if there is a pcap-devel or
275 libpcap-devel package that you can install, to provide the
276 pcap headers and libraries.
278 Failing all of the above, go to http://www.tcpdump.org/ and
279 download the source distribution of libpcap and build it
284 AC_MSG_ERROR([can't find usable libpcap])
289 # A real OS will have setproctitle()
290 AC_SEARCH_LIBS(setproctitle, [bsd],
291 AC_DEFINE(HAVE_SETPROCTITLE, 1,
292 [Define to 1 if you have setproctitle().]))
294 # A real OS will have safe string functions
295 AC_SEARCH_LIBS(strlcpy, [bsd],
296 AC_DEFINE(HAVE_STRLCPY, 1,
297 [Define to 1 if you have strlcpy().]))
299 AC_SEARCH_LIBS(strlcat, [bsd],
300 AC_DEFINE(HAVE_STRLCAT, 1,
301 [Define to 1 if you have strlcat().]))
304 AC_CONFIG_FILES([Makefile darkstat.8])