1From 28ba44ad9ca14153e96c94a9100423ea224c1af3 Mon Sep 17 00:00:00 2001
2From: Simon Marchi <simon.marchi@efficios.com>
3Date: Tue, 18 Feb 2020 13:14:22 -0500
4Subject: [PATCH] configure: simplify warning flags detection
5
6We currently use the AX_COMPILER_FLAGS macro to detect the warning flags
7that the current compiler supports.  It works, but is quite invasive.
8It unconditionally enables a bunch of warnings we don't want, which
9forces us to disable them with many -Wno-foo switches.
10
11Instead of using AX_COMPILER_FLAGS, we can use the slightly lower lever
12macro AX_APPEND_COMPILE_FLAGS to achieve our goal of detecting which
13warning flags are supported.  This is what we ended up using in
14lttng-tools (a completely unrelated project, but that has a suspiciously
15high ratio of contributors in common with Babeltrace).
16
17I looked in our git history to see which warning flags were mentioned in
18commit messages.  I have added the flags that did find actual problems
19and are not enabled by default to the AX_APPEND_COMPILE_FLAGS invocation.
20I have also added the flags that AX_COMPILER_FLAGS did provide, which we
21didn't need to disable.
22
23The --{enable,disable}-Werror flag is added using an explicit
24AC_ARG_ENABLE.  In lttng-tools, it was decided to _not_ have -Werror by
25default, so I suggest we do the same in Babeltrace, for consistency
26(although it saddens me very much).  Developers who want to build with
27-Werror will need to pass --enable-Werror.
28
29Note that with this patch, we lose the following configure switch, that
30is provided by AX_COMPILER_FLAGS:
31
32  --enable-compile-warnings=[no/yes/error]
33
34Change-Id: If968f7385a7f5c48d27f402c76bc26241a8f505a
35Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
36Reviewed-on: https://review.lttng.org/c/babeltrace/+/3209
37Tested-by: jenkins <jenkins@lttng.org>
38Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
39
40[Retrieved from:
41https://github.com/efficios/babeltrace/commit/28ba44ad9ca14153e96c94a9100423ea224c1af3]
42Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
43---
44 configure.ac                    |  74 +++++++++------
45 m4/ax_compiler_flags.m4         | 158 -------------------------------
46 m4/ax_compiler_flags_cflags.m4  | 161 --------------------------------
47 m4/ax_compiler_flags_gir.m4     |  60 ------------
48 m4/ax_compiler_flags_ldflags.m4 | 111 ----------------------
49 5 files changed, 46 insertions(+), 518 deletions(-)
50 delete mode 100644 m4/ax_compiler_flags.m4
51 delete mode 100644 m4/ax_compiler_flags_cflags.m4
52 delete mode 100644 m4/ax_compiler_flags_gir.m4
53 delete mode 100644 m4/ax_compiler_flags_ldflags.m4
54
55diff --git a/configure.ac b/configure.ac
56index 055fba101..7ebcf2ad4 100644
57--- a/configure.ac
58+++ b/configure.ac
59@@ -660,25 +660,35 @@ target.
60 CFLAGS=${save_CFLAGS}
61
62 # Detect C and LD warning flags supported by the compiler.
63-AX_COMPILER_FLAGS(
64-	[WARN_CFLAGS], dnl CFLAGS variable name
65-	[WARN_LDFLAGS], dnl LDFLAGS variable name (unused for now)
66-	[], dnl is-release
67-	[], dnl Extra base CFLAGS
68-	[ dnl Extra "yes" CFLAGS
69-		dnl Disable these flags, either because we don't want them
70-		dnl or because we want them but are not ready to enable them
71-		dnl yet.
72-		-Wno-sign-compare dnl
73-		-Wno-inline dnl
74-		-Wno-declaration-after-statement dnl
75-		-Wno-switch-enum dnl
76-		-Wno-switch-default dnl
77-		-Wno-packed dnl
78-		-Wno-pointer-arith dnl
79+
80+# Detect warning flags supported by the compiler, append them to WARN_CFLAGS.
81+#
82+# Pass -Werror as an extra flag during the test: this is needed to make the
83+# -Wunknown-warning-option diagnostic fatal with clang.
84+AX_APPEND_COMPILE_FLAGS([ dnl
85+		-Wall dnl
86+		-Wextra dnl
87+		-Wstrict-prototypes dnl
88+		-Wmissing-prototypes dnl
89+		-Wmissing-declarations dnl
90+		-Wnull-dereference dnl
91+		-Wundef dnl
92+		-Wredundant-decls dnl
93+		-Wshadow dnl
94+		-Wjump-misses-init dnl
95+		-Wtautological-constant-out-of-range-compare dnl
96+		-Wnested-externs dnl
97+		-Wwrite-strings dnl
98+		-Wformat=2 dnl
99 		-Wno-format-nonliteral dnl
100-		-Wno-double-promotion dnl
101-		-Wno-cast-align dnl
102+		-Wstrict-aliasing dnl
103+		-Wmissing-noreturn dnl
104+		-Winit-self dnl
105+		-Wduplicated-cond dnl
106+		-Wduplicated-branches dnl
107+		-Wlogical-op dnl
108+		-Wno-unused-parameter dnl
109+		-Wno-sign-compare dnl
110 		dnl
111 		dnl Some versions of SWIG (like 3.0.12) generate code that produces
112 		dnl -Wcast-function-type warnings.  This warning is present in gcc >= 8.  This
113@@ -692,24 +702,32 @@ AX_COMPILER_FLAGS(
114 		dnl
115 		dnl Ref: https://github.com/swig/swig/issues/1259
116 		-Wno-cast-function-type dnl
117-	])
118-
119-# CFLAGS from AX_COMPILER_FLAGS.
120-AM_CFLAGS="${AM_CFLAGS} ${WARN_CFLAGS}"
121+		-Wno-missing-field-initializers dnl
122+	],
123+	[WARN_CFLAGS],
124+	[-Werror])
125+
126+# When given, add -Werror to WARN_CFLAGS.
127+AC_ARG_ENABLE([Werror],
128+	[AS_HELP_STRING([--enable-Werror], [Treat compiler warnings as errors.])]
129+)
130+AS_IF([test "x$enable_Werror" = "xyes"],
131+	[WARN_CFLAGS="${WARN_CFLAGS} -Werror"]
132+)
133
134-# The test used in AX_COMPILER_FLAGS, generated using AC_LANG_PROGRAM, is
135+# The test used in AX_APPEND_COMPILE_FLAGS, generated using AC_LANG_PROGRAM, is
136 # written in such a way that it triggers a -Wold-style-definition warning.  So
137-# if the user has -Werror in their CFLAGS, that warning flag will end up
138-# disabled, because the test program will not build.
139+# this warning always ends up disabled if we put it there, because the test
140+# program does not build.
141 #
142 # Enable it here unconditionally.  It is supported by GCC >= 4.8 and by Clang
143 # (it is accepted for compatibility although it has no effect), and there is
144 # not reason to not want it.
145
146-AM_CFLAGS="${AM_CFLAGS} -Wold-style-definition"
147+WARN_CFLAGS="${WARN_CFLAGS} -Wold-style-definition"
148
149-# We want this one to always be an error.
150-AM_CFLAGS="${AM_CFLAGS} -Werror=implicit-function-declaration"
151+# CFLAGS from AX_APPEND_COMPILE_FLAGS.
152+AM_CFLAGS="${AM_CFLAGS} ${WARN_CFLAGS}"
153
154 # Done for AM_CFLAGS.
155 AC_SUBST(AM_CFLAGS)
156diff --git a/m4/ax_compiler_flags.m4 b/m4/ax_compiler_flags.m4
157deleted file mode 100644
158index ddb0456c4..000000000
159--- a/m4/ax_compiler_flags.m4
160+++ /dev/null
161@@ -1,158 +0,0 @@
162-# ===========================================================================
163-#    https://www.gnu.org/software/autoconf-archive/ax_compiler_flags.html
164-# ===========================================================================
165-#
166-# SYNOPSIS
167-#
168-#   AX_COMPILER_FLAGS([CFLAGS-VARIABLE], [LDFLAGS-VARIABLE], [IS-RELEASE], [EXTRA-BASE-CFLAGS], [EXTRA-YES-CFLAGS], [UNUSED], [UNUSED], [UNUSED], [EXTRA-BASE-LDFLAGS], [EXTRA-YES-LDFLAGS], [UNUSED], [UNUSED], [UNUSED])
169-#
170-# DESCRIPTION
171-#
172-#   Check for the presence of an --enable-compile-warnings option to
173-#   configure, defaulting to "error" in normal operation, or "yes" if
174-#   IS-RELEASE is equal to "yes".  Return the value in the variable
175-#   $ax_enable_compile_warnings.
176-#
177-#   Depending on the value of --enable-compile-warnings, different compiler
178-#   warnings are checked to see if they work with the current compiler and,
179-#   if so, are appended to CFLAGS-VARIABLE and LDFLAGS-VARIABLE.  This
180-#   allows a consistent set of baseline compiler warnings to be used across
181-#   a code base, irrespective of any warnings enabled locally by individual
182-#   developers.  By standardising the warnings used by all developers of a
183-#   project, the project can commit to a zero-warnings policy, using -Werror
184-#   to prevent compilation if new warnings are introduced.  This makes
185-#   catching bugs which are flagged by warnings a lot easier.
186-#
187-#   By providing a consistent --enable-compile-warnings argument across all
188-#   projects using this macro, continuous integration systems can easily be
189-#   configured the same for all projects.  Automated systems or build
190-#   systems aimed at beginners may want to pass the --disable-Werror
191-#   argument to unconditionally prevent warnings being fatal.
192-#
193-#   --enable-compile-warnings can take the values:
194-#
195-#    * no:      Base compiler warnings only; not even -Wall.
196-#    * yes:     The above, plus a broad range of useful warnings.
197-#    * error:   The above, plus -Werror so that all warnings are fatal.
198-#               Use --disable-Werror to override this and disable fatal
199-#               warnings.
200-#
201-#   The set of base and enabled flags can be augmented using the
202-#   EXTRA-*-CFLAGS and EXTRA-*-LDFLAGS variables, which are tested and
203-#   appended to the output variable if --enable-compile-warnings is not
204-#   "no". Flags should not be disabled using these arguments, as the entire
205-#   point of AX_COMPILER_FLAGS is to enforce a consistent set of useful
206-#   compiler warnings on code, using warnings which have been chosen for low
207-#   false positive rates.  If a compiler emits false positives for a
208-#   warning, a #pragma should be used in the code to disable the warning
209-#   locally. See:
210-#
211-#     https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
212-#
213-#   The EXTRA-* variables should only be used to supply extra warning flags,
214-#   and not general purpose compiler flags, as they are controlled by
215-#   configure options such as --disable-Werror.
216-#
217-#   IS-RELEASE can be used to disable -Werror when making a release, which
218-#   is useful for those hairy moments when you just want to get the release
219-#   done as quickly as possible.  Set it to "yes" to disable -Werror. By
220-#   default, it uses the value of $ax_is_release, so if you are using the
221-#   AX_IS_RELEASE macro, there is no need to pass this parameter. For
222-#   example:
223-#
224-#     AX_IS_RELEASE([git-directory])
225-#     AX_COMPILER_FLAGS()
226-#
227-#   CFLAGS-VARIABLE defaults to WARN_CFLAGS, and LDFLAGS-VARIABLE defaults
228-#   to WARN_LDFLAGS.  Both variables are AC_SUBST-ed by this macro, but must
229-#   be manually added to the CFLAGS and LDFLAGS variables for each target in
230-#   the code base.
231-#
232-#   If C++ language support is enabled with AC_PROG_CXX, which must occur
233-#   before this macro in configure.ac, warning flags for the C++ compiler
234-#   are AC_SUBST-ed as WARN_CXXFLAGS, and must be manually added to the
235-#   CXXFLAGS variables for each target in the code base.  EXTRA-*-CFLAGS can
236-#   be used to augment the base and enabled flags.
237-#
238-#   Warning flags for g-ir-scanner (from GObject Introspection) are
239-#   AC_SUBST-ed as WARN_SCANNERFLAGS.  This variable must be manually added
240-#   to the SCANNERFLAGS variable for each GIR target in the code base.  If
241-#   extra g-ir-scanner flags need to be enabled, the AX_COMPILER_FLAGS_GIR
242-#   macro must be invoked manually.
243-#
244-#   AX_COMPILER_FLAGS may add support for other tools in future, in addition
245-#   to the compiler and linker.  No extra EXTRA-* variables will be added
246-#   for those tools, and all extra support will still use the single
247-#   --enable-compile-warnings configure option.  For finer grained control
248-#   over the flags for individual tools, use AX_COMPILER_FLAGS_CFLAGS,
249-#   AX_COMPILER_FLAGS_LDFLAGS and AX_COMPILER_FLAGS_* for new tools.
250-#
251-#   The UNUSED variables date from a previous version of this macro, and are
252-#   automatically appended to the preceding non-UNUSED variable. They should
253-#   be left empty in new uses of the macro.
254-#
255-# LICENSE
256-#
257-#   Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
258-#   Copyright (c) 2015 David King <amigadave@amigadave.com>
259-#
260-#   Copying and distribution of this file, with or without modification, are
261-#   permitted in any medium without royalty provided the copyright notice
262-#   and this notice are preserved.  This file is offered as-is, without any
263-#   warranty.
264-
265-#serial 14
266-
267-# _AX_COMPILER_FLAGS_LANG([LANGNAME])
268-m4_defun([_AX_COMPILER_FLAGS_LANG],
269-[m4_ifdef([_AX_COMPILER_FLAGS_LANG_]$1[_enabled], [],
270-          [m4_define([_AX_COMPILER_FLAGS_LANG_]$1[_enabled], [])dnl
271-           AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_]$1[FLAGS])])dnl
272-])
273-
274-AC_DEFUN([AX_COMPILER_FLAGS],[
275-    # C support is enabled by default.
276-    _AX_COMPILER_FLAGS_LANG([C])
277-    # Only enable C++ support if AC_PROG_CXX is called. The redefinition of
278-    # AC_PROG_CXX is so that a fatal error is emitted if this macro is called
279-    # before AC_PROG_CXX, which would otherwise cause no C++ warnings to be
280-    # checked.
281-    AC_PROVIDE_IFELSE([AC_PROG_CXX],
282-                      [_AX_COMPILER_FLAGS_LANG([CXX])],
283-                      [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AX_COMPILER_FLAGS_LANG([CXX])])])
284-    AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_LDFLAGS])
285-
286-    # Default value for IS-RELEASE is $ax_is_release
287-    ax_compiler_flags_is_release=m4_tolower(m4_normalize(ifelse([$3],,
288-                                                                [$ax_is_release],
289-                                                                [$3])))
290-
291-    AC_ARG_ENABLE([compile-warnings],
292-                  AS_HELP_STRING([--enable-compile-warnings=@<:@no/yes/error@:>@],
293-                                 [Enable compiler warnings and errors]),,
294-                  [AS_IF([test "$ax_compiler_flags_is_release" = "yes"],
295-                         [enable_compile_warnings="yes"],
296-                         [enable_compile_warnings="error"])])
297-    AC_ARG_ENABLE([Werror],
298-                  AS_HELP_STRING([--disable-Werror],
299-                                 [Unconditionally make all compiler warnings non-fatal]),,
300-                  [enable_Werror=maybe])
301-
302-    # Return the user's chosen warning level
303-    AS_IF([test "$enable_Werror" = "no" -a \
304-                "$enable_compile_warnings" = "error"],[
305-        enable_compile_warnings="yes"
306-    ])
307-
308-    ax_enable_compile_warnings=$enable_compile_warnings
309-
310-    AX_COMPILER_FLAGS_CFLAGS([$1],[$ax_compiler_flags_is_release],
311-                             [$4],[$5 $6 $7 $8])
312-    m4_ifdef([_AX_COMPILER_FLAGS_LANG_CXX_enabled],
313-             [AX_COMPILER_FLAGS_CXXFLAGS([WARN_CXXFLAGS],
314-                                         [$ax_compiler_flags_is_release],
315-                                         [$4],[$5 $6 $7 $8])])
316-    AX_COMPILER_FLAGS_LDFLAGS([$2],[$ax_compiler_flags_is_release],
317-                              [$9],[$10 $11 $12 $13])
318-    AX_COMPILER_FLAGS_GIR([WARN_SCANNERFLAGS],[$ax_compiler_flags_is_release])
319-])dnl AX_COMPILER_FLAGS
320diff --git a/m4/ax_compiler_flags_cflags.m4 b/m4/ax_compiler_flags_cflags.m4
321deleted file mode 100644
322index 916f91837..000000000
323--- a/m4/ax_compiler_flags_cflags.m4
324+++ /dev/null
325@@ -1,161 +0,0 @@
326-# =============================================================================
327-#  https://www.gnu.org/software/autoconf-archive/ax_compiler_flags_cflags.html
328-# =============================================================================
329-#
330-# SYNOPSIS
331-#
332-#   AX_COMPILER_FLAGS_CFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS])
333-#
334-# DESCRIPTION
335-#
336-#   Add warning flags for the C compiler to VARIABLE, which defaults to
337-#   WARN_CFLAGS.  VARIABLE is AC_SUBST-ed by this macro, but must be
338-#   manually added to the CFLAGS variable for each target in the code base.
339-#
340-#   This macro depends on the environment set up by AX_COMPILER_FLAGS.
341-#   Specifically, it uses the value of $ax_enable_compile_warnings to decide
342-#   which flags to enable.
343-#
344-# LICENSE
345-#
346-#   Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
347-#   Copyright (c) 2017, 2018 Reini Urban <rurban@cpan.org>
348-#
349-#   Copying and distribution of this file, with or without modification, are
350-#   permitted in any medium without royalty provided the copyright notice
351-#   and this notice are preserved.  This file is offered as-is, without any
352-#   warranty.
353-
354-#serial 17
355-
356-AC_DEFUN([AX_COMPILER_FLAGS_CFLAGS],[
357-    AC_REQUIRE([AC_PROG_SED])
358-    AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS])
359-    AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
360-    AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
361-
362-    # Variable names
363-    m4_define([ax_warn_cflags_variable],
364-              [m4_normalize(ifelse([$1],,[WARN_CFLAGS],[$1]))])
365-
366-    AC_LANG_PUSH([C])
367-
368-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
369-      [#ifndef __cplusplus
370-       #error "no C++"
371-       #endif]])],
372-      [ax_compiler_cxx=yes;],
373-      [ax_compiler_cxx=no;])
374-
375-    # Always pass -Werror=unknown-warning-option to get Clang to fail on bad
376-    # flags, otherwise they are always appended to the warn_cflags variable, and
377-    # Clang warns on them for every compilation unit.
378-    # If this is passed to GCC, it will explode, so the flag must be enabled
379-    # conditionally.
380-    AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
381-        ax_compiler_flags_test="-Werror=unknown-warning-option"
382-    ],[
383-        ax_compiler_flags_test=""
384-    ])
385-
386-    # Check that -Wno-suggest-attribute=format is supported
387-    AX_CHECK_COMPILE_FLAG([-Wno-suggest-attribute=format],[
388-        ax_compiler_no_suggest_attribute_flags="-Wno-suggest-attribute=format"
389-    ],[
390-        ax_compiler_no_suggest_attribute_flags=""
391-    ])
392-
393-    # Base flags
394-    AX_APPEND_COMPILE_FLAGS([ dnl
395-        -fno-strict-aliasing dnl
396-        $3 dnl
397-    ],ax_warn_cflags_variable,[$ax_compiler_flags_test])
398-
399-    AS_IF([test "$ax_enable_compile_warnings" != "no"],[
400-        if test "$ax_compiler_cxx" = "no" ; then
401-            # C-only flags. Warn in C++
402-            AX_APPEND_COMPILE_FLAGS([ dnl
403-                -Wnested-externs dnl
404-                -Wmissing-prototypes dnl
405-                -Wstrict-prototypes dnl
406-                -Wdeclaration-after-statement dnl
407-                -Wimplicit-function-declaration dnl
408-                -Wold-style-definition dnl
409-                -Wjump-misses-init dnl
410-            ],ax_warn_cflags_variable,[$ax_compiler_flags_test])
411-        fi
412-
413-        # "yes" flags
414-        AX_APPEND_COMPILE_FLAGS([ dnl
415-            -Wall dnl
416-            -Wextra dnl
417-            -Wundef dnl
418-            -Wwrite-strings dnl
419-            -Wpointer-arith dnl
420-            -Wmissing-declarations dnl
421-            -Wredundant-decls dnl
422-            -Wno-unused-parameter dnl
423-            -Wno-missing-field-initializers dnl
424-            -Wformat=2 dnl
425-            -Wcast-align dnl
426-            -Wformat-nonliteral dnl
427-            -Wformat-security dnl
428-            -Wsign-compare dnl
429-            -Wstrict-aliasing dnl
430-            -Wshadow dnl
431-            -Winline dnl
432-            -Wpacked dnl
433-            -Wmissing-format-attribute dnl
434-            -Wmissing-noreturn dnl
435-            -Winit-self dnl
436-            -Wredundant-decls dnl
437-            -Wmissing-include-dirs dnl
438-            -Wunused-but-set-variable dnl
439-            -Warray-bounds dnl
440-            -Wreturn-type dnl
441-            -Wswitch-enum dnl
442-            -Wswitch-default dnl
443-            -Wduplicated-cond dnl
444-            -Wduplicated-branches dnl
445-            -Wlogical-op dnl
446-            -Wrestrict dnl
447-            -Wnull-dereference dnl
448-            -Wdouble-promotion dnl
449-            $4 dnl
450-            $5 dnl
451-            $6 dnl
452-            $7 dnl
453-        ],ax_warn_cflags_variable,[$ax_compiler_flags_test])
454-    ])
455-    AS_IF([test "$ax_enable_compile_warnings" = "error"],[
456-        # "error" flags; -Werror has to be appended unconditionally because
457-        # it's not possible to test for
458-        #
459-        # suggest-attribute=format is disabled because it gives too many false
460-        # positives
461-        AX_APPEND_FLAG([-Werror],ax_warn_cflags_variable)
462-
463-        AX_APPEND_COMPILE_FLAGS([ dnl
464-            [$ax_compiler_no_suggest_attribute_flags] dnl
465-        ],ax_warn_cflags_variable,[$ax_compiler_flags_test])
466-    ])
467-
468-    # In the flags below, when disabling specific flags, always add *both*
469-    # -Wno-foo and -Wno-error=foo. This fixes the situation where (for example)
470-    # we enable -Werror, disable a flag, and a build bot passes CFLAGS=-Wall,
471-    # which effectively turns that flag back on again as an error.
472-    for flag in $ax_warn_cflags_variable; do
473-        AS_CASE([$flag],
474-                [-Wno-*=*],[],
475-                [-Wno-*],[
476-                    AX_APPEND_COMPILE_FLAGS([-Wno-error=$(AS_ECHO([$flag]) | $SED 's/^-Wno-//')],
477-                                            ax_warn_cflags_variable,
478-                                            [$ax_compiler_flags_test])
479-                ])
480-    done
481-
482-    AC_LANG_POP([C])
483-
484-    # Substitute the variables
485-    AC_SUBST(ax_warn_cflags_variable)
486-])dnl AX_COMPILER_FLAGS
487diff --git a/m4/ax_compiler_flags_gir.m4 b/m4/ax_compiler_flags_gir.m4
488deleted file mode 100644
489index 5b4924a20..000000000
490--- a/m4/ax_compiler_flags_gir.m4
491+++ /dev/null
492@@ -1,60 +0,0 @@
493-# ===========================================================================
494-#  https://www.gnu.org/software/autoconf-archive/ax_compiler_flags_gir.html
495-# ===========================================================================
496-#
497-# SYNOPSIS
498-#
499-#   AX_COMPILER_FLAGS_GIR([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS])
500-#
501-# DESCRIPTION
502-#
503-#   Add warning flags for the g-ir-scanner (from GObject Introspection) to
504-#   VARIABLE, which defaults to WARN_SCANNERFLAGS.  VARIABLE is AC_SUBST-ed
505-#   by this macro, but must be manually added to the SCANNERFLAGS variable
506-#   for each GIR target in the code base.
507-#
508-#   This macro depends on the environment set up by AX_COMPILER_FLAGS.
509-#   Specifically, it uses the value of $ax_enable_compile_warnings to decide
510-#   which flags to enable.
511-#
512-# LICENSE
513-#
514-#   Copyright (c) 2015 Philip Withnall <philip@tecnocode.co.uk>
515-#
516-#   Copying and distribution of this file, with or without modification, are
517-#   permitted in any medium without royalty provided the copyright notice
518-#   and this notice are preserved.  This file is offered as-is, without any
519-#   warranty.
520-
521-#serial 6
522-
523-AC_DEFUN([AX_COMPILER_FLAGS_GIR],[
524-    AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
525-
526-    # Variable names
527-    m4_define([ax_warn_scannerflags_variable],
528-              [m4_normalize(ifelse([$1],,[WARN_SCANNERFLAGS],[$1]))])
529-
530-    # Base flags
531-    AX_APPEND_FLAG([$3],ax_warn_scannerflags_variable)
532-
533-    AS_IF([test "$ax_enable_compile_warnings" != "no"],[
534-        # "yes" flags
535-        AX_APPEND_FLAG([ dnl
536-            --warn-all dnl
537-            $4 dnl
538-            $5 dnl
539-            $6 dnl
540-            $7 dnl
541-        ],ax_warn_scannerflags_variable)
542-    ])
543-    AS_IF([test "$ax_enable_compile_warnings" = "error"],[
544-        # "error" flags
545-        AX_APPEND_FLAG([ dnl
546-            --warn-error dnl
547-        ],ax_warn_scannerflags_variable)
548-    ])
549-
550-    # Substitute the variables
551-    AC_SUBST(ax_warn_scannerflags_variable)
552-])dnl AX_COMPILER_FLAGS
553diff --git a/m4/ax_compiler_flags_ldflags.m4 b/m4/ax_compiler_flags_ldflags.m4
554deleted file mode 100644
555index 976d1198d..000000000
556--- a/m4/ax_compiler_flags_ldflags.m4
557+++ /dev/null
558@@ -1,111 +0,0 @@
559-# ==============================================================================
560-#  https://www.gnu.org/software/autoconf-archive/ax_compiler_flags_ldflags.html
561-# ==============================================================================
562-#
563-# SYNOPSIS
564-#
565-#   AX_COMPILER_FLAGS_LDFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS])
566-#
567-# DESCRIPTION
568-#
569-#   Add warning flags for the linker to VARIABLE, which defaults to
570-#   WARN_LDFLAGS.  VARIABLE is AC_SUBST-ed by this macro, but must be
571-#   manually added to the LDFLAGS variable for each target in the code base.
572-#
573-#   This macro depends on the environment set up by AX_COMPILER_FLAGS.
574-#   Specifically, it uses the value of $ax_enable_compile_warnings to decide
575-#   which flags to enable.
576-#
577-# LICENSE
578-#
579-#   Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
580-#   Copyright (c) 2017, 2018 Reini Urban <rurban@cpan.org>
581-#
582-#   Copying and distribution of this file, with or without modification, are
583-#   permitted in any medium without royalty provided the copyright notice
584-#   and this notice are preserved.  This file is offered as-is, without any
585-#   warranty.
586-
587-#serial 9
588-
589-AC_DEFUN([AX_COMPILER_FLAGS_LDFLAGS],[
590-    AX_REQUIRE_DEFINED([AX_APPEND_LINK_FLAGS])
591-    AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
592-    AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
593-    AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
594-
595-    # Variable names
596-    m4_define([ax_warn_ldflags_variable],
597-              [m4_normalize(ifelse([$1],,[WARN_LDFLAGS],[$1]))])
598-
599-    # Always pass -Werror=unknown-warning-option to get Clang to fail on bad
600-    # flags, otherwise they are always appended to the warn_ldflags variable,
601-    # and Clang warns on them for every compilation unit.
602-    # If this is passed to GCC, it will explode, so the flag must be enabled
603-    # conditionally.
604-    AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
605-        ax_compiler_flags_test="-Werror=unknown-warning-option"
606-    ],[
607-        ax_compiler_flags_test=""
608-    ])
609-
610-    AX_CHECK_LINK_FLAG([-Wl,--as-needed], [
611-        AX_APPEND_LINK_FLAGS([-Wl,--as-needed],
612-          [AM_LDFLAGS],[$ax_compiler_flags_test])
613-    ])
614-    AX_CHECK_LINK_FLAG([-Wl,-z,relro], [
615-        AX_APPEND_LINK_FLAGS([-Wl,-z,relro],
616-          [AM_LDFLAGS],[$ax_compiler_flags_test])
617-    ])
618-    AX_CHECK_LINK_FLAG([-Wl,-z,now], [
619-        AX_APPEND_LINK_FLAGS([-Wl,-z,now],
620-          [AM_LDFLAGS],[$ax_compiler_flags_test])
621-    ])
622-    AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [
623-        AX_APPEND_LINK_FLAGS([-Wl,-z,noexecstack],
624-          [AM_LDFLAGS],[$ax_compiler_flags_test])
625-    ])
626-    # textonly, retpolineplt not yet
627-
628-    # macOS and cygwin linker do not have --as-needed
629-    AX_CHECK_LINK_FLAG([-Wl,--no-as-needed], [
630-        ax_compiler_flags_as_needed_option="-Wl,--no-as-needed"
631-    ], [
632-        ax_compiler_flags_as_needed_option=""
633-    ])
634-
635-    # macOS linker speaks with a different accent
636-    ax_compiler_flags_fatal_warnings_option=""
637-    AX_CHECK_LINK_FLAG([-Wl,--fatal-warnings], [
638-        ax_compiler_flags_fatal_warnings_option="-Wl,--fatal-warnings"
639-    ])
640-    AX_CHECK_LINK_FLAG([-Wl,-fatal_warnings], [
641-        ax_compiler_flags_fatal_warnings_option="-Wl,-fatal_warnings"
642-    ])
643-
644-    # Base flags
645-    AX_APPEND_LINK_FLAGS([ dnl
646-        $ax_compiler_flags_as_needed_option dnl
647-        $3 dnl
648-    ],ax_warn_ldflags_variable,[$ax_compiler_flags_test])
649-
650-    AS_IF([test "$ax_enable_compile_warnings" != "no"],[
651-        # "yes" flags
652-        AX_APPEND_LINK_FLAGS([$4 $5 $6 $7],
653-                                ax_warn_ldflags_variable,
654-                                [$ax_compiler_flags_test])
655-    ])
656-    AS_IF([test "$ax_enable_compile_warnings" = "error"],[
657-        # "error" flags; -Werror has to be appended unconditionally because
658-        # it's not possible to test for
659-        #
660-        # suggest-attribute=format is disabled because it gives too many false
661-        # positives
662-        AX_APPEND_LINK_FLAGS([ dnl
663-            $ax_compiler_flags_fatal_warnings_option dnl
664-        ],ax_warn_ldflags_variable,[$ax_compiler_flags_test])
665-    ])
666-
667-    # Substitute the variables
668-    AC_SUBST(ax_warn_ldflags_variable)
669-])dnl AX_COMPILER_FLAGS
670