[Telepathy-commits] [telepathy-haze/master] Pull in TP_COMPILER_WARNINGS from telepathy-glib and use it to enable many warnings

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Jan 8 06:28:55 PST 2009


---
 configure.ac               |   43 +++++++++++++++----------------------------
 m4/Makefile.am             |    4 +++-
 m4/tp-compiler-warnings.m4 |   40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 29 deletions(-)
 create mode 100644 m4/tp-compiler-warnings.m4

diff --git a/configure.ac b/configure.ac
index e2e7b4f..872908c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,34 +31,21 @@ AC_PROG_CC_STDC
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
 
-# decide error flags
-AS_COMPILER_FLAG(-Wall, ERROR_CFLAGS="-Wall", ERROR_CFLAGS="")
-AS_COMPILER_FLAG(-Werror, werror=yes, werror=no)
-
-AC_ARG_ENABLE(Werror,
-  AC_HELP_STRING([--disable-Werror],[compile without -Werror (normally enabled in development builds)]),
-    werror=$enableval, :)
-
-AS_COMPILER_FLAG(-Wextra, wextra=yes, wextra=no)
-AS_COMPILER_FLAG(-Wno-missing-field-initializers,
-        wno_missing_field_initializers=yes,
-        wno_missing_field_initializers=no)
-AS_COMPILER_FLAG(-Wno-unused-parameter,
-        wno_unused_parameter=yes,
-        wno_unused_parameter=no)
-
-ifelse(haze_nano_version, 0, [],
-    [
-        if test x$werror = xyes; then
-            ERROR_CFLAGS="$ERROR_CFLAGS -Werror"
-        fi
-        if test x$wextra = xyes -a \
-            x$wno_missing_field_initializers = xyes -a \
-            x$wno_unused_parameter = xyes; then
-            ERROR_CFLAGS="$ERROR_CFLAGS -Wextra -Wno-missing-field-initializers -Wno-unused-parameter"
-        fi
-    ])
-
+ifelse(haze_nano_version, 0, [release=yes], [release=no])
+TP_COMPILER_WARNINGS([ERROR_CFLAGS], [test x$release = xno],
+  [all \
+   extra \
+   declaration-after-statement \
+   shadow \
+   strict-prototypes \
+   missing-prototypes \
+   sign-compare \
+   nested-externs \
+   pointer-arith \
+   format-security \
+   init-self],
+  [missing-field-initializers \
+   unused-parameter])
 AC_SUBST(ERROR_CFLAGS)
 
 AC_ARG_ENABLE(leaky-request-stubs,
diff --git a/m4/Makefile.am b/m4/Makefile.am
index d5293d7..3b39ac3 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -1,2 +1,4 @@
 EXTRA_DIST = \
-as-ac-expand.m4
+as-ac-expand.m4 \
+as-compiler-flag.m4 \
+tp-compiler-warnings.m4
diff --git a/m4/tp-compiler-warnings.m4 b/m4/tp-compiler-warnings.m4
new file mode 100644
index 0000000..dbc4ebb
--- /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([AS_COMPILER_FLAG])dnl
+
+  tp_warnings=""
+  for tp_flag in $3; do
+    AS_COMPILER_FLAG([-W$tp_flag], [tp_warnings="$tp_warnings -W$tp_flag"])
+  done
+
+  tp_error_flags="-Werror"
+  AS_COMPILER_FLAG([-Werror], [tp_werror=yes], [tp_werror=no])
+
+  for tp_flag in $4; do
+    AS_COMPILER_FLAG([-Wno-$tp_flag],
+      [tp_warnings="$tp_warnings -Wno-$tp_flag"])
+    AS_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
+
+])
-- 
1.5.6.5




More information about the Telepathy-commits mailing list