Commit 3b936432 authored by David King's avatar David King

Update AX_COMPILER_FLAGS from autoconf-archive

Drop C++ warning checks, as a C++ compiler is not required to build
Yelp.
parent 14004471
......@@ -13,6 +13,7 @@ AM_SILENT_RULES([yes])
AX_IS_RELEASE([git-directory])
AX_CHECK_ENABLE_DEBUG([info], [YELP_DEBUG], [$ax_is_release])
AX_COMPILER_FLAGS([], [], [$ax_is_release])
# Check for programs
AC_PROG_CC
AC_PROG_CC_C_O
......@@ -40,7 +41,6 @@ PKG_CHECK_MODULES(YELP,
AC_SUBST([YELP_CFLAGS])
AC_SUBST([YELP_LIBS])
AX_COMPILER_FLAGS([], [], [$ax_is_release])
# Initialize libtool
LT_PREREQ([2.2.6])
......
......@@ -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
......@@ -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
# ==============================================================================
# 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment