diff options
author | Pauli Nieminen <suokkos@gmail.com> | 2009-07-25 15:53:02 +0300 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-09-01 13:53:20 +1000 |
commit | 3b7dd69d0bf6bc19f0e4403bb6611de87497aac3 (patch) | |
tree | b2fe43a4320911aaf927f81aa2b691d5373c049b | |
parent | b0618a909a56d958a6690318545379e105587d82 (diff) |
Add XORG_STRICT_OPTION macro for strict compilation option
Strict compilation option can be used to get rid of warnings that often are
showing real hidden bug in code. That just waits to cause problems.
CWARNFLAGS has to be added to AM_C(PP)FLAGS to use strict compilation mode
in Makefile.am. Automatic addition to compiler flags would cause some configure
checks fail.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | xorg-macros.m4.in | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in index 1954714..5c22332 100644 --- a/xorg-macros.m4.in +++ b/xorg-macros.m4.in @@ -456,3 +456,32 @@ fi AC_SUBST(CWARNFLAGS) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) ]) # XORG_CWARNFLAGS + +# XORG_STRICT_OPTION +# ----------------------- +# Minimum version: 1.3.0 +# +# Add configure option to enable strict compilation +AC_DEFUN([XORG_STRICT_OPTION], [ +AC_REQUIRE([AC_PROG_CC]) +AC_REQUIRE([AC_PROG_CC_C99]) +AC_REQUIRE([XORG_CWARNFLAGS]) + +AC_ARG_ENABLE(strict-compilation, + AS_HELP_STRING([--enable-strict-compilation], + [Enable all warnings from compiler and make them errors (default: disabled)]), + [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no]) +if test "x$STRICT_COMPILE" = "xyes"; then + AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) + AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"]) + if test "x$GCC" = xyes ; then + STRICT_CFLAGS="-pedantic -Werror" + elif test "x$SUNCC" = "xyes"; then + STRICT_CFLAGS="-errwarn" + elif test "x$INTELCC" = "xyes"; then + STRICT_CFLAGS="-Werror" + fi +fi +CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS" +AC_SUBST([CWARNFLAGS]) +]) # XORG_STRICT_OPTION |