diff options
author | David King <amigadave@amigadave.com> | 2015-02-21 10:34:35 +0000 |
---|---|---|
committer | David King <amigadave@amigadave.com> | 2015-02-21 10:36:49 +0000 |
commit | 3b9364324d8545b3bce91f83bd55b10b1b5e3c2e (patch) | |
tree | 3cf69c1a570f1716a91d020f17a1bab30d392d92 /m4 | |
parent | 14004471be4abfa7681785bd5ec13803666e0f67 (diff) | |
download | yelp-3b9364324d8545b3bce91f83bd55b10b1b5e3c2e.tar.gz |
Update AX_COMPILER_FLAGS from autoconf-archive
Drop C++ warning checks, as a C++ compiler is not required to build
Yelp.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/ax_compiler_flags.m4 | 32 | ||||
-rw-r--r-- | m4/ax_compiler_flags_cflags.m4 | 6 | ||||
-rw-r--r-- | m4/ax_compiler_flags_cxxflags.m4 | 133 |
3 files changed, 29 insertions, 142 deletions
diff --git a/m4/ax_compiler_flags.m4 b/m4/ax_compiler_flags.m4 index 061dd866..84cd8820 100644 --- a/m4/ax_compiler_flags.m4 +++ b/m4/ax_compiler_flags.m4 @@ -59,10 +59,11 @@ # be manually added to the CFLAGS and LDFLAGS variables for each target in # the code base. # -# Warning flags for the C++ compiler are AC_SUBST-ed as WARN_CXXFLAGS, and -# must be manually added to the CXXFLAGS variables for each target in the -# code base. EXTRA-*-CFLAGS can be used to augment the flags enabled at -# each level. +# If C++ language support is enabled with AC_PROG_CXX, which must occur +# before this macro in configure.ac, warning flags for the C++ compiler +# are AC_SUBST-ed as WARN_CXXFLAGS, and must be manually added to the +# CXXFLAGS variables for each target in the code base. EXTRA-*-CFLAGS can +# be used to augment the flags enabled at each level. # # Warning flags for g-ir-scanner (from GObject Introspection) are # AC_SUBST-ed as WARN_SCANNERFLAGS. This variable must be manually added @@ -87,11 +88,25 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 8 +#serial 9 + +# _AX_COMPILER_FLAGS_LANG([LANGNAME]) +m4_defun([_AX_COMPILER_FLAGS_LANG], +[m4_ifdef([_AX_COMPILER_FLAGS_LANG_]$1[_enabled], [], + [m4_define([_AX_COMPILER_FLAGS_LANG_]$1[_enabled], [])dnl + AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_]$1[FLAGS])])dnl +]) AC_DEFUN([AX_COMPILER_FLAGS],[ - AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_CFLAGS]) - AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_CXXFLAGS]) + # C support is enabled by default. + _AX_COMPILER_FLAGS_LANG([C]) + # Only enable C++ support if AC_PROG_CXX is called. The redefinition of + # AC_PROG_CXX is so that a fatal error is emitted if this macro is called + # before AC_PROG_CXX, which would otherwise cause no C++ warnings to be + # checked. + AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AX_COMPILER_FLAGS_LANG([CXX])], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AX_COMPILER_FLAGS_LANG([CXX])])]) AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_LDFLAGS]) AC_ARG_ENABLE([compile-warnings], @@ -114,7 +129,8 @@ AC_DEFUN([AX_COMPILER_FLAGS],[ ax_enable_compile_warnings=$enable_compile_warnings AX_COMPILER_FLAGS_CFLAGS([$1],[$3],[$4],[$5],[$6],[$7],[$8]) - AX_COMPILER_FLAGS_CXXFLAGS([WARN_CXXFLAGS],[$3],[$4],[$5],[$6],[$7],[$8]) + m4_ifdef([_AX_COMPILER_FLAGS_LANG_CXX_enabled], + [AX_COMPILER_FLAGS_CXXFLAGS([WARN_CXXFLAGS],[$3],[$4],[$5],[$6],[$7],[$8])]) AX_COMPILER_FLAGS_LDFLAGS([$2],[$3],[$9],[$10],[$11],[$12],[$13]) AX_COMPILER_FLAGS_GIR([WARN_SCANNERFLAGS],[$3]) ])dnl AX_COMPILER_FLAGS diff --git a/m4/ax_compiler_flags_cflags.m4 b/m4/ax_compiler_flags_cflags.m4 index 7f2388de..204f64c7 100644 --- a/m4/ax_compiler_flags_cflags.m4 +++ b/m4/ax_compiler_flags_cflags.m4 @@ -25,7 +25,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 4 +#serial 5 AC_DEFUN([AX_COMPILER_FLAGS_CFLAGS],[ AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) @@ -36,6 +36,8 @@ AC_DEFUN([AX_COMPILER_FLAGS_CFLAGS],[ m4_define(ax_warn_cflags_variable, [m4_normalize(ifelse([$1],,[WARN_CFLAGS],[$1]))]) + AC_LANG_PUSH([C]) + # Always pass -Werror=unknown-warning-option to get Clang to fail on bad # flags, otherwise they are always appended to the warn_cflags variable, and # Clang warns on them for every compilation unit. @@ -128,6 +130,8 @@ AC_DEFUN([AX_COMPILER_FLAGS_CFLAGS],[ ],ax_warn_cflags_variable,[$ax_compiler_flags_test]) ]) + AC_LANG_POP([C]) + # Substitute the variables AC_SUBST(ax_warn_cflags_variable) ])dnl AX_COMPILER_FLAGS diff --git a/m4/ax_compiler_flags_cxxflags.m4 b/m4/ax_compiler_flags_cxxflags.m4 deleted file mode 100644 index 6031a6fa..00000000 --- a/m4/ax_compiler_flags_cxxflags.m4 +++ /dev/null @@ -1,133 +0,0 @@ -# ============================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_cxxflags.html -# ============================================================================== -# -# SYNOPSIS -# -# AX_COMPILER_FLAGS_CXXFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-MINIMUM-FLAGS], [EXTRA-YES-FLAGS], [EXTRA-MAXIMUM-FLAGS], [EXTRA-ERROR-FLAGS]) -# -# DESCRIPTION -# -# Add warning flags for the C++ compiler to VARIABLE, which defaults to -# WARN_CXXFLAGS. VARIABLE is AC_SUBST-ed by this macro, but must be -# manually added to the CXXFLAGS variable for each target in the code -# base. -# -# This macro depends on the environment set up by AX_COMPILER_FLAGS. -# Specifically, it uses the value of $ax_enable_compile_warnings to decide -# which flags to enable. -# -# LICENSE -# -# Copyright (c) 2015 David King <amigadave@amigadave.com> -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 2 - -AC_DEFUN([AX_COMPILER_FLAGS_CXXFLAGS],[ - AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) - AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) - AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) - - # Variable names - m4_define(ax_warn_cxxflags_variable, - [m4_normalize(ifelse([$1],,[WARN_CXXFLAGS],[$1]))]) - - AC_LANG_PUSH([C++]) - - # Always pass -Werror=unknown-warning-option to get Clang to fail on bad - # flags, otherwise they are always appended to the warn_cxxflags variable, - # and Clang warns on them for every compilation unit. - # If this is passed to GCC, it will explode, so the flag must be enabled - # conditionally. - AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[ - ax_compiler_flags_test="-Werror=unknown-warning-option" - ],[ - ax_compiler_flags_test="" - ]) - - # Base flags - AX_APPEND_COMPILE_FLAGS([ dnl - -fno-strict-aliasing dnl - $3 dnl - ],ax_warn_cxxflags_variable,[$ax_compiler_flags_test]) - - # In the flags below, when disabling specific flags, always add *both* - # -Wno-foo and -Wno-error=foo. This fixes the situation where (for example) - # we enable -Werror, disable a flag, and a build bot passes CFLAGS=-Wall, - # which effectively turns that flag back on again as an error. - AS_IF([test "$ax_enable_compile_warnings" != "no"],[ - # "minimum" flags - AX_APPEND_COMPILE_FLAGS([ dnl - -Wall dnl - $4 dnl - ],ax_warn_cxxflags_variable,[$ax_compiler_flags_test]) - ]) - AS_IF([test "$ax_enable_compile_warnings" != "no" -a \ - "$ax_enable_compile_warnings" != "minimum"],[ - # "yes" flags - AX_APPEND_COMPILE_FLAGS([ dnl - -Wextra dnl - -Wundef dnl - -Wwrite-strings dnl - -Wpointer-arith dnl - -Wmissing-declarations dnl - -Wredundant-decls dnl - -Wno-unused-parameter dnl - -Wno-error=unused-parameter dnl - -Wno-missing-field-initializers dnl - -Wno-error=missing-field-initializers dnl - -Wformat=2 dnl - -Wcast-align dnl - -Wformat-nonliteral dnl - -Wformat-security dnl - -Wsign-compare dnl - -Wstrict-aliasing dnl - -Wshadow dnl - -Winline dnl - -Wpacked dnl - -Wmissing-format-attribute dnl - -Wmissing-noreturn dnl - -Winit-self dnl - -Wredundant-decls dnl - -Wmissing-include-dirs dnl - -Wunused-but-set-variable dnl - -Warray-bounds dnl - -Wreturn-type dnl - -Wno-overloaded-virtual dnl - -Wno-error=overloaded-virtual dnl - $5 dnl - ],ax_warn_cxxflags_variable,[$ax_compiler_flags_test]) - ]) - AS_IF([test "$ax_enable_compile_warnings" = "maximum" -o \ - "$ax_enable_compile_warnings" = "error"],[ - # "maximum" flags - AX_APPEND_COMPILE_FLAGS([ dnl - -Wswitch-enum dnl - -Wswitch-default dnl - $6 dnl - ],ax_warn_cxxflags_variable,[$ax_compiler_flags_test]) - ]) - AS_IF([test "$ax_enable_compile_warnings" = "error"],[ - # "error" flags; -Werror has to be appended unconditionally because - # it’s not possible to test for - # - # suggest-attribute=format is disabled because it gives too many false - # positives - AX_APPEND_FLAG([-Werror],ax_warn_cxxflags_variable) - - AX_APPEND_COMPILE_FLAGS([ dnl - -Wno-suggest-attribute=format dnl - $7 dnl - ],ax_warn_cxxflags_variable,[$ax_compiler_flags_test]) - ]) - - AC_LANG_POP([C++]) - - # Substitute the variables - AC_SUBST(ax_warn_cxxflags_variable) -])dnl AX_COMPILER_FLAGS_CXXFLAGS |