From: Sebastian Harl Date: Thu, 15 Oct 2009 21:59:26 +0000 (+0200) Subject: configure.ac: Added --disable-hardening command line option. X-Git-Url: https://git.tokkee.org/?p=template.git;a=commitdiff_plain;h=379e19a21ba6937215bcd3eb9db8d5d54c286eae configure.ac: Added --disable-hardening command line option. This option may be used to disable harding options (enabled by default). --- diff --git a/configure.ac b/configure.ac index e0fd5db..d3f05aa 100644 --- a/configure.ac +++ b/configure.ac @@ -61,6 +61,36 @@ if test "x$enable_standards" = "xyes"; then 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])