From: Todd C. Miller Date: Tue, 30 Aug 2011 14:12:04 +0000 (-0400) Subject: Add --enable-werror configure option. X-Git-Tag: SUDO_1_7_8~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=862d056d7e820a922effea759f7ce272c1b48939;p=sudo Add --enable-werror configure option. Add -Wall and -Werror after all tests so they don't cause failures. --HG-- branch : 1.7 --- diff --git a/INSTALL b/INSTALL index 5008f35c3..b8bb309c8 100644 --- a/INSTALL +++ b/INSTALL @@ -636,6 +636,9 @@ The following options are also configurable at runtime: --enable-warnings Enable compiler warnings when building sudo with gcc. + --enable-werror + Enable the -Werror compiler option when building sudo with gcc. + --enable-admin-flag Enable the creation of an Ubuntu-style admin flag file the first time sudo is run. diff --git a/configure b/configure index 7f8bdfe1b..c4ef12bbb 100755 --- a/configure +++ b/configure @@ -862,6 +862,7 @@ enable_path_info enable_env_debug enable_env_reset enable_warnings +enable_werror enable_admin_flag with_selinux enable_gss_krb5_ccache_name @@ -1521,6 +1522,7 @@ Optional Features: --enable-env-debug Whether to enable environment debugging. --enable-env-reset Whether to enable environment resetting by default. --enable-warnings Whether to enable compiler warnings + --enable-werror Whether to enable the -Werror compiler option --enable-admin-flag Whether to create a Ubuntu-style admin flag file --enable-gss-krb5-ccache-name Use GSS-API to set the Kerberos V cred cache name @@ -5522,10 +5524,7 @@ fi # Check whether --enable-warnings was given. if test "${enable_warnings+set}" = set; then : enableval=$enable_warnings; case "$enableval" in - yes) if test X"$with_devel" != X"yes" -a -n "$GCC"; then - CFLAGS="${CFLAGS} -Wall" - fi - ;; + yes) ;; no) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring unknown argument to --enable-warnings: $enableval" >&5 $as_echo "$as_me: WARNING: Ignoring unknown argument to --enable-warnings: $enableval" >&2;} @@ -5535,6 +5534,19 @@ $as_echo "$as_me: WARNING: Ignoring unknown argument to --enable-warnings: $enab fi +# Check whether --enable-werror was given. +if test "${enable_werror+set}" = set; then : + enableval=$enable_werror; case "$enableval" in + yes) ;; + no) ;; + *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring unknown argument to --enable-werror: $enableval" >&5 +$as_echo "$as_me: WARNING: Ignoring unknown argument to --enable-werror: $enableval" >&2;} + ;; + esac + +fi + + # Check whether --enable-admin-flag was given. if test "${enable_admin_flag+set}" = set; then : enableval=$enable_admin_flag; case "$enableval" in @@ -13488,10 +13500,6 @@ $as_echo "$with_noexec" >&6; } NOEXECFILE="sudo_noexec$_shrext" NOEXECDIR="`echo $with_noexec|sed 's:^\(.*\)/[^/]*:\1:'`" -if test X"$with_devel" = X"yes" -a -n "$GCC"; then - CFLAGS="${CFLAGS} -Wall" -fi - # Extract the first word of "uname", so it can be a program name with args. set dummy uname; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -19833,6 +19841,15 @@ if test -n "$LIBS"; then done fi +if test -n "$GCC"; then + if test X"$enable_warnings" = X"yes" -o X"$with_devel" = X"yes"; then + CFLAGS="${CFLAGS} -Wall" + fi + if test X"$enable_werror" = X"yes"; then + CFLAGS="${CFLAGS} -Werror" + fi +fi + test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)' if test X"$with_noexec" != X"no" -o X"$with_selinux" != X"no"; then diff --git a/configure.in b/configure.in index b24fc5454..930821033 100644 --- a/configure.in +++ b/configure.in @@ -1293,16 +1293,23 @@ fi AC_ARG_ENABLE(warnings, [AS_HELP_STRING([--enable-warnings], [Whether to enable compiler warnings])], [ case "$enableval" in - yes) if test X"$with_devel" != X"yes" -a -n "$GCC"; then - CFLAGS="${CFLAGS} -Wall" - fi - ;; + yes) ;; no) ;; *) AC_MSG_WARN([Ignoring unknown argument to --enable-warnings: $enableval]) ;; esac ]) +AC_ARG_ENABLE(werror, +[AS_HELP_STRING([--enable-werror], [Whether to enable the -Werror compiler option])], +[ case "$enableval" in + yes) ;; + no) ;; + *) AC_MSG_WARN([Ignoring unknown argument to --enable-werror: $enableval]) + ;; + esac +]) + AC_ARG_ENABLE(admin-flag, [AS_HELP_STRING([--enable-admin-flag], [Whether to create a Ubuntu-style admin flag file])], [ case "$enableval" in @@ -1376,13 +1383,6 @@ AC_MSG_RESULT($with_noexec) NOEXECFILE="sudo_noexec$_shrext" NOEXECDIR="`echo $with_noexec|sed 's:^\(.*\)/[[^/]]*:\1:'`" -dnl -dnl It is now safe to modify CFLAGS and CPPFLAGS -dnl -if test X"$with_devel" = X"yes" -a -n "$GCC"; then - CFLAGS="${CFLAGS} -Wall" -fi - dnl dnl Find programs we use dnl @@ -2894,6 +2894,18 @@ if test -n "$LIBS"; then done fi +dnl +dnl We add -Wall and -Werror after all tests so they don't cause failures +dnl +if test -n "$GCC"; then + if test X"$enable_warnings" = X"yes" -o X"$with_devel" = X"yes"; then + CFLAGS="${CFLAGS} -Wall" + fi + if test X"$enable_werror" = X"yes"; then + CFLAGS="${CFLAGS} -Werror" + fi +fi + dnl dnl Set exec_prefix dnl