X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=configure.ac;h=d3f05aa19de3257758a82d1e5d2a76f497069da9;hb=379e19a21ba6937215bcd3eb9db8d5d54c286eae;hp=583843df66554a719d478788c4e5e0aa7e33f8b9;hpb=7d0a87a73a3962d361a2d3eb85ff346ffc7f4406;p=template.git diff --git a/configure.ac b/configure.ac index 583843d..d3f05aa 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,7 @@ 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 ]) AC_CONFIG_SRCDIR([src/foobar.c]) AC_CONFIG_HEADERS([src/config.h]) AC_PREFIX_DEFAULT([/opt/foobar]) @@ -11,7 +12,6 @@ AC_LANG(C) AC_SYS_LARGEFILE -dnl Check for programs... AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL @@ -30,6 +30,67 @@ test_cc_flags() { 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]) @@ -51,3 +112,19 @@ AC_CHECK_HEADERS(libgen.h) AC_CONFIG_FILES([Makefile src/Makefile]) AC_OUTPUT +cat <