diff --git a/configure.ac b/configure.ac
index 583843df66554a719d478788c4e5e0aa7e33f8b9..d3f05aa19de3257758a82d1e5d2a76f497069da9 100644 (file)
--- a/configure.ac
+++ b/configure.ac
dnl Process this file with autoconf to produce a configure script.
-AC_INIT([foobar],[m4_esyscmd(./version-gen.sh)],[sh@tokkee.org])
+AC_INIT([foobar],[m4_esyscmd(./version-gen.sh)],
+ [Sebastian Harl <sh@tokkee.org>])
AC_CONFIG_SRCDIR([src/foobar.c])
AC_CONFIG_HEADERS([src/config.h])
AC_PREFIX_DEFAULT([/opt/foobar])
AC_SYS_LARGEFILE
-dnl Check for programs...
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
return $ret
}
+dnl Optionally stick to standard C99 and POSIX.1 2001 as close as possible.
+AC_ARG_ENABLE([standards],
+ AS_HELP_STRING([--enable-standards],
+ [Enable standards compliance mode]),
+ [enable_standards="$enableval"],
+ [enable_standards="no"])
+
+if test "x$enable_standards" = "xyes"; then
+ AC_DEFINE([_ISOC99_SOURCE], 1,
+ [Define to enforce ISO/IEC 9899:1999 (C99) compliance.])
+ AC_DEFINE([_POSIX_C_SOURCE], 200112L,
+ [Define to enforce IEEE 1003.1-2001 (POSIX:2001) compliance.])
+ AC_DEFINE([_XOPEN_SOURCE], 600,
+ [Define to enforce X/Open 6 (XSI) compliance.])
+ AC_DEFINE([_REENTRANT], 1,
+ [Define to enable reentrant interfaces.])
+ AC_DEFINE([_THREAD_SAFE], 1,
+ [Define to enable reentrant interfaces.])
+
+ for flag in -std=c99 -pedantic; do
+ AC_MSG_CHECKING([whether $CC accepts $flag])
+
+ if test_cc_flags $flag; then
+ CFLAGS="$CFLAGS $flag"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ done
+fi
+
+dnl Hardening (see e.g. http://wiki.debian.org/Hardening for a motivation).
+AC_DEFINE([_FORTIFY_SOURCE], 2,
+ [Define to enable protection against static sized buffer overflows.])
+AC_ARG_ENABLE([hardening],
+ AS_HELP_STRING([--disable-hardening],
+ [Disable hardening options]),
+ [enable_hardening="$enableval"],
+ [enable_hardening="yes"])
+
+if test "x$enable_hardening" = "xyes"; then
+ hardening=0
+ hardening_tests=0
+ for flag in -Wformat -Wformat-security; do
+ hardening_tests=$(($hardening_tests + 1))
+ AC_MSG_CHECKING([whether $CC accepts $flag])
+
+ if test_cc_flags $flag; then
+ CFLAGS="$CFLAGS $flag"
+ hardening=$(($hardening + 1))
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ done
+ if test $hardening -ne $hardening_tests; then
+ AC_MSG_WARN(
+ [Some hardening options are not supported by your compiler!])
+ fi
+fi
+
for flag in -Wall -Wextra -Werror; do
AC_MSG_CHECKING([whether $CC accepts $flag])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
+cat <<EOF;
+
+$PACKAGE_NAME has been configured successfully.
+
+Run 'make' to compile the software and use 'make install' to
+install the package into $prefix.
+
+Configuration summary:
+
+ package version: $PACKAGE_VERSION
+ build date: $build_date
+
+Please report bugs to $PACKAGE_BUGREPORT.
+
+EOF
+