Added checks for compiler options.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2009-10-29 23:29:32 +02:00
parent 91a4598b54
commit 2ffb7c6719
3 changed files with 79 additions and 9 deletions

View File

@ -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])

View File

@ -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)

70
m4.include/mc-cflags.m4 Normal file
View File

@ -0,0 +1,70 @@
dnl @synopsis MC_CHECK_CFLAGS
dnl
dnl Check flags supported by compilator
dnl
dnl @author Slava Zanko <slavazanko@gmail.com>
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])
])