Use the host compiler for build tool c-ify.
[darkstat-debian] / configure.ac
index 15c356a..dd237e4 100644 (file)
@@ -1,34 +1,11 @@
-AC_INIT(darkstat, 3.0.715, , , http://unix4lyfe.org/darkstat/)
+# Need at least 2.64 for PACKAGE_URL
+AC_PREREQ([2.64])
+AC_INIT(darkstat, 3.0.719, , , https://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)]),
@@ -40,6 +17,9 @@ AC_DEFINE_UNQUOTED(PRIVDROP_USER, "$_pdu", [User to privdrop to.])
 AC_PROG_INSTALL
 AC_PROG_CC
 
+# Compiler's language features.
+AC_C_RESTRICT
+
 m4_pattern_allow([^AM_DEFAULT_VERBOSITY$])
 AC_ARG_ENABLE([silent-rules],
 [  --enable-silent-rules          less verbose build output (undo: 'make V=1')
@@ -92,121 +72,25 @@ 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]),
+AC_ARG_ENABLE(warnings, AS_HELP_STRING([--enable-warnings],
+ [turn on lots of compile-time warnings,
 these are only useful for development]),
  [if test "x$enableval" = "xyes" ; then
-   AC_MSG_CHECKING(if your C compiler can emit certain warnings)
+   AC_MSG_CHECKING(if your C compiler has gcc-like --extra-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.
-
+   CFLAGS="$CFLAGS -fdiagnostics-show-option --all-warnings --extra-warnings"
    if (eval $ac_link) 2>/dev/null; then
     AC_MSG_RESULT(yes)
+   else
+    AC_MSG_RESULT(no)
+    CFLAGS="$save_cflags"
+   fi
 
-    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
-
+   AC_MSG_CHECKING(if your C compiler has clang-like -Weverything)
+   save_cflags="$CFLAGS"
+   CFLAGS="$CFLAGS -Weverything"
+   if (eval $ac_link) 2>/dev/null; then
+    AC_MSG_RESULT(yes)
    else
     AC_MSG_RESULT(no)
     CFLAGS="$save_cflags"
@@ -225,10 +109,9 @@ $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.
+On Debian or a derivative, try: sudo apt-get install zlib1g-dev
+
+On an RPM system, see if there is a zlib-devel package.
 
 $RULE
 END
@@ -248,11 +131,11 @@ AC_SEARCH_LIBS(hstrerror, [resolv], [],
 # 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)
+AC_SEARCH_LIBS(getifaddrs, [c],
+  [AC_CHECK_HEADERS(ifaddrs.h)])
+
+
 
 # Some OSes (Solaris) need sys/sockio.h for SIOCGIFADDR
 AC_CHECK_HEADERS(sys/sockio.h)
@@ -292,19 +175,16 @@ 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
+darkstat absolutely requires libpcap to be installed.  On Debian
+systems, apt-get install libpcap-dev.  On RPM systems like RedHat, try
+installing the libpcap-devel package.
+
+If libpcap is 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.
+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
@@ -325,5 +205,7 @@ AC_SEARCH_LIBS(strlcat, [bsd],
 AC_CHECK_HEADERS(bsd/string.h)
 AC_CHECK_HEADERS(bsd/unistd.h)
 
+AC_SEARCH_LIBS(clock_gettime, rt)
+
 AC_CONFIG_FILES([Makefile darkstat.8])
 AC_OUTPUT