summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2013-08-12 10:31:46 +0200
committerJonny Lamb <jonny.lamb@collabora.co.uk>2013-08-12 10:32:56 +0200
commitea512029263a894ea3bd17421011cf533634d9d1 (patch)
treeb2c3a70cfdbb48a2847ec71de1bf09604ba19721
parent7fd1bde39331e334f3164738e557c18a17b441a3 (diff)
configure: add more compiler warnings and add Werrorcall-channel
-rw-r--r--configure.ac62
-rw-r--r--m4/tp-compiler-flag.m436
-rw-r--r--m4/tp-compiler-warnings.m440
3 files changed, 126 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac
index 8d7dd69..67ddc9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,26 +1,64 @@
-AC_INIT([telepathy-ring], [2.2.1])
AC_PREREQ([2.59])
-AM_INIT_AUTOMAKE([foreign 1.9])
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
+# Making releases:
+# set the new version number:
+# odd minor -> development series
+# even minor -> stable series
+# increment micro for each release within a series
+# set ring_nano_version to 0.
+m4_define([ring_major_version], [2])
+m4_define([ring_minor_version], [2])
+m4_define([ring_micro_version], [1])
+m4_define([ring_nano_version], [1])
+
+# Some magic
+m4_define([ring_base_version],
+ [ring_major_version.ring_minor_version.ring_micro_version])
+m4_define([ring_version],
+ [m4_if(ring_nano_version, 0, [ring_base_version],
+ [ring_base_version].[ring_nano_version])])
+
+AC_INIT([Telepathy Ring], [ring_version])
AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE([foreign 1.9])
+
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
+
+AM_PROG_LIBTOOL
AM_CONFIG_HEADER([config.h])
+dnl check for tools
AC_PROG_CC
AC_PROG_CC_STDC
-dnl Not yet
-AM_PROG_LIBTOOL
+ifelse(ring_nano_version, 0,
+ [ official_release=yes ],
+ [ official_release=no ])
dnl decide on error flags
-AS_COMPILER_FLAG(-Wall, [
- ERROR_CFLAGS="-Wall"
- if test "x$WERROR" = "xyes"; then
- AS_COMPILER_FLAG(-Werror,ERROR_CFLAGS="$ERROR_CFLAGS -Werror",ERROR_CFLAGS="$ERROR_CFLAGS")
- fi
-])
-AC_SUBST(ERROR_CFLAGS)
+TP_COMPILER_WARNINGS([ERROR_CFLAGS], [test "x$official_release" = xno],
+ [all \
+ extra \
+ strict-prototypes \
+ nested-externs \
+ pointer-arith \
+ format-security \
+ init-self],
+ [missing-field-initializers \
+ unused-parameter \
+ sign-compare \
+ type-limits])
+AC_SUBST([ERROR_CFLAGS])
+
+# missing:
+# missing-declarations
+# declaration-after-statement
+# missing-prototypes
+# sign-compare
+# shadow
+# shouldn't be in undesired:
+# type-limits
AM_MAINTAINER_MODE
diff --git a/m4/tp-compiler-flag.m4 b/m4/tp-compiler-flag.m4
new file mode 100644
index 0000000..fc05e9e
--- /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 0000000..fab5dc8
--- /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
+
+])