From 2ffb7c67197fefe58b757c68d01955ce9cac9a9a Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Thu, 29 Oct 2009 23:29:32 +0200 Subject: [PATCH] Added checks for compiler options. Signed-off-by: Slava Zanko --- acinclude.m4 | 1 + configure.ac | 17 ++++++------ m4.include/mc-cflags.m4 | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 m4.include/mc-cflags.m4 diff --git a/acinclude.m4 b/acinclude.m4 index f52ccf79e..6f54b9281 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,6 +1,7 @@ m4_include([m4.include/ac_onceonly.m4]) m4_include([m4.include/ax_path_lib_pcre.m4]) m4_include([m4.include/dx_doxygen.m4]) +m4_include([m4.include/mc-cflags.m4]) m4_include([m4.include/mc-check-search-type.m4]) m4_include([m4.include/mc-mcserver.m4]) m4_include([m4.include/ac-get-fs-info.m4]) diff --git a/configure.ac b/configure.ac index 2c95de57b..baf1f12e5 100644 --- a/configure.ac +++ b/configure.ac @@ -515,19 +515,18 @@ if test "$GLIBC21" != yes; then AC_DEFINE(USE_INCLUDED_REGEX, 1, [Use the regex included here]) fi -dnl If default CFLAGS is used with gcc, add -Wall -if test -z "$ac_env_CFLAGS_set"; then - if test -n "$GCC"; then - CFLAGS="$CFLAGS -Wall" - fi -fi +MC_CHECK_CFLAGS + +CFLAGS_OPTS=" -O2 " +CFLAGS_EXTRA="" if test x$USE_MAINTAINER_MODE = xyes; then - CFLAGS_WARNINGS="-Wall -Werror -Wwrite-strings -Wnested-externs -Wsign-compare -Wuninitialized" - CFLAGS_DEBUG="-g3 -O -ggdb" - CFLAGS="$CFLAGS $CFLAGS_WARNINGS $CFLAGS_DEBUG" + CFLAGS_EXTRA="-Werror" + CFLAGS_OPTS="-g3 -O -ggdb" fi +CFLAGS="$CFLAGS $mc_configured_cflags $CFLAGS_OPTS $CFLAGS_EXTRA" + AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) diff --git a/m4.include/mc-cflags.m4 b/m4.include/mc-cflags.m4 new file mode 100644 index 000000000..330ee63c1 --- /dev/null +++ b/m4.include/mc-cflags.m4 @@ -0,0 +1,70 @@ +dnl @synopsis MC_CHECK_CFLAGS +dnl +dnl Check flags supported by compilator +dnl +dnl @author Slava Zanko +dnl @version 2009-10-29 +dnl @license GPL +dnl @copyright Free Software Foundation, Inc. + +AC_DEFUN([MC_CHECK_ONE_CFLAG],[ + + AC_MSG_CHECKING([if gcc accepts $1]) + + safe_CFLAGS=$CFLAGS + CFLAGS="$1" + + AC_TRY_COMPILE(, [ + return 0; + ], + [ + mc_check_one_cflag=yes + ], + [ + mc_check_one_cflag=no + ]) + + CFLAGS=$safe_CFLAGS + AC_MSG_RESULT([$mc_check_one_cflag]) + + if test x$mc_check_one_cflag = xyes; then + mc_configured_cflags="$mc_configured_cflags $1" + fi + +]) + +AC_DEFUN([MC_CHECK_CFLAGS],[ + mc_configured_cflags="" + + MC_CHECK_ONE_CFLAG([-Wunused-result]) + MC_CHECK_ONE_CFLAG([-Wimplicit-int]) + MC_CHECK_ONE_CFLAG([-Wimplicit-function-declaration]) + MC_CHECK_ONE_CFLAG([-Wmissing-braces]) + MC_CHECK_ONE_CFLAG([-Wparentheses]) + MC_CHECK_ONE_CFLAG([-Wreturn-type]) + MC_CHECK_ONE_CFLAG([-Wswitch]) + MC_CHECK_ONE_CFLAG([-Wunused-function]) + MC_CHECK_ONE_CFLAG([-Wunused-label]) + MC_CHECK_ONE_CFLAG([-Wunused-parameter]) + MC_CHECK_ONE_CFLAG([-Wunused-value]) + MC_CHECK_ONE_CFLAG([-Wunused-variable]) + MC_CHECK_ONE_CFLAG([-Wuninitialized]) + MC_CHECK_ONE_CFLAG([-Wdeclaration-after-statement]) + MC_CHECK_ONE_CFLAG([-Wshadow]) + MC_CHECK_ONE_CFLAG([-Wwrite-strings]) + MC_CHECK_ONE_CFLAG([-Wsign-compare]) + MC_CHECK_ONE_CFLAG([-Wmissing-parameter-type]) + MC_CHECK_ONE_CFLAG([-Wmissing-prototypes]) + + MC_CHECK_ONE_CFLAG([-Wmissing-declarations]) + MC_CHECK_ONE_CFLAG([-Wnested-externs]) + MC_CHECK_ONE_CFLAG([-Wno-unreachable-code]) + MC_CHECK_ONE_CFLAG([-Wno-long-long]) + MC_CHECK_ONE_CFLAG([-Wpointer-sign]) + MC_CHECK_ONE_CFLAG([-Wcomment]) + +dnl MC_CHECK_ONE_CFLAG([-fno-stack-protector]) +dnl MC_CHECK_ONE_CFLAG([-Wsequence-point]) +dnl MC_CHECK_ONE_CFLAG([-Wstrict-aliasing]) +dnl MC_CHECK_ONE_CFLAG([-Wformat]) +]) -- 2.11.4.GIT