summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid King <amigadave@amigadave.com>2015-01-29 09:30:40 +0000
committerDavid King <amigadave@amigadave.com>2015-01-29 21:55:42 +0000
commit64d86bbc375591b3a88e943aceeaf8e17e35993c (patch)
tree35a68b9d459bc303cfa37f0d50a7c3fa9ee50f2f
parent6a4b321028b18b6c9c806c1c928ea0fe5f6d2d99 (diff)
downloadcheese-wip/kill-gnome-common.tar.gz
Use AX_COMPILER_FLAGSwip/kill-gnome-common
Drop use of GNOME_COMPILE_WARNINGS. https://wiki.gnome.org/Projects/GnomeCommon/Migration
-rw-r--r--Makefile.am40
-rw-r--r--configure.ac4
-rw-r--r--m4/ax_append_compile_flags.m465
-rw-r--r--m4/ax_append_flag.m471
-rw-r--r--m4/ax_check_compile_flag.m474
-rw-r--r--m4/ax_compiler_flags.m499
-rw-r--r--m4/ax_compiler_flags_cflags.m4127
-rw-r--r--m4/ax_compiler_flags_gir.m468
-rw-r--r--m4/ax_compiler_flags_ldflags.m490
9 files changed, 621 insertions, 17 deletions
diff --git a/Makefile.am b/Makefile.am
index 1db07f11..4c217099 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -48,7 +48,6 @@ AM_CPPFLAGS = \
-I$(top_builddir) \
$(CHEESE_CFLAGS) \
$(CHEESE_GTK_FLAGS) \
- $(CHEESE_WFLAGS) \
$(WARN_CFLAGS)
AM_VALAFLAGS = \
@@ -75,8 +74,7 @@ lib_LTLIBRARIES = libcheese.la libcheese-gtk.la
libcheese_gtk_la_CFLAGS = \
$(CHEESE_CFLAGS) \
- $(CHEESE_GTK_CFLAGS) \
- $(CHEESE_WFLAGS)
+ $(CHEESE_GTK_CFLAGS)
libcheese_gtk_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
@@ -95,7 +93,8 @@ libcheese_gtk_la_LDFLAGS = \
-version-info $(LIBCHEESE_GTK_LT_VERSION) \
-export-symbols $(top_srcdir)/libcheese/cheese-gtk.symbols \
-no-undefined \
- $(AM_LDFLAGS)
+ $(AM_LDFLAGS) \
+ $(WARN_LDFLAGS)
libcheese_gtk_la_SOURCES = \
libcheese/cheese-avatar-chooser.c \
@@ -117,8 +116,7 @@ noinst_libcheese_gtk_headers = \
libcheese_la_CFLAGS = \
$(CHEESE_CFLAGS) \
- $(CHEESE_GTK_CFLAGS) \
- $(CHEESE_WFLAGS)
+ $(CHEESE_GTK_CFLAGS)
libcheese_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
@@ -131,7 +129,8 @@ libcheese_la_LIBADD = \
libcheese_la_LDFLAGS = \
-version-info $(LIBCHEESE_LT_VERSION) \
- $(AM_LDFLAGS)
+ $(AM_LDFLAGS) \
+ $(WARN_LDFLAGS)
libcheese_la_SOURCES = \
libcheese/cheese-enums.c \
@@ -165,7 +164,7 @@ cheese_HEADERS = \
if HAVE_INTROSPECTION
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_COMPILER_ARGS = --includedir=$(top_srcdir)
-INTROSPECTION_SCANNER_ARGS = --add-include-path=$(top_srcdir) --warn-all
+INTROSPECTION_SCANNER_ARGS = --add-include-path=$(top_srcdir)
INTROSPECTION_GIRS = Cheese-3.0.gir
@@ -173,7 +172,8 @@ Cheese-3.0.gir: libcheese.la
Cheese_3_0_gir_CFLAGS = \
-I$(top_srcdir)/libcheese \
-I$(top_builddir)/libcheese \
- $(CHEESE_CFLAGS)
+ $(CHEESE_CFLAGS) \
+ $(WARN_CFLAGS)
Cheese_3_0_gir_FILES = \
$(libcheese_la_SOURCES) \
$(noinst_libcheese_headers) \
@@ -183,7 +183,10 @@ Cheese_3_0_gir_INCLUDES = \
Clutter-1.0 \
GdkPixbuf-2.0
Cheese_3_0_gir_LIBS = libcheese.la
-Cheese_3_0_gir_SCANNERFLAGS = --verbose --warn-all --pkg-export cheese
+Cheese_3_0_gir_SCANNERFLAGS = \
+ --verbose \
+ $(WARN_SCANNERFLAGS) \
+ --pkg-export cheese
girdir = $(datadir)/gir-1.0
gir_DATA = $(INTROSPECTION_GIRS)
@@ -246,7 +249,8 @@ cheese_LDADD = \
libcheese.la \
libcheese-gtk.la \
$(CHEESE_LIBS) \
- $(CHEESE_GTK_LIBS)
+ $(CHEESE_GTK_LIBS) \
+ $(WARN_LDFLAGS)
libexec_PROGRAMS = \
gnome-camera-service
@@ -289,7 +293,8 @@ gnome_camera_service_CFLAGS = \
gnome_camera_service_LDADD = \
libcheese-gtk.la \
- $(CHEESE_GTK_LIBS)
+ $(CHEESE_GTK_LIBS) \
+ $(WARN_LDFLAGS)
EXAMPLES = \
tests/cheese-test-camera \
@@ -333,29 +338,34 @@ tests_test_webcam_button_CPPFLAGS = $(EXAMPLES_CPPFLAGS)
tests_cheese_test_camera_LDADD = \
$(CHEESE_LIBS) \
$(CHEESE_GTK_LIBS) \
+ $(WARN_LDFLAGS) \
libcheese.la
tests_cheese_test_chooser_LDADD = \
$(CHEESE_LIBS) \
$(CHEESE_GTK_LIBS) \
+ $(WARN_LDFLAGS) \
libcheese.la \
libcheese-gtk.la
tests_cheese_test_flash_LDADD = \
$(CHEESE_LIBS) \
$(CHEESE_GTK_LIBS) \
+ $(WARN_LDFLAGS) \
libcheese.la \
libcheese-gtk.la
tests_cheese_test_monitor_LDADD = \
$(CHEESE_LIBS) \
$(CHEESE_GTK_LIBS) \
+ $(WARN_LDFLAGS) \
libcheese.la \
libcheese-gtk.la
tests_cheese_test_widget_LDADD = \
$(CHEESE_LIBS) \
$(CHEESE_GTK_LIBS) \
+ $(WARN_LDFLAGS) \
libcheese.la \
libcheese-gtk.la
-tests_test_service_client_LDADD = $(CHEESE_GTK_LIBS)
-tests_test_webcam_button_LDADD = $(XTEST_LIBS)
+tests_test_service_client_LDADD = $(CHEESE_GTK_LIBS) $(WARN_LDFLAGS)
+tests_test_webcam_button_LDADD = $(XTEST_LIBS) $(WARN_LDFLAGS)
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
@@ -429,6 +439,7 @@ tests_test_libcheese_gtk_CPPFLAGS = $(EXAMPLES_CPPFLAGS)
tests_test_libcheese_gtk_LDADD = \
$(CHEESE_LIBS) \
$(CHEESE_GTK_LIBS) \
+ $(WARN_LDFLAGS) \
libcheese-gtk.la \
libcheese.la
@@ -437,6 +448,7 @@ tests_test_libcheese_SOURCES = \
tests_test_libcheese_CPPFLAGS = $(EXAMPLES_CPPFLAGS)
tests_test_libcheese_LDADD = \
$(CHEESE_LIBS) \
+ $(WARN_LDFLAGS) \
libcheese.la
if CHEESE_ENABLE_TESTS
diff --git a/configure.ac b/configure.ac
index 8f702f04..b914a825 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,9 +30,7 @@ LT_LIB_M
PKG_PROG_PKG_CONFIG([0.24])
-AC_SUBST([CHEESE_WFLAGS], ["-Wall"])
-
-GNOME_COMPILE_WARNINGS([maximum])
+AX_COMPILER_FLAGS([WARN_CFLAGS], [WARN_LDFLAGS], [no])
#*******************************************************************************
# Libraries
diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4
new file mode 100644
index 00000000..dc7b8660
--- /dev/null
+++ b/m4/ax_append_compile_flags.m4
@@ -0,0 +1,65 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS])
+#
+# DESCRIPTION
+#
+# For every FLAG1, FLAG2 it is checked whether the compiler works with the
+# flag. If it does, the flag is added FLAGS-VARIABLE
+#
+# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+# CFLAGS) is used. During the check the flag is always added to the
+# current language's flags.
+#
+# If EXTRA-FLAGS is defined, it is added to the current language's default
+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
+# force the compiler to issue an error when a bad flag is given.
+#
+# NOTE: This macro depends on the AX_APPEND_FLAG and
+# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
+# AX_APPEND_LINK_FLAGS.
+#
+# LICENSE
+#
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 4
+
+AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
+[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+for flag in $1; do
+ AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3])
+done
+])dnl AX_APPEND_COMPILE_FLAGS
diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4
new file mode 100644
index 00000000..d26286c1
--- /dev/null
+++ b/m4/ax_append_flag.m4
@@ -0,0 +1,71 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
+#
+# DESCRIPTION
+#
+# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
+# added in between.
+#
+# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
+# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
+# FLAG.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 4
+
+AC_DEFUN([AX_APPEND_FLAG],
+[dnl
+AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
+AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
+AS_VAR_SET_IF(FLAGS,[
+ AS_CASE([AS_VAR_GET(FLAGS)],
+ ["* $1 *|*$1"],[AC_RUN_LOG([: FLAGS already contains $1])],
+ [
+ AS_VAR_APPEND(FLAGS," $1")
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
+ ])
+ ],
+ [
+ AS_VAR_SET(FLAGS,[$1])
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
+ ])
+AS_VAR_POPDEF([FLAGS])dnl
+])dnl AX_APPEND_FLAG
diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4
new file mode 100644
index 00000000..ca363971
--- /dev/null
+++ b/m4/ax_check_compile_flag.m4
@@ -0,0 +1,74 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+# Check whether the given FLAG works with the current language's compiler
+# or gives an error. (Warnings, however, are ignored)
+#
+# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+# success/failure.
+#
+# If EXTRA-FLAGS is defined, it is added to the current language's default
+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
+# force the compiler to issue an error when a bad flag is given.
+#
+# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 4
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+ AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+ [AS_VAR_SET(CACHEVAR,[yes])],
+ [AS_VAR_SET(CACHEVAR,[no])])
+ _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+ [m4_default([$2], :)],
+ [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
diff --git a/m4/ax_compiler_flags.m4 b/m4/ax_compiler_flags.m4
new file mode 100644
index 00000000..27d313dd
--- /dev/null
+++ b/m4/ax_compiler_flags.m4
@@ -0,0 +1,99 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPILER_FLAGS([CFLAGS-VARIABLE], [LDFLAGS-VARIABLE], [IS-RELEASE], [EXTRA-BASE-CFLAGS], [EXTRA-MINIMUM-CFLAGS], [EXTRA-YES-CFLAGS], [EXTRA-MAXIMUM-CFLAGS], [EXTRA-ERROR-CFLAGS], [EXTRA-BASE-LDFLAGS], [EXTRA-MINIMUM-LDFLAGS], [EXTRA-YES-LDFLAGS], [EXTRA-MAXIMUM-LDFLAGS], [EXTRA-ERROR-LDFLAGS])
+#
+# DESCRIPTION
+#
+# Check for the presence of an --enable-compile-warnings option to
+# configure, defaulting to "error" in normal operation, or "yes" if
+# IS-RELEASE is equal to "yes". Return the value in the variable
+# $ax_enable_compile_warnings.
+#
+# Depending on the value of --enable-compile-warnings, different compiler
+# warnings are checked to see if they work with the current compiler and,
+# if so, are appended to CFLAGS-VARIABLE and LDFLAGS-VARIABLE. This
+# allows a consistent set of baseline compiler warnings to be used across
+# a code base, irrespective of any warnings enabled locally by individual
+# developers. By standardising the warnings used by all developers of a
+# project, the project can commit to a zero-warnings policy, using -Werror
+# to prevent compilation if new warnings are introduced. This makes
+# catching bugs which are flagged by warnings a lot easier.
+#
+# By providing a consistent --enable-compile-warnings argument across all
+# projects using this macro, continuous integration systems can easily be
+# configured the same for all projects.
+#
+# --enable-compile-warnings can take the values:
+#
+# * no: Base compiler warnings only; not even -Wall.
+# * minimum: The above, plus minimal extra warnings such as -Wall.
+# * yes: The above, plus a broad range of useful warnings.
+# * maximum: The above, plus additional warnings which enforce a particular
+# coding style
+# * error: The above, plus -Werror so that all warnings are fatal.
+#
+# The set of flags enabled at each level can be augmented using the
+# EXTRA-*-CFLAGS and EXTRA-*-LDFLAGS variables. Flags should not be
+# disabled using these arguments, as the entire point of AX_COMPILER_FLAGS
+# is to enforce a consistent set of useful compiler warnings on code,
+# using warnings which have been chosen for low false positive rates. If
+# a compiler emits false positives for a warning, a #pragma should be used
+# in the code to disable the warning locally. See:
+#
+# https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
+#
+# IS-RELEASE can be used to disable -Werror when making a release, which
+# is useful for those hairy moments when you just want to get the release
+# done as quickly as possible. Set it to "yes" to disable -Werror.
+#
+# CFLAGS-VARIABLE defaults to WARN_CFLAGS, and LDFLAGS-VARIABLE defaults
+# to WARN_LDFLAGS. Both variables are AC_SUBST-ed by this macro, but must
+# be manually added to the CFLAGS and LDFLAGS variables for each target in
+# the code base.
+#
+# Warning flags for g-ir-scanner (from GObject Introspection) are
+# AC_SUBST-ed as WARN_SCANNERFLAGS. This variable must be manually added
+# to the SCANNERFLAGS variable for each GIR target in the code base. If
+# extra g-ir-scanner flags need to be enabled, the AX_COMPILER_FLAGS_GIR
+# macro must be invoked manually.
+#
+# AX_COMPILER_FLAGS may add support for other tools in future, in addition
+# to the compiler and linker. No extra EXTRA-* variables will be added
+# for those tools, and all extra support will still use the single
+# --enable-compile-warnings configure option. For finer grained control
+# over the flags for individual tools, use AX_COMPILER_FLAGS_CFLAGS,
+# AX_COMPILER_FLAGS_LDFLAGS and AX_COMPILER_FLAGS_* for new tools.
+#
+# LICENSE
+#
+# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
+#
+# 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 6
+
+AC_DEFUN([AX_COMPILER_FLAGS],[
+ AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_CFLAGS])
+ AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_LDFLAGS])
+
+ AC_ARG_ENABLE([compile-warnings],
+ AS_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
+ [Enable different levels of compiler warnings]),,
+ [AS_IF([test "$3" = "yes"],
+ [enable_compile_warnings="yes"],
+ [enable_compile_warnings="error"])])
+
+ # Return the user’s chosen warning level
+ ax_enable_compile_warnings=$enable_compile_warnings
+
+ AX_COMPILER_FLAGS_CFLAGS([$1],[$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
new file mode 100644
index 00000000..24c0b153
--- /dev/null
+++ b/m4/ax_compiler_flags_cflags.m4
@@ -0,0 +1,127 @@
+# ============================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_cflags.html
+# ============================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPILER_FLAGS_CFLAGS([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_CFLAGS. VARIABLE is AC_SUBST-ed by this macro, but must be
+# manually added to the CFLAGS 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) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
+#
+# 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_CFLAGS],[
+ 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_cflags_variable,
+ [m4_normalize(ifelse([$1],,[WARN_CFLAGS],[$1]))])
+
+ # 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.
+ # 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
+ $4 dnl
+ ],ax_warn_cflags_variable,[$ax_compiler_flags_test])
+
+ AS_IF([test "$ax_enable_compile_warnings" != "no"],[
+ # "minimum" flags
+ AX_APPEND_COMPILE_FLAGS([ dnl
+ -Wall dnl
+ $5 dnl
+ ],ax_warn_cflags_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
+ -Wnested-externs dnl
+ -Wwrite-strings dnl
+ -Wpointer-arith dnl
+ -Wmissing-declarations dnl
+ -Wmissing-prototypes dnl
+ -Wstrict-prototypes dnl
+ -Wredundant-decls dnl
+ -Wno-unused-parameter dnl
+ -Wno-missing-field-initializers dnl
+ -Wdeclaration-after-statement dnl
+ -Wformat=2 dnl
+ -Wold-style-definition 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
+ -Wimplicit-function-declaration dnl
+ -Wreturn-type dnl
+ $6 dnl
+ ],ax_warn_cflags_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
+ -Waggregate-return dnl
+ $7 dnl
+ ],ax_warn_cflags_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_cflags_variable)
+
+ AX_APPEND_COMPILE_FLAGS([ dnl
+ -Wno-suggest-attribute=format dnl
+ $8 dnl
+ ],ax_warn_cflags_variable,[$ax_compiler_flags_test])
+ ])
+
+ # Substitute the variables
+ AC_SUBST(ax_warn_cflags_variable)
+])dnl AX_COMPILER_FLAGS
diff --git a/m4/ax_compiler_flags_gir.m4 b/m4/ax_compiler_flags_gir.m4
new file mode 100644
index 00000000..f26a8d23
--- /dev/null
+++ b/m4/ax_compiler_flags_gir.m4
@@ -0,0 +1,68 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_gir.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPILER_FLAGS_GIR([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-MINIMUM-FLAGS], [EXTRA-YES-FLAGS], [EXTRA-MAXIMUM-FLAGS], [EXTRA-ERROR-FLAGS])
+#
+# DESCRIPTION
+#
+# Add warning flags for the g-ir-scanner (from GObject Introspection) to
+# VARIABLE, which defaults to WARN_SCANNERFLAGS. VARIABLE is AC_SUBST-ed
+# by this macro, but must be manually added to the SCANNERFLAGS variable
+# for each GIR 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 Philip Withnall <philip@tecnocode.co.uk>
+#
+# 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_GIR],[
+ AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+
+ # Variable names
+ m4_define(ax_warn_scannerflags_variable,
+ [m4_normalize(ifelse([$1],,[WARN_SCANNERFLAGS],[$1]))])
+
+ # Base flags
+ AX_APPEND_FLAG([$3],ax_warn_scannerflags_variable)
+
+ AS_IF([test "$ax_enable_compile_warnings" != "no"],[
+ # "minimum" flags
+ AX_APPEND_FLAG([ dnl
+ --warn-all dnl
+ $4 dnl
+ ],ax_warn_scannerflags_variable)
+ ])
+ AS_IF([test "$ax_enable_compile_warnings" != "no" -a \
+ "$ax_enable_compile_warnings" != "minimum"],[
+ # "yes" flags
+ AX_APPEND_FLAG([$5],ax_warn_scannerflags_variable)
+ ])
+ AS_IF([test "$ax_enable_compile_warnings" = "maximum" -o \
+ "$ax_enable_compile_warnings" = "error"],[
+ # "maximum" flags
+ AX_APPEND_FLAG([$6],ax_warn_scannerflags_variable)
+ ])
+ AS_IF([test "$ax_enable_compile_warnings" = "error"],[
+ # "error" flags
+ AX_APPEND_FLAG([ dnl
+ --warn-error dnl
+ $7 dnl
+ ],ax_warn_scannerflags_variable)
+ ])
+
+ # Substitute the variables
+ AC_SUBST(ax_warn_scannerflags_variable)
+])dnl AX_COMPILER_FLAGS
diff --git a/m4/ax_compiler_flags_ldflags.m4 b/m4/ax_compiler_flags_ldflags.m4
new file mode 100644
index 00000000..ad845c61
--- /dev/null
+++ b/m4/ax_compiler_flags_ldflags.m4
@@ -0,0 +1,90 @@
+# =============================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_ldflags.html
+# =============================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPILER_FLAGS_LDFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-MINIMUM-FLAGS], [EXTRA-YES-FLAGS], [EXTRA-MAXIMUM-FLAGS], [EXTRA-ERROR-FLAGS])
+#
+# DESCRIPTION
+#
+# Add warning flags for the linker to VARIABLE, which defaults to
+# WARN_LDFLAGS. VARIABLE is AC_SUBST-ed by this macro, but must be
+# manually added to the LDFLAGS 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) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
+#
+# 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_LDFLAGS],[
+ 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_ldflags_variable,
+ [m4_normalize(ifelse([$1],,[WARN_LDFLAGS],[$1]))])
+
+ # Always pass -Werror=unknown-warning-option to get Clang to fail on bad
+ # flags, otherwise they are always appended to the warn_ldflags 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
+ -Wl,--no-as-needed dnl
+ $3 dnl
+ ],ax_warn_ldflags_variable,[$ax_compiler_flags_test])
+
+ AS_IF([test "$ax_enable_compile_warnings" != "no"],[
+ # "minimum" flags
+ AX_APPEND_COMPILE_FLAGS([$4],
+ ax_warn_ldflags_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([$5],
+ ax_warn_ldflags_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([$6],
+ ax_warn_ldflags_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_COMPILE_FLAGS([ dnl
+ -Wl,--fatal-warnings dnl
+ $7 dnl
+ ],ax_warn_ldflags_variable,[$ax_compiler_flags_test])
+ ])
+
+ # Substitute the variables
+ AC_SUBST(ax_warn_ldflags_variable)
+])dnl AX_COMPILER_FLAGS