1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

configure: detect compiler flag

Use m4 macro AC_TRY_CCFLAG to detect presence of some compiler
option.
Use it to detect -Wjump-misses-init.
This commit is contained in:
Zdenek Kabelac 2013-10-24 21:40:25 +02:00
parent 772fa460d1
commit d95751cb0b
5 changed files with 91 additions and 1 deletions

39
acinclude.m4 Normal file
View File

@ -0,0 +1,39 @@
dnl AC_GCC_VERSION
dnl check for compiler version
dnl sets COMPILER_VERSION and GCC_VERSION
AC_DEFUN([AC_CC_VERSION],
[
AC_MSG_CHECKING([C compiler version])
COMPILER_VERSION=`$CC -v 2>&1 | grep version`
case "$COMPILER_VERSION" in
*gcc*)
dnl Ok, how to turn $3 into the real $3
GCC_VERSION=`echo $COMPILER_VERSION | \
sed -e 's/[[^ ]]*\ [[^ ]]*\ \([[^ ]]*\)\ .*/\1/'` ;;
*) GCC_VERSION=unknown ;;
esac
AC_MSG_RESULT($GCC_VERSION)
])
dnl AC_TRY_CCFLAG([CCFLAG], [VAR], [ACTION-IF-WORKS], [ACTION-IF-FAILS])
dnl check if $CC supports a given flag
AC_DEFUN([AC_TRY_CCFLAG],
[
AC_REQUIRE([AC_PROG_CC])
ac_save_CFLAGS=$CFLAGS
CFLAGS=$1
AC_MSG_RESULT([KOUKEJ $name])
AC_CACHE_CHECK([whether $CC accepts $1 flag], [ac_cv_flag_$2],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
[AS_VAR_SET([ac_cv_flag_$2], [yes])],
[AS_VAR_SET([ac_cv_flag_$2], [no])])])
CFLAGS=$ac_save_CFLAGS
$2=AS_VAR_GET([ac_cv_flag_$2])
if test "$2" = yes; then
ifelse([$3], [], [:], [$3])
else
ifelse([$4], [], [:], [$4])
fi
])

1
aclocal.m4 vendored
View File

@ -169,3 +169,4 @@ else
fi[]dnl
])# PKG_CHECK_MODULES
m4_include([acinclude.m4])

42
configure vendored
View File

@ -708,6 +708,7 @@ CUNIT_CFLAGS
GENPNG
GENHTML
LCOV
HAVE_WJUMP
SACKPT_LIBS
SACKPT_CFLAGS
DLM_LIBS
@ -8677,6 +8678,47 @@ else
CSCOPE_CMD=
fi
ac_save_CFLAGS=$CFLAGS
CFLAGS=-Wjump-misses-init
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: KOUKEJ $name" >&5
$as_echo "KOUKEJ $name" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -Wjump-misses-init flag" >&5
$as_echo_n "checking whether $CC accepts -Wjump-misses-init flag... " >&6; }
if test "${ac_cv_flag_HAVE_WJUMP+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_flag_HAVE_WJUMP=yes
else
ac_cv_flag_HAVE_WJUMP=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_flag_HAVE_WJUMP" >&5
$as_echo "$ac_cv_flag_HAVE_WJUMP" >&6; }
CFLAGS=$ac_save_CFLAGS
HAVE_WJUMP=$ac_cv_flag_HAVE_WJUMP
if test "HAVE_WJUMP" = yes; then
:
else
:
fi
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C optimisation flag" >&5
$as_echo_n "checking for C optimisation flag... " >&6; }

View File

@ -835,6 +835,10 @@ else
CSCOPE_CMD=
fi
dnl -- Check if compiler supports -Wjump-misses-init
AC_TRY_CCFLAG([-Wjump-misses-init], [HAVE_WJUMP], [], [])
AC_SUBST(HAVE_WJUMP)
################################################################################
dnl -- Override optimisation
AC_MSG_CHECKING(for C optimisation flag)

View File

@ -138,9 +138,13 @@ WFLAGS += -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings \
-Wpointer-arith -Wclobbered -Wempty-body -Wignored-qualifiers \
-Wmissing-parameter-type -Wold-style-declaration -Woverride-init \
-Wtype-limits -Wuninitialized -Wmissing-include-dirs -Wsync-nand \
-Wfloat-equal -Wjump-misses-init -Wlogical-op -Wstrict-prototypes \
-Wfloat-equal -Wlogical-op -Wstrict-prototypes \
-Wold-style-definition -Wmissing-format-attribute
ifeq ("@HAVE_WJUMP@", "yes")
WFLAGS += -Wjump-misses-init
endif
#WFLAGS += -W -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers
#WFLAGS += -Wsign-compare -Wunused-parameter -Wmissing-field-initializers
#WFLAGS += -Wconversion -Wbad-function-cast -Wcast-qual -Waggregate-return -Wpacked