diff --git a/m4/cc_clang.m4 b/m4/cc_clang.m4 deleted file mode 100644 index f1198d768e..0000000000 --- a/m4/cc_clang.m4 +++ /dev/null @@ -1,7 +0,0 @@ -dnl * clang check -AC_DEFUN([CC_CLANG],[ -have_clang=no -if $CC -dM -E -x c /dev/null | grep __clang__ > /dev/null 2>&1; then - have_clang=yes -fi -]) diff --git a/m4/cc_fortify.m4 b/m4/cc_fortify.m4 deleted file mode 100644 index 3b01ec97cd..0000000000 --- a/m4/cc_fortify.m4 +++ /dev/null @@ -1,18 +0,0 @@ -dnl -dnl Check for support for D_FORTIFY_SOURCE=2 -dnl - -AC_DEFUN([AC_CC_D_FORTIFY_SOURCE],[ - AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) - if test $enable_hardening = yes; then - case "$host" in - *) - gl_COMPILER_OPTION_IF([-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2], [ - CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" - ], - [], - [AC_LANG_PROGRAM()] - ) - esac - fi -]) diff --git a/m4/cc_pie.m4 b/m4/cc_pie.m4 deleted file mode 100644 index 5ea018db2f..0000000000 --- a/m4/cc_pie.m4 +++ /dev/null @@ -1,52 +0,0 @@ -dnl -dnl Check for support for position independent executables -dnl -dnl Copyright (C) 2013 Red Hat, Inc. -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library. If not, see -dnl . -dnl - -AC_DEFUN([AC_CC_PIE],[ - AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) - PIE_CFLAGS= - PIE_LDFLAGS= - - if test $enable_hardening = yes; then - OLD_CFLAGS=$CFLAGS - case "$host" in - *-*-mingw* | *-*-msvc* | *-*-cygwin* ) - ;; dnl All code is position independent on Win32 target - *) - CFLAGS="-fPIE -DPIE" - gl_COMPILER_OPTION_IF([-pie], [ - PIE_CFLAGS="-fPIE -DPIE" - PIE_LDFLAGS="-pie" - ], [ - dnl some versions of clang require -Wl,-pie instead of -pie - gl_COMPILER_OPTION_IF([[-Wl,-pie]], [ - PIE_CFLAGS="-fPIE -DPIE" - PIE_LDFLAGS="-Wl,-pie" - ], [AC_MSG_RESULT([not supported])], - [AC_LANG_PROGRAM()] - ) - ], - [AC_LANG_PROGRAM()] - ) - esac - CFLAGS=$OLD_CFLAGS - fi - AC_SUBST([PIE_CFLAGS]) - AC_SUBST([PIE_LDFLAGS]) -]) diff --git a/m4/cc_retpoline.m4 b/m4/cc_retpoline.m4 deleted file mode 100644 index 26f567c3a1..0000000000 --- a/m4/cc_retpoline.m4 +++ /dev/null @@ -1,18 +0,0 @@ -dnl -dnl Check for support for Retpoline -dnl - -AC_DEFUN([AC_CC_RETPOLINE],[ - AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) - if test $enable_hardening = yes; then - case "$host" in - *) - gl_COMPILER_OPTION_IF([-mfunction-return=thunk -mindirect-branch=thunk], [ - CFLAGS="$CFLAGS -mfunction-return=thunk -mindirect-branch=thunk" - ], - [], - [AC_LANG_PROGRAM()] - ) - esac - fi -]) diff --git a/m4/cc_stack_protector.m4 b/m4/cc_stack_protector.m4 deleted file mode 100644 index fc7f957408..0000000000 --- a/m4/cc_stack_protector.m4 +++ /dev/null @@ -1,22 +0,0 @@ -dnl -dnl Check for support for -fstack-protector or -strong -dnl - -AC_DEFUN([AC_CC_F_STACK_PROTECTOR],[ - AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) - if test $enable_hardening = yes; then - case "$host" in - *) - gl_COMPILER_OPTION_IF([-fstack-protector-strong], [ - CFLAGS="$CFLAGS -fstack-protector-strong" - ], - [ - gl_COMPILER_OPTION_IF([-fstack-protector], [ - CFLAGS="$CFLAGS -fstack-protector" - ], [], [AC_LANG_PROGRAM()]) - ], - [AC_LANG_PROGRAM()] - ) - esac - fi -]) diff --git a/m4/cflags.m4 b/m4/cflags.m4 deleted file mode 100644 index cd1ecbf301..0000000000 --- a/m4/cflags.m4 +++ /dev/null @@ -1,51 +0,0 @@ -dnl * gcc specific options -AC_DEFUN([DOVECOT_CFLAGS],[ - if test "x$ac_cv_c_compiler_gnu" = "xyes"; then - # -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings - # -Wstrict-prototypes -Wredundant-decls # may give warnings in some systems - # -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings - CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast" - - if test "$have_clang" = "yes"; then - AC_TRY_COMPILE([ - #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 3) - # error new clang - #endif - ],,,[ - # clang 3.3+ unfortunately this gives warnings with hash.h - CFLAGS="$CFLAGS -Wno-duplicate-decl-specifier" - ]) - else - # This is simply to avoid warning when building strftime() wrappers.. - CFLAGS="$CFLAGS -fno-builtin-strftime" - fi - - AC_TRY_COMPILE([ - #if __GNUC__ < 4 - # error old gcc - #endif - ],,[ - # gcc4 - CFLAGS="$CFLAGS -Wstrict-aliasing=2" - ]) - - # Use std=gnu99 if we have new enough gcc - old_cflags=$CFLAGS - CFLAGS="-std=gnu99" - AC_TRY_COMPILE([ - ],, [ - CFLAGS="$CFLAGS $old_cflags" - ], [ - CFLAGS="$old_cflags" - ]) - - fi - if test "$have_clang" = "yes"; then - # clang specific options - if test "$want_devel_checks" = "yes"; then - # FIXME: enable once md[45], sha[12] can be compiled without - #CFLAGS="$CFLAGS -fsanitize=integer,undefined -ftrapv" - : - fi - fi -]) diff --git a/m4/dovecot.m4 b/m4/dovecot.m4 index 1eea1406b9..02e533e1e6 100644 --- a/m4/dovecot.m4 +++ b/m4/dovecot.m4 @@ -8,6 +8,231 @@ # serial 25 +dnl +dnl Check for support for D_FORTIFY_SOURCE=2 +dnl + +AC_DEFUN([AC_CC_D_FORTIFY_SOURCE],[ + AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) + if test $enable_hardening = yes; then + case "$host" in + *) + gl_COMPILER_OPTION_IF([-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2], [ + CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" + ], + [], + [AC_LANG_PROGRAM()] + ) + esac + fi +]) + +dnl * gcc specific options +AC_DEFUN([DOVECOT_CFLAGS],[ + if test "x$ac_cv_c_compiler_gnu" = "xyes"; then + # -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings + # -Wstrict-prototypes -Wredundant-decls # may give warnings in some systems + # -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings + CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast" + + if test "$have_clang" = "yes"; then + AC_TRY_COMPILE([ + #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 3) + # error new clang + #endif + ],,,[ + # clang 3.3+ unfortunately this gives warnings with hash.h + CFLAGS="$CFLAGS -Wno-duplicate-decl-specifier" + ]) + else + # This is simply to avoid warning when building strftime() wrappers.. + CFLAGS="$CFLAGS -fno-builtin-strftime" + fi + + AC_TRY_COMPILE([ + #if __GNUC__ < 4 + # error old gcc + #endif + ],,[ + # gcc4 + CFLAGS="$CFLAGS -Wstrict-aliasing=2" + ]) + + # Use std=gnu99 if we have new enough gcc + old_cflags=$CFLAGS + CFLAGS="-std=gnu99" + AC_TRY_COMPILE([ + ],, [ + CFLAGS="$CFLAGS $old_cflags" + ], [ + CFLAGS="$old_cflags" + ]) + + fi + if test "$have_clang" = "yes"; then + # clang specific options + if test "$want_devel_checks" = "yes"; then + # FIXME: enable once md[45], sha[12] can be compiled without + #CFLAGS="$CFLAGS -fsanitize=integer,undefined -ftrapv" + : + fi + fi +]) + +AC_DEFUN([AC_LD_WHOLE_ARCHIVE], [ + LD_WHOLE_ARCHIVE= + LD_NO_WHOLE_ARCHIVE= + AC_MSG_CHECKING([for linker option to include whole archive]) + ld_help="`$CC -Wl,-help 2>&1`" + case "$ld_help" in + *"--whole-archive"*) + LD_WHOLE_ARCHIVE="--whole-archive" + LD_NO_WHOLE_ARCHIVE="--no-whole-archive" + ;; + esac + AS_IF([test "x$LD_WHOLE_ARCHIVE" != "x"], + [AC_MSG_RESULT([-Wl,$LD_WHOLE_ARCHIVE])], + [AC_MSG_RESULT([not supported])] + ) + AC_SUBST([LD_WHOLE_ARCHIVE]) + AC_SUBST([LD_NO_WHOLE_ARCHIVE]) + AM_CONDITIONAL([HAVE_WHOLE_ARCHIVE], [test "x$LD_WHOLE_ARCHIVE" != "x"]) +]) + +dnl +dnl Check for -z now and -z relro linker flags +dnl +dnl Copyright (C) 2013 Red Hat, Inc. +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library. If not, see +dnl . +dnl + +AC_DEFUN([AC_LD_RELRO],[ + RELRO_LDFLAGS= + if test $enable_hardening = yes; then + AC_MSG_CHECKING([for how to force completely read-only GOT table]) + ld_help=`$CC -Wl,-help 2>&1` + case $ld_help in + *"-z relro"*) RELRO_LDFLAGS="-Wl,-z -Wl,relro" ;; + esac + case $ld_help in + *"-z now"*) RELRO_LDFLAGS="$RELRO_LDFLAGS -Wl,-z -Wl,now" ;; + esac + AS_IF([test "x$RELRO_LDFLAGS" != "x"], + [AC_MSG_RESULT([$RELRO_LDFLAGS])], + [AC_MSG_RESULT([unknown])] + ) + fi + AC_SUBST([RELRO_LDFLAGS]) +]) + +dnl +dnl Check for support for position independent executables +dnl +dnl Copyright (C) 2013 Red Hat, Inc. +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library. If not, see +dnl . +dnl + +AC_DEFUN([AC_CC_PIE],[ + AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) + PIE_CFLAGS= + PIE_LDFLAGS= + + if test $enable_hardening = yes; then + OLD_CFLAGS=$CFLAGS + case "$host" in + *-*-mingw* | *-*-msvc* | *-*-cygwin* ) + ;; dnl All code is position independent on Win32 target + *) + CFLAGS="-fPIE -DPIE" + gl_COMPILER_OPTION_IF([-pie], [ + PIE_CFLAGS="-fPIE -DPIE" + PIE_LDFLAGS="-pie" + ], [ + dnl some versions of clang require -Wl,-pie instead of -pie + gl_COMPILER_OPTION_IF([[-Wl,-pie]], [ + PIE_CFLAGS="-fPIE -DPIE" + PIE_LDFLAGS="-Wl,-pie" + ], [AC_MSG_RESULT([not supported])], + [AC_LANG_PROGRAM()] + ) + ], + [AC_LANG_PROGRAM()] + ) + esac + CFLAGS=$OLD_CFLAGS + fi + AC_SUBST([PIE_CFLAGS]) + AC_SUBST([PIE_LDFLAGS]) +]) + +dnl +dnl Check for support for Retpoline +dnl + +AC_DEFUN([AC_CC_RETPOLINE],[ + AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) + if test $enable_hardening = yes; then + case "$host" in + *) + gl_COMPILER_OPTION_IF([-mfunction-return=thunk -mindirect-branch=thunk], [ + CFLAGS="$CFLAGS -mfunction-return=thunk -mindirect-branch=thunk" + ], + [], + [AC_LANG_PROGRAM()] + ) + esac + fi +]) + +dnl +dnl Check for support for -fstack-protector or -strong +dnl + +AC_DEFUN([AC_CC_F_STACK_PROTECTOR],[ + AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) + if test $enable_hardening = yes; then + case "$host" in + *) + gl_COMPILER_OPTION_IF([-fstack-protector-strong], [ + CFLAGS="$CFLAGS -fstack-protector-strong" + ], + [ + gl_COMPILER_OPTION_IF([-fstack-protector], [ + CFLAGS="$CFLAGS -fstack-protector" + ], [], [AC_LANG_PROGRAM()]) + ], + [AC_LANG_PROGRAM()] + ) + esac + fi +]) + AC_DEFUN([DC_DOVECOT_MODULEDIR],[ AC_ARG_WITH(moduledir, [ --with-moduledir=DIR Base directory for dynamically loadable modules], @@ -194,3 +419,89 @@ AC_DEFUN([DC_PANDOC], [ fi fi ]) +# warnings.m4 serial 11 +dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson + +# gl_AS_VAR_APPEND(VAR, VALUE) +# ---------------------------- +# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it. +m4_ifdef([AS_VAR_APPEND], +[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])], +[m4_define([gl_AS_VAR_APPEND], +[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])]) + + +# gl_COMPILER_OPTION_IF(OPTION, [IF-SUPPORTED], [IF-NOT-SUPPORTED], +# [PROGRAM = AC_LANG_PROGRAM()]) +# ----------------------------------------------------------------- +# Check if the compiler supports OPTION when compiling PROGRAM. +# +# FIXME: gl_Warn must be used unquoted until we can assume Autoconf +# 2.64 or newer. +AC_DEFUN([gl_COMPILER_OPTION_IF], +[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl +AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl +AS_LITERAL_IF([$1], + [m4_pushdef([gl_Positive], m4_bpatsubst([$1], [^-Wno-], [-W]))], + [gl_positive="$1" +case $gl_positive in + -Wno-*) gl_positive=-W`expr "X$gl_positive" : 'X-Wno-\(.*\)'` ;; +esac +m4_pushdef([gl_Positive], [$gl_positive])])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [ + gl_save_compiler_FLAGS="$gl_Flags" + gl_AS_VAR_APPEND(m4_defn([gl_Flags]), + [" $gl_unknown_warnings_are_errors ]m4_defn([gl_Positive])["]) + AC_LINK_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])], + [AS_VAR_SET(gl_Warn, [yes])], + [AS_VAR_SET(gl_Warn, [no])]) + gl_Flags="$gl_save_compiler_FLAGS" +]) +AS_VAR_IF(gl_Warn, [yes], [$2], [$3]) +m4_popdef([gl_Positive])dnl +AS_VAR_POPDEF([gl_Flags])dnl +AS_VAR_POPDEF([gl_Warn])dnl +]) + +# gl_UNKNOWN_WARNINGS_ARE_ERRORS +# ------------------------------ +# Clang doesn't complain about unknown warning options unless one also +# specifies -Wunknown-warning-option -Werror. Detect this. +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS], +[gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option], + [gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'], + [gl_unknown_warnings_are_errors=])]) + +# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS], +# [PROGRAM = AC_LANG_PROGRAM()]) +# --------------------------------------------- +# Adds parameter to WARN_CFLAGS if the compiler supports it when +# compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]). +# +# If VARIABLE is a variable name, AC_SUBST it. +AC_DEFUN([gl_WARN_ADD], +[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) +gl_COMPILER_OPTION_IF([$1], + [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])], + [], + [$3]) +m4_ifval([$2], + [AS_LITERAL_IF([$2], [AC_SUBST([$2])])], + [AC_SUBST([WARN_CFLAGS])])dnl +]) + +# Local Variables: +# mode: autoconf +# End: +dnl * clang check +AC_DEFUN([CC_CLANG],[ +have_clang=no +if $CC -dM -E -x c /dev/null | grep __clang__ > /dev/null 2>&1; then + have_clang=yes +fi +]) diff --git a/m4/ld_relro.m4 b/m4/ld_relro.m4 deleted file mode 100644 index a2800510ec..0000000000 --- a/m4/ld_relro.m4 +++ /dev/null @@ -1,38 +0,0 @@ -dnl -dnl Check for -z now and -z relro linker flags -dnl -dnl Copyright (C) 2013 Red Hat, Inc. -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library. If not, see -dnl . -dnl - -AC_DEFUN([AC_LD_RELRO],[ - RELRO_LDFLAGS= - if test $enable_hardening = yes; then - AC_MSG_CHECKING([for how to force completely read-only GOT table]) - ld_help=`$CC -Wl,-help 2>&1` - case $ld_help in - *"-z relro"*) RELRO_LDFLAGS="-Wl,-z -Wl,relro" ;; - esac - case $ld_help in - *"-z now"*) RELRO_LDFLAGS="$RELRO_LDFLAGS -Wl,-z -Wl,now" ;; - esac - AS_IF([test "x$RELRO_LDFLAGS" != "x"], - [AC_MSG_RESULT([$RELRO_LDFLAGS])], - [AC_MSG_RESULT([unknown])] - ) - fi - AC_SUBST([RELRO_LDFLAGS]) -]) diff --git a/m4/ld_whole_archive.m4 b/m4/ld_whole_archive.m4 deleted file mode 100644 index 42a4206e9f..0000000000 --- a/m4/ld_whole_archive.m4 +++ /dev/null @@ -1,19 +0,0 @@ -AC_DEFUN([AC_LD_WHOLE_ARCHIVE], [ - LD_WHOLE_ARCHIVE= - LD_NO_WHOLE_ARCHIVE= - AC_MSG_CHECKING([for linker option to include whole archive]) - ld_help="`$CC -Wl,-help 2>&1`" - case "$ld_help" in - *"--whole-archive"*) - LD_WHOLE_ARCHIVE="--whole-archive" - LD_NO_WHOLE_ARCHIVE="--no-whole-archive" - ;; - esac - AS_IF([test "x$LD_WHOLE_ARCHIVE" != "x"], - [AC_MSG_RESULT([-Wl,$LD_WHOLE_ARCHIVE])], - [AC_MSG_RESULT([not supported])] - ) - AC_SUBST([LD_WHOLE_ARCHIVE]) - AC_SUBST([LD_NO_WHOLE_ARCHIVE]) - AM_CONDITIONAL([HAVE_WHOLE_ARCHIVE], [test "x$LD_WHOLE_ARCHIVE" != "x"]) -]) diff --git a/m4/warnings.m4 b/m4/warnings.m4 deleted file mode 100644 index 5ae01def13..0000000000 --- a/m4/warnings.m4 +++ /dev/null @@ -1,79 +0,0 @@ -# warnings.m4 serial 11 -dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Simon Josefsson - -# gl_AS_VAR_APPEND(VAR, VALUE) -# ---------------------------- -# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it. -m4_ifdef([AS_VAR_APPEND], -[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])], -[m4_define([gl_AS_VAR_APPEND], -[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])]) - - -# gl_COMPILER_OPTION_IF(OPTION, [IF-SUPPORTED], [IF-NOT-SUPPORTED], -# [PROGRAM = AC_LANG_PROGRAM()]) -# ----------------------------------------------------------------- -# Check if the compiler supports OPTION when compiling PROGRAM. -# -# FIXME: gl_Warn must be used unquoted until we can assume Autoconf -# 2.64 or newer. -AC_DEFUN([gl_COMPILER_OPTION_IF], -[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl -AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl -AS_LITERAL_IF([$1], - [m4_pushdef([gl_Positive], m4_bpatsubst([$1], [^-Wno-], [-W]))], - [gl_positive="$1" -case $gl_positive in - -Wno-*) gl_positive=-W`expr "X$gl_positive" : 'X-Wno-\(.*\)'` ;; -esac -m4_pushdef([gl_Positive], [$gl_positive])])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [ - gl_save_compiler_FLAGS="$gl_Flags" - gl_AS_VAR_APPEND(m4_defn([gl_Flags]), - [" $gl_unknown_warnings_are_errors ]m4_defn([gl_Positive])["]) - AC_LINK_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])], - [AS_VAR_SET(gl_Warn, [yes])], - [AS_VAR_SET(gl_Warn, [no])]) - gl_Flags="$gl_save_compiler_FLAGS" -]) -AS_VAR_IF(gl_Warn, [yes], [$2], [$3]) -m4_popdef([gl_Positive])dnl -AS_VAR_POPDEF([gl_Flags])dnl -AS_VAR_POPDEF([gl_Warn])dnl -]) - -# gl_UNKNOWN_WARNINGS_ARE_ERRORS -# ------------------------------ -# Clang doesn't complain about unknown warning options unless one also -# specifies -Wunknown-warning-option -Werror. Detect this. -AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS], -[gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option], - [gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'], - [gl_unknown_warnings_are_errors=])]) - -# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS], -# [PROGRAM = AC_LANG_PROGRAM()]) -# --------------------------------------------- -# Adds parameter to WARN_CFLAGS if the compiler supports it when -# compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]). -# -# If VARIABLE is a variable name, AC_SUBST it. -AC_DEFUN([gl_WARN_ADD], -[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) -gl_COMPILER_OPTION_IF([$1], - [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])], - [], - [$3]) -m4_ifval([$2], - [AS_LITERAL_IF([$2], [AC_SUBST([$2])])], - [AC_SUBST([WARN_CFLAGS])])dnl -]) - -# Local Variables: -# mode: autoconf -# End: