summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-04-06 13:38:52 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-04-06 13:38:52 +0100
commitf7215f58589693d498ac8f675aba9e6c14a06bcf (patch)
tree2bc8e21517d00e5fd95fe1bc58fb42f783b4a689 /m4
parent5af3fb342da510de94504d62996413d1ccebedae (diff)
configure.ac: use TP_COMPILER_WARNINGS
The set of warnings used is taken from telepathy-glib, plus -Wmissing-declarations which we already had. This results in the addition of the following warnings: sign-compare, nested-externs, pointer-arith, format-security, init-self.
Diffstat (limited to 'm4')
-rw-r--r--m4/Makefile.am3
-rw-r--r--m4/as-compiler-flag.m432
-rw-r--r--m4/tp-compiler-flag.m436
-rw-r--r--m4/tp-compiler-warnings.m440
4 files changed, 78 insertions, 33 deletions
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 313f362a0..1607f74ce 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -1,4 +1,5 @@
EXTRA_DIST = \
- as-compiler-flag.m4 \
+ tp-compiler-flag.m4 \
+ tp-compiler-warnings.m4 \
compiler.m4 \
ax_config_dir.m4
diff --git a/m4/as-compiler-flag.m4 b/m4/as-compiler-flag.m4
index 605708a5a..8b1378917 100644
--- a/m4/as-compiler-flag.m4
+++ b/m4/as-compiler-flag.m4
@@ -1,33 +1 @@
-dnl as-compiler-flag.m4 0.1.0
-
-dnl autostars m4 macro for detection of compiler flags
-
-dnl David Schleef <ds@schleef.org>
-
-dnl $Id: as-compiler-flag.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $
-
-dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
-dnl Tries to compile with the given CFLAGS.
-dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
-dnl and ACTION-IF-NOT-ACCEPTED otherwise.
-
-AC_DEFUN([AS_COMPILER_FLAG],
-[
- AC_MSG_CHECKING([to see if compiler understands $1])
-
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $1"
-
- AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
- CFLAGS="$save_CFLAGS"
-
- if test "X$flag_ok" = Xyes ; then
- $2
- true
- else
- $3
- true
- fi
- AC_MSG_RESULT([$flag_ok])
-])
diff --git a/m4/tp-compiler-flag.m4 b/m4/tp-compiler-flag.m4
new file mode 100644
index 000000000..fc05e9e17
--- /dev/null
+++ b/m4/tp-compiler-flag.m4
@@ -0,0 +1,36 @@
+dnl A version of AS_COMPILER_FLAG that supports both C and C++.
+dnl Based on:
+
+dnl as-compiler-flag.m4 0.1.0
+dnl autostars m4 macro for detection of compiler flags
+dnl David Schleef <ds@schleef.org>
+dnl $Id: as-compiler-flag.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $
+
+dnl TP_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
+dnl Tries to compile with the given CFLAGS and CXXFLAGS.
+dnl
+dnl Runs ACTION-IF-ACCEPTED if the compiler for the currently selected
+dnl AC_LANG can compile with the flags, and ACTION-IF-NOT-ACCEPTED otherwise.
+
+AC_DEFUN([TP_COMPILER_FLAG],
+[
+ AC_MSG_CHECKING([to see if compiler understands $1])
+
+ save_CFLAGS="$CFLAGS"
+ save_CXXFLAGS="$CXXFLAGS"
+ CFLAGS="$CFLAGS $1"
+ CXXFLAGS="$CXXFLAGS $1"
+
+ AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
+ CFLAGS="$save_CFLAGS"
+ CXXFLAGS="$save_CXXFLAGS"
+
+ if test "X$flag_ok" = Xyes ; then
+ $2
+ true
+ else
+ $3
+ true
+ fi
+ AC_MSG_RESULT([$flag_ok])
+])
diff --git a/m4/tp-compiler-warnings.m4 b/m4/tp-compiler-warnings.m4
new file mode 100644
index 000000000..fab5dc898
--- /dev/null
+++ b/m4/tp-compiler-warnings.m4
@@ -0,0 +1,40 @@
+dnl TP_COMPILER_WARNINGS(VARIABLE, WERROR_BY_DEFAULT, DESIRABLE, UNDESIRABLE)
+dnl $1 (VARIABLE): the variable to put flags into
+dnl $2 (WERROR_BY_DEFAULT): a command returning true if -Werror should be the
+dnl default
+dnl $3 (DESIRABLE): warning flags we want (e.g. all extra shadow)
+dnl $4 (UNDESIRABLE): warning flags we don't want (e.g.
+dnl missing-field-initializers unused-parameter)
+AC_DEFUN([TP_COMPILER_WARNINGS],
+[
+ AC_REQUIRE([AC_ARG_ENABLE])dnl
+ AC_REQUIRE([AC_HELP_STRING])dnl
+ AC_REQUIRE([TP_COMPILER_FLAG])dnl
+
+ tp_warnings=""
+ for tp_flag in $3; do
+ TP_COMPILER_FLAG([-W$tp_flag], [tp_warnings="$tp_warnings -W$tp_flag"])
+ done
+
+ tp_error_flags="-Werror"
+ TP_COMPILER_FLAG([-Werror], [tp_werror=yes], [tp_werror=no])
+
+ for tp_flag in $4; do
+ TP_COMPILER_FLAG([-Wno-$tp_flag],
+ [tp_warnings="$tp_warnings -Wno-$tp_flag"])
+ TP_COMPILER_FLAG([-Wno-error=$tp_flag],
+ [tp_error_flags="$tp_error_flags -Wno-error=$tp_flag"], [tp_werror=no])
+ done
+
+ AC_ARG_ENABLE([Werror],
+ AC_HELP_STRING([--disable-Werror],
+ [compile without -Werror (normally enabled in development builds)]),
+ tp_werror=$enableval, :)
+
+ if test "x$tp_werror" = xyes && $2; then
+ $1="$tp_warnings $tp_error_flags"
+ else
+ $1="$tp_warnings"
+ fi
+
+])