1 # Need at least 2.64 for PACKAGE_URL
3 AC_INIT(darkstat, 3.0.719, , , https://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 # Compiler's language features.
23 m4_pattern_allow([^AM_DEFAULT_VERBOSITY$])
24 AC_ARG_ENABLE([silent-rules],
25 [ --enable-silent-rules less verbose build output (undo: 'make V=1')
26 --disable-silent-rules verbose build output (undo: 'make V=0')])
27 case $enable_silent_rules in
28 no) AM_DEFAULT_VERBOSITY=1;;
29 *) AM_DEFAULT_VERBOSITY=0;;
31 AC_SUBST([AM_DEFAULT_VERBOSITY])
33 # Let user disable debugging symbols so we create smaller binaries.
34 AC_MSG_CHECKING(if we want debug code)
35 AC_ARG_ENABLE(debug, AS_HELP_STRING([--disable-debug],
36 [turn off debugging code and asserts]),
37 [if test "x$enableval" = "xno" ; then
38 CFLAGS="$CFLAGS -DNDEBUG -g0"
40 elif test "x$enableval" = "xyes" ; then
43 CFLAGS="$CFLAGS -g$enableval"
44 AC_MSG_RESULT(sure ($enableval))
46 [AC_MSG_RESULT(sure)])
48 # Augment CFLAGS for fun.
49 echo "int main(void){return 1;}" > conftest.$ac_ext
51 AC_MSG_CHECKING(if your C compiler wants a hit off the pipe)
53 CFLAGS="-pipe $CFLAGS"
54 if (eval $ac_link) 2>/dev/null; then
55 AC_MSG_RESULT(sure does)
61 AC_MSG_CHECKING(if your C compiler has a link-time optimizer)
62 if test x$GCC = xyes; then
64 CFLAGS="-flto $CFLAGS"
65 if (eval $ac_link) 2>/dev/null; then
66 AC_MSG_RESULT(sure does)
72 AC_MSG_RESULT(skipped)
75 AC_ARG_ENABLE(warnings, AS_HELP_STRING([--enable-warnings],
76 [turn on lots of compile-time warnings,
77 these are only useful for development]),
78 [if test "x$enableval" = "xyes" ; then
79 AC_MSG_CHECKING(if your C compiler has gcc-like --extra-warnings)
81 CFLAGS="$CFLAGS -fdiagnostics-show-option --all-warnings --extra-warnings"
82 if (eval $ac_link) 2>/dev/null; then
89 AC_MSG_CHECKING(if your C compiler has clang-like -Weverything)
91 CFLAGS="$CFLAGS -Weverything"
92 if (eval $ac_link) 2>/dev/null; then
100 rm -f conftest.$ac_objext conftest.$ac_ext
105 AC_CHECK_LIB(z, deflate,, [
109 I can't link to zlib. You really can't have a modern
110 operating system without zlib.
112 On Debian or a derivative, try: sudo apt-get install zlib1g-dev
114 On an RPM system, see if there is a zlib-devel package.
118 AC_MSG_ERROR([can't find usable zlib])])
123 # Must do at least socket and nsl before checking for libpcap.
124 AC_SEARCH_LIBS(gethostbyname, [nsl], [],
125 [AC_MSG_ERROR([gethostbyname() not found])])
126 AC_SEARCH_LIBS(socket, [socket], [],
127 [AC_MSG_ERROR([socket() not found])])
128 AC_SEARCH_LIBS(hstrerror, [resolv], [],
129 [AC_MSG_ERROR([hstrerror() not found])])
131 # Solaris need sys/filio.h for FIONBIO
132 AC_CHECK_HEADERS(sys/filio.h)
134 # This is the modern way. Older systems use the ioctl method.
135 AC_SEARCH_LIBS(getifaddrs, [c],
136 [AC_CHECK_HEADERS(ifaddrs.h)])
140 # Some OSes (Solaris) need sys/sockio.h for SIOCGIFADDR
141 AC_CHECK_HEADERS(sys/sockio.h)
144 AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
145 [prefix to libpcap installation]),
146 [if test "$withval" = yes ; then
147 AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
149 if test "$withval" != no ; then
153 if test -n "$PCAP_HOME" ; then
154 LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
155 CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
156 CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
158 CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
161 AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
163 if test -z "$PCAP_BROKEN" ; then
164 AC_CHECK_HEADERS(pcap.h,,
165 [# Couldn't find headers, try include/pcap
166 CPPFLAGS="$CPPFLAGS2"
167 AC_MSG_NOTICE([checking in include/pcap])
168 unset ac_cv_header_pcap_h
169 AC_CHECK_HEADERS(pcap.h,
170 AC_MSG_RESULT([I hate you.]),
174 if test -n "$PCAP_BROKEN" ; then
178 darkstat absolutely requires libpcap to be installed. On Debian
179 systems, apt-get install libpcap-dev. On RPM systems like RedHat, try
180 installing the libpcap-devel package.
182 If libpcap is installed into a prefix that isn't being picked up by
183 configure, for example /usr/local, re-run configure and add
184 --with-pcap=/usr/local
186 Failing all of the above, go to http://www.tcpdump.org/ and download the
187 source distribution of libpcap and build it yourself.
191 AC_MSG_ERROR([can't find usable libpcap])
194 # If not in libc, we might find these in libbsd.
195 AC_SEARCH_LIBS(setproctitle, [bsd],
196 AC_DEFINE(HAVE_SETPROCTITLE, 1,
197 [Define to 1 if you have setproctitle().]))
198 AC_SEARCH_LIBS(strlcpy, [bsd],
199 AC_DEFINE(HAVE_STRLCPY, 1,
200 [Define to 1 if you have strlcpy().]))
201 AC_SEARCH_LIBS(strlcat, [bsd],
202 AC_DEFINE(HAVE_STRLCAT, 1,
203 [Define to 1 if you have strlcat().]))
205 AC_CHECK_HEADERS(bsd/string.h)
206 AC_CHECK_HEADERS(bsd/unistd.h)
208 AC_SEARCH_LIBS(clock_gettime, rt)
210 AC_CONFIG_FILES([Makefile darkstat.8])