From 8473993cc27e6b812a309be1119f9a01ceadea55 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 16 Aug 2016 13:36:38 +0200 Subject: Test additonal compiler flags with AX_COMPILER_FLAGS_CFLAGS This patch integrates the remaining tests for compiler flags into the call to AX_COMPILER_FLAGS_CFLAGS. All tests for compiler flags are now done in a single place. Signed-off-by: Thomas Zimmermann --- configure.ac | 47 +++++++++++++++-------------------------------- m4/tp-compiler-flag.m4 | 43 ------------------------------------------- 2 files changed, 15 insertions(+), 75 deletions(-) delete mode 100644 m4/tp-compiler-flag.m4 diff --git a/configure.ac b/configure.ac index 644364e..367aca2 100644 --- a/configure.ac +++ b/configure.ac @@ -1348,17 +1348,15 @@ fi AC_SUBST([DBUS_X_CFLAGS]) AC_SUBST([DBUS_X_LIBS]) -#### gcc warning flags - -cc_supports_flag() { - AC_MSG_CHECKING(whether $CC supports "$*") - save_CFLAGS="$CFLAGS" - CFLAGS="$*" - AC_TRY_COMPILE([], [], [rc=yes], [rc=no]) - CFLAGS="$save_CFLAGS" - AC_MSG_RESULT([$rc]) - test "x$rc" = xyes -} +# We're treating -fno-common like a warning: it makes the linker more +# strict, because on some systems the linker is *always* this strict +TEST_CFLAGS="$TEST_CFLAGS -fno-common" + +AS_IF([test "x$enable_ansi" = "xyes"],[ + TEST_CFLAGS="$TEST_CFLAGS -ansi -pedantic" + AC_DEFINE([_POSIX_C_SOURCE],[199309L],[Define to enable POSIX features]) + AC_DEFINE([_BSD_SOURCE],[1],[Define to enable BSD features]) + ]) dnl TODO: The compiler flags below disable warnings that the dnl compiler emits while building DBus. Fix the source @@ -1376,7 +1374,8 @@ DISABLE_WARNINGS="DISABLE_WARNINGS AX_COMPILER_FLAGS -AX_COMPILER_FLAGS_CFLAGS([EXTRA_CFLAGS],[],[], +AX_COMPILER_FLAGS_CFLAGS([EXTRA_CFLAGS],[], + [$TEST_CFLAGS], [-Wchar-subscripts \ -Wfloat-equal \ -Wno-address \ @@ -1392,30 +1391,14 @@ AX_COMPILER_FLAGS_CXXFLAGS([EXTRA_CXXFLAGS],[],[], AX_COMPILER_FLAGS_LDFLAGS([EXTRA_LDFLAGS]) +dnl TODO: In principle we should put EXTRA_CFLAGS in each Makefile.am like +dnl telepathy-glib does, since CFLAGS is meant to be reserved for the user... +dnl but prepending to CFLAGS (so the user can override it with later CFLAGS) +dnl is the next best thing. CFLAGS="$EXTRA_CFLAGS $CFLAGS" CXXFLAGS="$EXTRA_CXXFLAGS $CXXFLAGS" LDFLAGS="$EXTRA_LDFLAGS $LDFLAGS" -if test "x$GCC" = "xyes"; then - # We're treating -fno-common like a warning: it makes the linker more - # strict, because on some systems the linker is *always* this strict - TP_ADD_COMPILER_FLAG([WARNING_CFLAGS], [-fno-common]) - - # http://bugs.freedesktop.org/show_bug.cgi?id=10599 - TP_ADD_COMPILER_FLAG([WARNING_CFLAGS], [-fno-strict-aliasing]) - - if test "x$enable_ansi" = "xyes"; then - TP_ADD_COMPILER_FLAG([WARNING_CFLAGS], - [-ansi -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -pedantic]) - fi -fi - -dnl In principle we should put WARNING_CFLAGS in each Makefile.am like -dnl telepathy-glib does, since CFLAGS is meant to be reserved for the user... -dnl but prepending to CFLAGS (so the user can override it with later CFLAGS) -dnl is the next best thing -CFLAGS="$WARNING_CFLAGS $CFLAGS" - case $host_os in solaris*) # Solaris' C library apparently needs these runes to be threadsafe... diff --git a/m4/tp-compiler-flag.m4 b/m4/tp-compiler-flag.m4 deleted file mode 100644 index 06deaba..0000000 --- a/m4/tp-compiler-flag.m4 +++ /dev/null @@ -1,43 +0,0 @@ -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 -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]) -]) - -dnl TP_ADD_COMPILER_FLAG(VARIABLE, CFLAGS) -dnl Append CFLAGS to VARIABLE if the compiler supports them. -AC_DEFUN([TP_ADD_COMPILER_FLAG], -[ - TP_COMPILER_FLAG([$2], [$1="[$]$1 $2"]) -]) -- 2.7.4