[yelp] Update AX_COMPILER_FLAGS from autoconf-archive



commit 3b9364324d8545b3bce91f83bd55b10b1b5e3c2e
Author: David King <amigadave amigadave com>
Date:   Sat Feb 21 10:34:35 2015 +0000

    Update AX_COMPILER_FLAGS from autoconf-archive
    
    Drop C++ warning checks, as a C++ compiler is not required to build
    Yelp.

 configure.ac                     |    2 +-
 m4/ax_compiler_flags.m4          |   32 +++++++--
 m4/ax_compiler_flags_cflags.m4   |    6 ++-
 m4/ax_compiler_flags_cxxflags.m4 |  133 --------------------------------------
 4 files changed, 30 insertions(+), 143 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d7f59c4..24bf15c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
diff --git a/m4/ax_compiler_flags.m4 b/m4/ax_compiler_flags.m4
index 061dd86..84cd882 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 7f2388d..204f64c 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]