summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2011-11-01 12:19:24 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2011-11-06 16:07:57 -0800
commitb406f730d64dfb8b699631ffb3ee5f3a1f0db8c4 (patch)
treec23b23adfdce5e2836ee27bbda57094c2d1b811e
parentb175fe0e07fce86cf029695e9e93b573ada54b0c (diff)
downloadxorg-util-macros-b406f730d64dfb8b699631ffb3ee5f3a1f0db8c4.tar.gz
Add XORG_COMPILER_FLAGS to replace XORG_CWARNFLAGS
See: https://bugs.freedesktop.org/show_bug.cgi?id=31238 Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--xorg-macros.m4.in48
1 files changed, 47 insertions, 1 deletions
diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
index 6f3bd3e..5cbfd9b 100644
--- a/xorg-macros.m4.in
+++ b/xorg-macros.m4.in
@@ -1430,12 +1430,54 @@ m4_foreach([flag], m4_cdr($@), [
])
]) # 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])
+
+# -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])
@@ -1463,12 +1505,13 @@ 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.
AC_DEFUN([XORG_STRICT_OPTION], [
AC_REQUIRE([XORG_CWARNFLAGS])
+AC_REQUIRE([XORG_COMPILER_FLAGS])
AC_ARG_ENABLE(strict-compilation,
AS_HELP_STRING([--enable-strict-compilation],
@@ -1484,9 +1527,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
@@ -1498,6 +1543,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