master - configure: detect compiler flag
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d95751cb0b750ea698d665bd8ad8086fe9ee6945 Commit: d95751cb0b750ea698d665bd8ad8086fe9ee6945 Parent: 772fa460d1ef7dede99478e30de756136ea0c7aa Author: Zdenek Kabelac <[email protected]> AuthorDate: Thu Oct 24 21:40:25 2013 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Fri Oct 25 00:41:36 2013 +0200
configure: detect compiler flag
Use m4 macro AC_TRY_CCFLAG to detect presence of some compiler option.
Use it to detect -Wjump-misses-init.
--- acinclude.m4 | 39 +++++++++++++++++++++++++++++++++++++++ aclocal.m4 | 1 + configure | 42 ++++++++++++++++++++++++++++++++++++++++++ configure.in | 4 ++++ make.tmpl.in | 6 +++++- 5 files changed, 91 insertions(+), 1 deletions(-)
acinclude.m4 new file +39 -0
@@ -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 +])
aclocal.m4 +1 -0
@@ -169,3 +169,4 @@ else fi[]dnl ])# PKG_CHECK_MODULES +m4_include([acinclude.m4])
configure +42 -0
54 lines not on this page · raw message
configure.in +4 -0
@@ -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)
make.tmpl.in +5 -1
@@ -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