[Pkg-telepathy-commits] [libnice] 38/265: configure: Verify that the compiler understands warning cflags

Simon McVittie smcv at debian.org
Wed May 14 12:04:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository libnice.

commit 574b59a3550238d5a329903b5a03f817ae8bbd45
Author: Olivier Crête <olivier.crete at collabora.com>
Date:   Thu Dec 26 21:16:14 2013 -0500

    configure: Verify that the compiler understands warning cflags
    
    Older compilers don't understand all of the flags
---
 .gitignore                         |  1 -
 agent/Makefile.am                  |  2 +-
 common.mk                          | 18 -----------
 configure.ac                       | 19 +++++++++++
 docs/reference/libnice/Makefile.am |  2 +-
 examples/Makefile.am               |  2 +-
 m4/as-compiler-flag.m4             | 64 ++++++++++++++++++++++++++++++++++++++
 nice/Makefile.am                   |  2 +-
 random/Makefile.am                 |  2 +-
 socket/Makefile.am                 |  2 +-
 stun/Makefile.am                   |  2 +-
 stun/tools/Makefile.am             |  2 +-
 tests/Makefile.am                  |  2 +-
 13 files changed, 92 insertions(+), 28 deletions(-)

diff --git a/.gitignore b/.gitignore
index b4f9b7c..9695793 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,7 +37,6 @@ stamp-h1
 
 # top level stuff
 debian
-m4
 
 # address/ stuff
 address/libaddress.la
diff --git a/agent/Makefile.am b/agent/Makefile.am
index 0494e5e..7975906 100644
--- a/agent/Makefile.am
+++ b/agent/Makefile.am
@@ -10,7 +10,7 @@ include $(top_srcdir)/common.mk
 
 AM_CFLAGS = \
 	-DG_LOG_DOMAIN=\"libnice\" \
-	$(ERROR_CFLAGS) \
+	$(LIBNICE_CFLAGS) \
 	$(GLIB_CFLAGS) \
 	$(GUPNP_CFLAGS) \
 	-I $(top_srcdir) \
diff --git a/common.mk b/common.mk
index 1382422..e2ca3f4 100644
--- a/common.mk
+++ b/common.mk
@@ -1,21 +1,3 @@
-
-ERROR_CFLAGS = \
-	$(LIBNICE_CFLAGS) \
-	-fno-strict-aliasing \
-	-Wextra \
-	-Wundef \
-	-Wnested-externs \
-	-Wwrite-strings \
-	-Wpointer-arith \
-	-Wbad-function-cast \
-	-Wmissing-declarations \
-	-Wmissing-prototypes \
-	-Wstrict-prototypes \
-	-Wredundant-decls \
-	-Wno-unused-parameter \
-	-Wno-missing-field-initializers
-# -Wold-style-definition -Winline -Wunreachable-code
-
 CLEANFILES = *.gcno *.gcda
 
 pkgincludedir = $(includedir)/nice
diff --git a/configure.ac b/configure.ac
index 115b57f..2173a4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -99,6 +99,25 @@ dnl if asked for, add -Werror if supported
 if test "x$LIBNICE_RELEASE" != "xyes"; then
   LIBNICE_CFLAGS="$LIBNICE_CFLAGS -Werror"
 fi
+
+AC_DEFUN([NICE_ADD_FLAG],
+  AS_COMPILER_FLAG([$1], LIBNICE_CFLAGS="$LIBNICE_CFLAGS $1", [])
+)
+
+NICE_ADD_FLAG([-fno-strict-aliasing])
+NICE_ADD_FLAG([-Wextra])
+NICE_ADD_FLAG([-Wundef])
+NICE_ADD_FLAG([-Wnested-externs])
+NICE_ADD_FLAG([-Wwrite-strings])
+NICE_ADD_FLAG([-Wpointer-arith])
+NICE_ADD_FLAG([-Wbad-function-cast])
+NICE_ADD_FLAG([-Wmissing-declarations])
+NICE_ADD_FLAG([-Wmissing-prototypes])
+NICE_ADD_FLAG([-Wstrict-prototypes])
+NICE_ADD_FLAG([-Wredundant-decls])
+NICE_ADD_FLAG([-Wno-unused-parameter])
+NICE_ADD_FLAG([-Wno-missing-field-initializers])
+
 #
 # Fixes for Solaris
 #
diff --git a/docs/reference/libnice/Makefile.am b/docs/reference/libnice/Makefile.am
index 51384ab..952b2ec 100644
--- a/docs/reference/libnice/Makefile.am
+++ b/docs/reference/libnice/Makefile.am
@@ -72,7 +72,7 @@ expand_content_files=
 # signals and properties.
 # e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
 # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
-AM_CFLAGS =  $(ERROR_CFLAGS) \
+AM_CFLAGS =  $(LIBNICE_CFLAGS) \
         $(GLIB_CFLAGS) \
         -I $(top_srcdir) \
         -I $(top_srcdir)/random \
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 007a5c8..1e7decf 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -14,7 +14,7 @@ AM_CFLAGS = \
 	-I $(top_srcdir)/random \
 	-I $(top_srcdir)/socket \
 	-I $(top_srcdir)/stun \
