1 # Need at least 2.64 for PACKAGE_URL
3 AC_INIT(darkstat, 3.0.717, , , http://unix4lyfe.org/darkstat/)
4 AC_CONFIG_SRCDIR([darkstat.c])
5 AC_CONFIG_HEADER([config.h])
7 RULE="------------------------------------------------------------"
9 # Let user specify CHROOT_DIR, or else autodetect it, or else die.
10 AC_ARG_WITH(chroot-dir, AS_HELP_STRING([--with-chroot-dir],
11 [specify the chroot directory (default: /var/empty)]),
12 [if test "x$withval" = "xyes"; then
13 AC_MSG_ERROR([please specify --with-chroot-dir=/path/to/darkstat/chroot])
16 [# Find an "empty" directory to serve as the chroot.
18 AC_MSG_CHECKING([for $_chd])
19 if test -d $_chd ; then
20 AC_MSG_RESULT(found it)
22 AC_MSG_RESULT(not there)
24 AC_MSG_CHECKING([for $_chd])
25 if test -d $_chd ; then
26 AC_MSG_RESULT(found it)
28 AC_MSG_RESULT(not there either)
29 AC_MSG_ERROR([please specify --with-chroot-dir=/path/to/darkstat/chroot])
32 AC_DEFINE_UNQUOTED(CHROOT_DIR, "$_chd", [Default chroot directory.])
34 # Allow configure-time override of PRIVDROP_USER.
35 AC_ARG_WITH(privdrop-user, AS_HELP_STRING([--with-privdrop-user],
36 [specify which user to drop privileges to (default: nobody)]),
39 AC_DEFINE_UNQUOTED(PRIVDROP_USER, "$_pdu", [User to privdrop to.])
41 # Checks for programs.
45 m4_pattern_allow([^AM_DEFAULT_VERBOSITY$])
46 AC_ARG_ENABLE([silent-rules],
47 [ --enable-silent-rules less verbose build output (undo: 'make V=1')
48 --disable-silent-rules verbose build output (undo: 'make V=0')])
49 case $enable_silent_rules in
50 no) AM_DEFAULT_VERBOSITY=1;;
51 *) AM_DEFAULT_VERBOSITY=0;;
53 AC_SUBST([AM_DEFAULT_VERBOSITY])
55 # Let user disable debugging symbols so we create smaller binaries.
56 AC_MSG_CHECKING(if we want debug code)
57 AC_ARG_ENABLE(debug, AS_HELP_STRING([--disable-debug],
58 [turn off debugging code and asserts]),
59 [if test "x$enableval" = "xno" ; then
60 CFLAGS="$CFLAGS -DNDEBUG -g0"
62 elif test "x$enableval" = "xyes" ; then
65 CFLAGS="$CFLAGS -g$enableval"
66 AC_MSG_RESULT(sure ($enableval))
68 [AC_MSG_RESULT(sure)])
70 # Augment CFLAGS for fun.
71 echo "int main(void){return 1;}" > conftest.$ac_ext
73 AC_MSG_CHECKING(if your C compiler wants a hit off the pipe)
75 CFLAGS="-pipe $CFLAGS"
76 if (eval $ac_link) 2>/dev/null; then
77 AC_MSG_RESULT(sure does)
83 AC_MSG_CHECKING(if your C compiler has a link-time optimizer)
84 if test x$GCC = xyes; then
86 CFLAGS="-flto $CFLAGS"
87 if (eval $ac_link) 2>/dev/null; then
88 AC_MSG_RESULT(sure does)
94 AC_MSG_RESULT(skipped)
97 AC_ARG_ENABLE(warnings, AS_HELP_STRING([--enable-warnings],
98 [turn on lots of compile-time warnings,
99 these are only useful for development]),
100 [if test "x$enableval" = "xyes" ; then
101 AC_MSG_CHECKING(if your C compiler has gcc-like --extra-warnings)
102 save_cflags="$CFLAGS"
103 CFLAGS="$CFLAGS -fdiagnostics-show-option --all-warnings --extra-warnings"
104 if (eval $ac_link) 2>/dev/null; then
108 CFLAGS="$save_cflags"
111 AC_MSG_CHECKING(if your C compiler has clang-like -Weverything)
112 save_cflags="$CFLAGS"
113 CFLAGS="$CFLAGS -Weverything"
114 if (eval $ac_link) 2>/dev/null; then
118 CFLAGS="$save_cflags"
122 rm -f conftest.$ac_objext conftest.$ac_ext
127 AC_CHECK_LIB(z, deflate,, [
131 I can't link to zlib. You really can't have a modern
132 operating system without zlib.
134 If you are using a package-based operating system (like
135 something with RPMs), see if there is a zlib-devel package
136 that you can install, to provide the zlib headers and
141 AC_MSG_ERROR([can't find usable zlib])])
146 # Must do at least socket and nsl before checking for libpcap.
147 AC_SEARCH_LIBS(gethostbyname, [nsl], [],
148 [AC_MSG_ERROR([gethostbyname() not found])])
149 AC_SEARCH_LIBS(socket, [socket], [],
150 [AC_MSG_ERROR([socket() not found])])
151 AC_SEARCH_LIBS(hstrerror, [resolv], [],
152 [AC_MSG_ERROR([hstrerror() not found])])
154 # Solaris need sys/filio.h for FIONBIO
155 AC_CHECK_HEADERS(sys/filio.h)
157 # This is the modern way. Older systems use the ioctl method.
158 AC_SEARCH_LIBS(getifaddrs, [c],
159 [AC_CHECK_HEADERS(ifaddrs.h)])
163 # Some OSes (Solaris) need sys/sockio.h for SIOCGIFADDR
164 AC_CHECK_HEADERS(sys/sockio.h)
167 AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
168 [prefix to libpcap installation]),
169 [if test "$withval" = yes ; then
170 AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
172 if test "$withval" != no ; then
176 if test -n "$PCAP_HOME" ; then
177 LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
178 CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
179 CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
181 CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
184 AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
186 if test -z "$PCAP_BROKEN" ; then
187 AC_CHECK_HEADERS(pcap.h,,
188 [# Couldn't find headers, try include/pcap
189 CPPFLAGS="$CPPFLAGS2"
190 AC_MSG_NOTICE([checking in include/pcap])
191 unset ac_cv_header_pcap_h
192 AC_CHECK_HEADERS(pcap.h,
193 AC_MSG_RESULT([I hate you.]),
197 if test -n "$PCAP_BROKEN" ; then
201 darkstat absolutely requires libpcap to be installed. On Debian
202 systems, apt-get install libpcap-dev. On RPM systems like RedHat, try
203 installing the libpcap-devel package.
205 If libpcap is installed into a prefix that isn't being picked up by
206 configure, for example /usr/local, re-run configure and add
207 --with-pcap=/usr/local
209 Failing all of the above, go to http://www.tcpdump.org/ and download the
210 source distribution of libpcap and build it yourself.
214 AC_MSG_ERROR([can't find usable libpcap])
217 # If not in libc, we might find these in libbsd.
218 AC_SEARCH_LIBS(setproctitle, [bsd],
219 AC_DEFINE(HAVE_SETPROCTITLE, 1,
220 [Define to 1 if you have setproctitle().]))
221 AC_SEARCH_LIBS(strlcpy, [bsd],
222 AC_DEFINE(HAVE_STRLCPY, 1,
223 [Define to 1 if you have strlcpy().]))
224 AC_SEARCH_LIBS(strlcat, [bsd],
225 AC_DEFINE(HAVE_STRLCAT, 1,
226 [Define to 1 if you have strlcat().]))
228 AC_CHECK_HEADERS(bsd/string.h)
229 AC_CHECK_HEADERS(bsd/unistd.h)
231 AC_SEARCH_LIBS(clock_gettime, rt)
233 AC_CONFIG_FILES([Makefile darkstat.8])