1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
|
AC_INIT(darkstat, 3.0.715, , , http://unix4lyfe.org/darkstat/)
AC_CONFIG_SRCDIR([darkstat.c])
AC_CONFIG_HEADER([config.h])
RULE="------------------------------------------------------------"
# Let user specify CHROOT_DIR, or else autodetect it, or else die.
AC_ARG_WITH(chroot-dir, AS_HELP_STRING([--with-chroot-dir],
[specify the chroot directory (default: /var/empty)]),
[if test "x$withval" = "xyes"; then
AC_MSG_ERROR([please specify --with-chroot-dir=/path/to/darkstat/chroot])
fi
_chd="$withval"],
[# Find an "empty" directory to serve as the chroot.
_chd="/var/empty"
AC_MSG_CHECKING([for $_chd])
if test -d $_chd ; then
AC_MSG_RESULT(found it)
else
AC_MSG_RESULT(not there)
_chd="/var/lib/empty"
AC_MSG_CHECKING([for $_chd])
if test -d $_chd ; then
AC_MSG_RESULT(found it)
else
AC_MSG_RESULT(not there either)
AC_MSG_ERROR([please specify --with-chroot-dir=/path/to/darkstat/chroot])
fi
fi])
AC_DEFINE_UNQUOTED(CHROOT_DIR, "$_chd", [Default chroot directory.])
# Allow configure-time override of PRIVDROP_USER.
AC_ARG_WITH(privdrop-user, AS_HELP_STRING([--with-privdrop-user],
[specify which user to drop privileges to (default: nobody)]),
[_pdu="$withval"],
[_pdu="nobody"])
AC_DEFINE_UNQUOTED(PRIVDROP_USER, "$_pdu", [User to privdrop to.])
# Checks for programs.
AC_PROG_INSTALL
AC_PROG_CC
m4_pattern_allow([^AM_DEFAULT_VERBOSITY$])
AC_ARG_ENABLE([silent-rules],
[ --enable-silent-rules less verbose build output (undo: 'make V=1')
--disable-silent-rules verbose build output (undo: 'make V=0')])
case $enable_silent_rules in
no) AM_DEFAULT_VERBOSITY=1;;
*) AM_DEFAULT_VERBOSITY=0;;
esac
AC_SUBST([AM_DEFAULT_VERBOSITY])
# Let user disable debugging symbols so we create smaller binaries.
AC_MSG_CHECKING(if we want debug code)
AC_ARG_ENABLE(debug, AS_HELP_STRING([--disable-debug],
[turn off debugging code and asserts]),
[if test "x$enableval" = "xno" ; then
CFLAGS="$CFLAGS -DNDEBUG -g0"
AC_MSG_RESULT(nope)
elif test "x$enableval" = "xyes" ; then
AC_MSG_RESULT(sure)
else
CFLAGS="$CFLAGS -g$enableval"
AC_MSG_RESULT(sure ($enableval))
fi],
[AC_MSG_RESULT(sure)])
# Augment CFLAGS for fun.
echo "int main(void){return 1;}" > conftest.$ac_ext
AC_MSG_CHECKING(if your C compiler wants a hit off the pipe)
save_cflags="$CFLAGS"
CFLAGS="-pipe $CFLAGS"
if (eval $ac_link) 2>/dev/null; then
AC_MSG_RESULT(sure does)
else
AC_MSG_RESULT(no)
CFLAGS="$save_cflags"
fi
AC_MSG_CHECKING(if your C compiler has a link-time optimizer)
if test x$GCC = xyes; then
save_cflags="$CFLAGS"
CFLAGS="-flto $CFLAGS"
if (eval $ac_link) 2>/dev/null; then
AC_MSG_RESULT(sure does)
else
AC_MSG_RESULT(no)
CFLAGS="$save_cflags"
fi
else
AC_MSG_RESULT(skipped)
fi
AC_ARG_ENABLE(mad-warnings, AS_HELP_STRING([--enable-mad-warnings],
[turn on lots of compile-time warnings, these are GCC-specific and only
really useful for development]),
[if test "x$enableval" = "xyes" ; then
AC_MSG_CHECKING(if your C compiler can emit certain warnings)
save_cflags="$CFLAGS"
CFLAGS="$CFLAGS -fdiagnostics-show-option \
-Waddress \
-Waggregate-return \
-Wall \
-Wbad-function-cast \
-Wcast-align \
-Wcast-qual \
-Wchar-subscripts \
-Wcomment \
-Wdeclaration-after-statement \
-Wdisabled-optimization \
-Wextra \
-Wfloat-equal \
-Wformat \
-Wformat=2 \
-Wformat-nonliteral \
-Wformat-security \
-Wformat-y2k \
-Wimplicit \
-Wimplicit-function-declaration \
-Wimplicit-int \
-Winit-self \
-Winline \
-Winvalid-pch \
-Wmain \
-Wmissing-braces \
-Wmissing-declarations \
-Wmissing-field-initializers \
-Wmissing-format-attribute \
-Wmissing-include-dirs \
-Wmissing-noreturn \
-Wmissing-prototypes \
-Wnested-externs \
-Wnonnull \
-Wold-style-definition \
-Wpacked \
-Wparentheses \
-Wpointer-arith \
-Wpointer-sign \
-Wredundant-decls \
-Wreturn-type \
-Wsequence-point \
-Wshadow \
-Wsign-compare \
-Wstrict-aliasing -fstrict-aliasing \
-Wstrict-overflow=5 -fstrict-overflow \
-Wstrict-prototypes \
-Wswitch \
-Wswitch-default \
-Wswitch-enum \
-Wtrigraphs \
-Wundef \
-Wuninitialized \
-Wunknown-pragmas \
-Wunsafe-loop-optimizations \
-Wunused \
-Wunused-function \
-Wunused-label \
-Wunused-parameter \
-Wunused-value \
-Wunused-variable \
-Wvariadic-macros \
-Wvolatile-register-var \
-Wwrite-strings \
"
# The above are valid for gcc version 4.2.1.
if (eval $ac_link) 2>/dev/null; then
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(if your C compiler can emit certain other warnings)
save_cflags="$CFLAGS"
CFLAGS="$CFLAGS \
-Warray-bounds \
-Wclobbered \
-Wcoverage-mismatch \
-Wempty-body \
-Wignored-qualifiers \
-Wlogical-op \
-Wmissing-parameter-type \
-Wold-style-declaration \
-Wpacked-bitfield-compat \
-Wsync-nand \
-Wtype-limits \
-Wvla \
"
# The above are valid for gcc version 4.4.3.
# We skip the following entirely:
#-pedantic
#-Wabi
#-Wc++-compat
#-Wconversion
#-Wfatal-errors
#-Wlong-long
#-Wpadded
#-Wsign-conversion
#-Wstack-protector
#-Wsystem-headers
#-Wtraditional
#-Wtraditional-conversion
#-Wunreachable-code
if (eval $ac_link) 2>/dev/null; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
CFLAGS="$save_cflags"
fi
else
AC_MSG_RESULT(no)
CFLAGS="$save_cflags"
fi
fi])
rm -f conftest.$ac_objext conftest.$ac_ext
# Check for zlib.
AC_CHECK_LIB(z, deflate,, [
cat <<END
$RULE
I can't link to zlib. You really can't have a modern
operating system without zlib.
If you are using a package-based operating system (like
something with RPMs), see if there is a zlib-devel package
that you can install, to provide the zlib headers and
libraries.
$RULE
END
AC_MSG_ERROR([can't find usable zlib])])
# Check for Solaris.
# Must do at least socket and nsl before checking for libpcap.
AC_SEARCH_LIBS(gethostbyname, [nsl], [],
[AC_MSG_ERROR([gethostbyname() not found])])
AC_SEARCH_LIBS(socket, [socket], [],
[AC_MSG_ERROR([socket() not found])])
AC_SEARCH_LIBS(hstrerror, [resolv], [],
[AC_MSG_ERROR([hstrerror() not found])])
# Solaris need sys/filio.h for FIONBIO
AC_CHECK_HEADERS(sys/filio.h)
# Debian GNU/kFreeBSD needs net/if_ether.h for ETH_P_IPV6
AC_CHECK_HEADERS(net/if_ether.h)
# This is the modern way. Older systems use the ioctl method.
AC_CHECK_HEADERS(ifaddrs.h)
# Some OSes (Solaris) need sys/sockio.h for SIOCGIFADDR
AC_CHECK_HEADERS(sys/sockio.h)
# Check for libpcap
AC_ARG_WITH(pcap, AS_HELP_STRING([--with-pcap=DIR],
[prefix to libpcap installation]),
[if test "$withval" = yes ; then
AC_MSG_ERROR([must specify a path, as in --with-pcap=DIR])
fi
if test "$withval" != no ; then
PCAP_HOME="$withval"
fi])
if test -n "$PCAP_HOME" ; then
LDFLAGS="$LDFLAGS -L$PCAP_HOME/lib"
CPPFLAGS2="$CPPFLAGS -I$PCAP_HOME/include/pcap"
CPPFLAGS="$CPPFLAGS -I$PCAP_HOME/include"
else
CPPFLAGS2="$CPPFLAGS -I/usr/include/pcap"
fi
AC_CHECK_LIB(pcap, pcap_loop,, PCAP_BROKEN="yes")
if test -z "$PCAP_BROKEN" ; then
AC_CHECK_HEADERS(pcap.h,,
[# Couldn't find headers, try include/pcap
CPPFLAGS="$CPPFLAGS2"
AC_MSG_NOTICE([checking in include/pcap])
unset ac_cv_header_pcap_h
AC_CHECK_HEADERS(pcap.h,
AC_MSG_RESULT([I hate you.]),
PCAP_BROKEN="yes")])
fi
if test -n "$PCAP_BROKEN" ; then
cat <<END_MSG
$RULE
darkstat absolutely requires libpcap to be installed. If
it's installed into a prefix that isn't being picked up by
configure, for example /usr/local, re-run configure and add
--with-pcap=/usr/local
If you are using a package-based operating system (like
something with RPMs), see if there is a pcap-devel or
libpcap-devel package that you can install, to provide the
pcap headers and libraries.
Failing all of the above, go to http://www.tcpdump.org/ and
download the source distribution of libpcap and build it
yourself.
$RULE
END_MSG
AC_MSG_ERROR([can't find usable libpcap])
fi
# If not in libc, we might find these in libbsd.
AC_SEARCH_LIBS(setproctitle, [bsd],
AC_DEFINE(HAVE_SETPROCTITLE, 1,
[Define to 1 if you have setproctitle().]))
AC_SEARCH_LIBS(strlcpy, [bsd],
AC_DEFINE(HAVE_STRLCPY, 1,
[Define to 1 if you have strlcpy().]))
AC_SEARCH_LIBS(strlcat, [bsd],
AC_DEFINE(HAVE_STRLCAT, 1,
[Define to 1 if you have strlcat().]))
AC_CHECK_HEADERS(bsd/string.h)
AC_CHECK_HEADERS(bsd/unistd.h)
AC_CONFIG_FILES([Makefile darkstat.8])
AC_OUTPUT
|