-	$(ERROR_CFLAGS) \
+	$(LIBNICE_CFLAGS) \
 	$(GLIB_CFLAGS) \
         $(GUPNP_CFLAGS)
 
diff --git a/m4/as-compiler-flag.m4 b/m4/as-compiler-flag.m4
new file mode 100644
index 0000000..882a4c7
--- /dev/null
+++ b/m4/as-compiler-flag.m4
@@ -0,0 +1,64 @@
+dnl as-compiler-flag.m4 0.1.0
+
+dnl autostars m4 macro for detection of compiler flags
+
+dnl David Schleef <ds at schleef.org>
+dnl Tim-Philipp Müller <tim centricular net>
+
+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])
+])
+
+dnl AS_CXX_COMPILER_FLAG(CPPFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
+dnl Tries to compile with the given CPPFLAGS.
+dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
+dnl and ACTION-IF-NOT-ACCEPTED otherwise.
+
+AC_DEFUN([AS_CXX_COMPILER_FLAG],
+[
+  AC_REQUIRE([AC_PROG_CXX])
+
+  AC_MSG_CHECKING([to see if c++ compiler understands $1])
+
+  save_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $1"
+
+  AC_LANG_PUSH(C++)
+
+  AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
+  CPPFLAGS="$save_CPPFLAGS"
+
+  if test "X$flag_ok" = Xyes ; then
+    $2
+    true
+  else
+    $3
+    true
+  fi
+
+  AC_LANG_POP(C++)
+
+  AC_MSG_RESULT([$flag_ok])
+])
+
diff --git a/nice/Makefile.am b/nice/Makefile.am
index ce2be07..b2ccb2b 100644
--- a/nice/Makefile.am
+++ b/nice/Makefile.am
@@ -26,7 +26,7 @@ libnice_la_LDFLAGS = \
 
 
 AM_CFLAGS = \
-	$(ERROR_CFLAGS) \
+	$(LIBNICE_CFLAGS) \
 	$(GLIB_CFLAGS) \
 	-I $(top_srcdir) \
 	-I $(top_srcdir)/agent \
diff --git a/random/Makefile.am b/random/Makefile.am
index 8d8ab82..86ab926 100644
--- a/random/Makefile.am
+++ b/random/Makefile.am
@@ -8,7 +8,7 @@
 
 include $(top_srcdir)/common.mk
 
-AM_CFLAGS = $(ERROR_CFLAGS) $(GLIB_CFLAGS)
+AM_CFLAGS = $(LIBNICE_CFLAGS) $(GLIB_CFLAGS)
 
 noinst_LTLIBRARIES = libnice-random.la
 
diff --git a/socket/Makefile.am b/socket/Makefile.am
index 9b5b006..336a5a3 100644
--- a/socket/Makefile.am
+++ b/socket/Makefile.am
@@ -10,7 +10,7 @@ include $(top_srcdir)/common.mk
 
 AM_CFLAGS = \
 	-DG_LOG_DOMAIN=\"libnice-socket\" \
-	$(ERROR_CFLAGS) \
+	$(LIBNICE_CFLAGS) \
 	$(GLIB_CFLAGS) \
 	$(GUPNP_CFLAGS) \
 	-I $(top_srcdir)/random \
diff --git a/stun/Makefile.am b/stun/Makefile.am
index 7601964..f90c3d4 100644
--- a/stun/Makefile.am
+++ b/stun/Makefile.am
@@ -10,7 +10,7 @@ SUBDIRS = . tools tests
 
 include $(top_srcdir)/common.mk
 
-AM_CFLAGS = -std=gnu99 -DG_LOG_DOMAIN=\"libnice-stun\" $(ERROR_CFLAGS)
+AM_CFLAGS = -std=gnu99 -DG_LOG_DOMAIN=\"libnice-stun\" $(LIBNICE_CFLAGS)
 AM_CPPFLAGS = -I$(top_srcdir)
 
 if WINDOWS
diff --git a/stun/tools/Makefile.am b/stun/tools/Makefile.am
index 42b3108..7a9b772 100644
--- a/stun/tools/Makefile.am
+++ b/stun/tools/Makefile.am
@@ -8,7 +8,7 @@
 #
 
 include $(top_srcdir)/common.mk
-AM_CFLAGS = -std=gnu99 $(ERROR_CFLAGS)
+AM_CFLAGS = -std=gnu99 $(LIBNICE_CFLAGS)
 AM_CPPFLAGS = -I$(top_srcdir) 
 
 bin_PROGRAMS = stunbdc stund
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 88cb73f..5a1a9c7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,7 +9,7 @@
 include $(top_srcdir)/common.mk
 
 AM_CFLAGS = \
-	$(ERROR_CFLAGS) \
+	$(LIBNICE_CFLAGS) \
 	$(GLIB_CFLAGS) \
         $(GUPNP_CFLAGS) \
 	-I $(top_srcdir) \

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/libnice.git



More information about the Pkg-telepathy-commits mailing list