From 0027d409c8b1d900ad7bf2c384afe7710bf2250e Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sat, 25 Jul 2009 15:53:02 +0300 Subject: [PATCH 1/4] 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. --- 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 bcf8c44..befa429 100644 --- a/xorg-macros.m4.in +++ b/xorg-macros.m4.in @@ -455,3 +455,32 @@ else fi AC_SUBST(CWARNFLAGS) ]) # 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 -- 1.6.3.3