summaryrefslogtreecommitdiff
path: root/acinclude.m4
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2013-10-24 21:40:25 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2013-10-25 00:41:36 +0200
commitd95751cb0b750ea698d665bd8ad8086fe9ee6945 (patch)
tree6121ab50968f1fda9a413c86300c1f436657b63b /acinclude.m4
parent772fa460d1ef7dede99478e30de756136ea0c7aa (diff)
downloadlvm2-d95751cb0b750ea698d665bd8ad8086fe9ee6945.tar.gz
configure: detect compiler flag
Use m4 macro AC_TRY_CCFLAG to detect presence of some compiler option. Use it to detect -Wjump-misses-init.
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m439
1 files changed, 39 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644
index 000000000..333abb545
--- /dev/null
+++ b/acinclude.m4
@@ -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
+])