From e9dc2a2568acb069fc49c26ca1a83731437ec057 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 | 50 ++++++++++++++++++-------------------------------- m4/tp-compiler-flag.m4 | 43 ------------------------------------------- 2 files changed, 18 insertions(+), 75 deletions(-) delete mode 100644 m4/tp-compiler-flag.m4 diff --git a/configure.ac b/configure.ac index a17a3af..87fc000 100644 --- a/configure.ac +++ b/configure.ac @@ -1318,17 +1318,18 @@ 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" + +# http://bugs.freedesktop.org/show_bug.cgi?id=10599 +TEST_CFLAGS="$TEST_CFLAGS -fno-strict-aliasing" + +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 @@ -1345,7 +1346,8 @@ DISABLE_UNUSED_WARNINGS="-Wno-discarded-qualifiers AX_COMPILER_FLAGS -AX_COMPILER_FLAGS_CFLAGS([EXTRA_CFLAGS],,, +AX_COMPILER_FLAGS_CFLAGS([EXTRA_CFLAGS],, + [$TEST_CFLAGS], [-Wchar-subscripts \ -Wfloat-equal \ -Wno-address \ @@ -1361,30 +1363,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="$CFLAGS $EXTRA_CFLAGS" CXXFLAGS="$CXXFLAGS $EXTRA_CXXFLAGS" LDFLAGS="$LDFLAGS $EXTRA_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