[PATCH util-macros 4/6] Add XORG_COMPILER_FLAGS to replace XORG_CWARNFLAGS
Jeremy Huddleston
jeremyhu at apple.com
Tue Nov 1 13:16:22 PDT 2011
See: https://bugs.freedesktop.org/show_bug.cgi?id=31238
Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
---
xorg-macros.m4.in | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
index 456f78f..c362943 100644
--- a/xorg-macros.m4.in
+++ b/xorg-macros.m4.in
@@ -1405,12 +1405,54 @@ ifelse([$#], [0], [AC_MSG_ERROR("Incorrect arguments to XORG_TESTSET_CFLAG")],
])
]) # XORG_TESTSET_CFLAG
+# XORG_COMPILER_FLAGS
+# ---------------
+# Minimum version: 1.16.0
+#
+# Defines BASE_CFLAGS to contain a set of command line arguments supported
+# by the selected compiler which do NOT alter the generated code. These
+# arguments will cause the compiler to print various warnings during
+# compilation AND turn a conservative set of warnings into errors.
+#
+# The set of flags supported by BASE_CFLAGS will grow in future
+# versions of util-macros as options are added to new compilers.
+#
+AC_DEFUN([XORG_COMPILER_FLAGS], [
+AC_REQUIRE([XORG_COMPILER_BRAND])
+
+dnl -v is too short to test reliably with XORG_TESTSET_CFLAG
+if test "x$SUNCC" = "xyes"; then
+ BASE_CFLAGS="-v"
+else
+ BASE_CFLAGS=""
+fi
+
+XORG_TESTSET_CFLAG(BASE_CFLAGS, -Wall)
+XORG_TESTSET_CFLAG(BASE_CFLAGS, -Wpointer-arith)
+XORG_TESTSET_CFLAG(BASE_CFLAGS, -Wstrict-prototypes)
+XORG_TESTSET_CFLAG(BASE_CFLAGS, -Wmissing-prototypes)
+XORG_TESTSET_CFLAG(BASE_CFLAGS, -Wmissing-declarations)
+XORG_TESTSET_CFLAG(BASE_CFLAGS, -Wnested-externs)
+XORG_TESTSET_CFLAG(BASE_CFLAGS, -Wbad-function-cast)
+XORG_TESTSET_CFLAG(BASE_CFLAGS, -Wformat=2, -Wformat)
+XORG_TESTSET_CFLAG(BASE_CFLAGS, -Wold-style-definition)
+XORG_TESTSET_CFLAG(BASE_CFLAGS, -Wdeclaration-after-statement)
+
+AC_SUBST(BASE_CFLAGS)
+]) # XORG_COMPILER_FLAGS
+
# XORG_CWARNFLAGS
# ---------------
# Minimum version: 1.2.0
+# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
#
# Defines CWARNFLAGS to enable C compiler warnings.
#
+# This function is deprecated because it defines -fno-strict-aliasing
+# which alters the code generated by the compiler. If -fno-strict-aliasing
+# is needed, then it should be added explicitly in the module when
+# it is updated to use BASE_CFLAGS.
+#
AC_DEFUN([XORG_CWARNFLAGS], [
AC_REQUIRE([AC_PROG_CC_C99])
AC_REQUIRE([XORG_COMPILER_BRAND])
@@ -1438,7 +1480,7 @@ AC_SUBST(CWARNFLAGS)
# Add configure option to enable strict compilation flags, such as treating
# warnings as fatal errors.
# If --enable-strict-compilation is passed to configure, adds strict flags to
-# $CWARNFLAGS.
+# $BASE_CFLAGS and the deprecated $CWARNFLAGS.
#
# Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
# when strict compilation is unconditionally desired.
@@ -1459,9 +1501,11 @@ XORG_TESTSET_CFLAG(STRICT_CFLAGS, -Werror, -errwarn)
XORG_TESTSET_CFLAG(STRICT_CFLAGS, -Werror=attributes)
if test "x$STRICT_COMPILE" = "xyes"; then
+ BASE_CFLAGS="$BASE_CFLAGS $STRICT_CFLAGS"
CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"
fi
AC_SUBST([STRICT_CFLAGS])
+AC_SUBST([BASE_CFLAGS])
AC_SUBST([CWARNFLAGS])
]) # XORG_STRICT_OPTION
@@ -1473,6 +1517,7 @@ AC_SUBST([CWARNFLAGS])
#
AC_DEFUN([XORG_DEFAULT_OPTIONS], [
AC_REQUIRE([AC_PROG_INSTALL])
+XORG_COMPILER_FLAGS
XORG_CWARNFLAGS
XORG_STRICT_OPTION
XORG_RELEASE_VERSION
--
1.7.7
More information about the xorg-devel
mailing list