1 # Need at least 2.64 for PACKAGE_URL
3 AC_INIT(darkstat, 3.0.718, , , http://unix4lyfe.org/darkstat/)
4 AC_CONFIG_SRCDIR([darkstat.c])
5 AC_CONFIG_HEADER([config.h])
7 RULE="------------------------------------------------------------"
9 # Allow configure-time override of PRIVDROP_USER.
10 AC_ARG_WITH(privdrop-user, AS_HELP_STRING([--with-privdrop-user],
11 [specify which user to drop privileges to (default: nobody)]),
14 AC_DEFINE_UNQUOTED(PRIVDROP_USER, "$_pdu", [User to privdrop to.])
16 # Checks for programs.
20 m4_pattern_allow([^AM_DEFAULT_VERBOSITY$])
21 AC_ARG_ENABLE([silent-rules],
22 [ --enable-silent-rules less verbose build output (undo: 'make V=1')
23 --disable-silent-rules verbose build output (undo: 'make V=0')])
24 case $enable_silent_rules in
25 no) AM_DEFAULT_VERBOSITY=1;;
26 *) AM_DEFAULT_VERBOSITY=0;;
28 AC_SUBST([AM_DEFAULT_VERBOSITY])
30 # Let user disable debugging symbols so we create smaller binaries.
31 AC_MSG_CHECKING(if we want debug code)
32 AC_ARG_ENABLE(debug, AS_HELP_STRING([--disable-debug],
33 [turn off debugging code and asserts]),
34 [if test "x$enableval" = "xno" ; then
35 CFLAGS="$CFLAGS -DNDEBUG -g0"
37 elif test "x$enableval" = "xyes" ; then
40 CFLAGS="$CFLAGS -g$enableval"
41 AC_MSG_RESULT(sure ($enableval))
43 [AC_MSG_RESULT(sure)])
45 # Augment CFLAGS for fun.
46 echo "int main(void){return 1;}" > conftest.$ac_ext
48 AC_MSG_CHECKING(if your C compiler wants a hit off the pipe)
50 CFLAGS="-pipe $CFLAGS"
51 if (eval $ac_link) 2>/dev/null; then
52 AC_MSG_RESULT(sure does)
58 AC_MSG_CHECKING(if your C compiler has a link-time optimizer)
59 if test x$GCC = xyes; then
61 CFLAGS="-flto $CFLAGS"
62 if (eval $ac_link) 2>/dev/null; then
63 AC_MSG_RESULT(sure does)
69 AC_MSG_RESULT(skipped)
72 AC_ARG_ENABLE(warnings, AS_HELP_STRING([--enable-warnings],
73 [turn on lots of compile-time warnings,
74 these are only useful for development]),
75 [if test "x$enableval" = "xyes" ; then
76 AC_MSG_CHECKING(if your C compiler has gcc-like --extra-warnings)
78 CFLAGS="$CFLAGS -fdiagnostics-show-option --all-warnings --extra-warnings"
79 if (eval $ac_link) 2>/dev/null; then
86 AC_MSG_CHECKING(if your C compiler has clang-like -Weverything)
88 CFLAGS="$CFLAGS -Weverything"
89 if (eval $ac_link) 2>/dev/null; then
97 rm -f conftest.$ac_objext conftest.$ac_ext
102 AC_CHECK_LIB(z, deflate,, [
106 I can't link to zlib. You really can't have a modern
107 operating system without zlib.
109 If you are using a package-based operating system (like
110 something with RPMs), see if there is a zlib-devel package
111 that you can install, to provide the zlib headers and
116 AC_MSG_ERROR([can't find usable zlib])])
121 # Must do at least socket and nsl before checking for libpcap.
122 AC_SEARCH_LIBS(gethostbyname, [nsl], [],
123 [AC_MSG_ERROR([gethostbyname() not found])])
124 AC_SEARCH_LIBS(socket, [socket], [],
125 [AC_MSG_ERROR([socket() not found])])
126 AC_SEARCH_LIBS(hstrerror, [resolv], [],
127 [AC_MSG_ERROR([hstrerror() not found])])
129 # Solaris need sys/filio.h for FIONBIO
130 AC_CHECK_HEADERS(sys/filio.h)
132 # This is the modern way. Older systems use the ioctl method.
133 AC_SEARCH_LIBS(getifaddrs, [c],
134 [AC_CHECK_HEADERS(ifaddrs.h)])
138 # Some OSes (Solaris) need sys/sockio.h for SIOCGIFADDR
139 AC_CHECK_HEADERS(sys/sockio.h)
142 AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
143 [prefix to libpcap installation]),
144 [if test "$withval" = yes ; then
145 AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
147 if test "$withval" != no ; then
151 if test -n "$PCAP_HOME" ; then
152 LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
153 CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
154 CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
156 CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
159 AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
161 if test -z "$PCAP_BROKEN" ; then
162 AC_CHECK_HEADERS(pcap.h,,
163 [# Couldn't find headers, try include/pcap
164 CPPFLAGS="$CPPFLAGS2"
165 AC_MSG_NOTICE([checking in include/pcap])
166 unset ac_cv_header_pcap_h
167 AC_CHECK_HEADERS(pcap.h,
168 AC_MSG_RESULT([I hate you.]),
172 if test -n "$PCAP_BROKEN" ; then
176 darkstat absolutely requires libpcap to be installed. On Debian
177 systems, apt-get install libpcap-dev. On RPM systems like RedHat, try
178 installing the libpcap-devel package.
180 If libpcap is installed into a prefix that isn't being picked up by
181 configure, for example /usr/local, re-run configure and add
182 --with-pcap=/usr/local
184 Failing all of the above, go to http://www.tcpdump.org/ and download the
185 source distribution of libpcap and build it yourself.
189 AC_MSG_ERROR([can't find usable libpcap])
192 # If not in libc, we might find these in libbsd.
193 AC_SEARCH_LIBS(setproctitle, [bsd],
194 AC_DEFINE(HAVE_SETPROCTITLE, 1,
195 [Define to 1 if you have setproctitle().]))
196 AC_SEARCH_LIBS(strlcpy, [bsd],
197 AC_DEFINE(HAVE_STRLCPY, 1,
198 [Define to 1 if you have strlcpy().]))
199 AC_SEARCH_LIBS(strlcat, [bsd],
200 AC_DEFINE(HAVE_STRLCAT, 1,
201 [Define to 1 if you have strlcat().]))
203 AC_CHECK_HEADERS(bsd/string.h)
204 AC_CHECK_HEADERS(bsd/unistd.h)
206 AC_SEARCH_LIBS(clock_gettime, rt)
208 AC_CONFIG_FILES([Makefile darkstat.8])