Tizen 2.1 base
[external/freealut.git] / admin / autotools / m4 / alut_check_flag.m4
1 # ALUT_CHECK_FLAG(FLAG, [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED])
2 # -----------------------------------------------------------------------
3 # Check to see whether the compiler for the current language supports a
4 # particular option.
5 #
6 # Implementation note: When given an unkown option, some GCC versions issue an
7 # warning on stderr only, but return an exit value of 0 nevertheless.
8 # Consequently we have to check stderr *and* the exit value.
9 AC_DEFUN([ALUT_CHECK_FLAG],
10 [AC_LANG_COMPILER_REQUIRE()dnl
11 AC_LANG_CASE([C],          [alut_compiler="$CC"  m4_pushdef([alut_Flags], [CFLAGS])],
12              [C++],        [alut_compiler="$CXX" m4_pushdef([alut_Flags], [CXXFLAGS])],
13              [Fortran 77], [alut_compiler="$F77" m4_pushdef([alut_Flags], [FFLAGS])])
14 m4_pushdef([alut_Cache], [alut_cv_[]alut_Flags[]AS_TR_SH([$1])])[]dnl
15 AC_CACHE_CHECK([whether $alut_compiler accepts $1], [alut_Cache],
16 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
17 alut_save_flags="$alut_Flags"
18 alut_Flags="$alut_Flags $1"
19 alut_Cache=no
20 if ALUT_EVAL_STDERR([$ac_compile conftest.$ac_ext]) >/dev/null; then
21   test -s conftest.err || alut_Cache=yes
22 fi
23 alut_Flags="$alut_save_flags"
24 rm -f conftest.err conftest.$ac_ext])
25 AS_IF([test $alut_Cache = yes], [$2], [$3])[]dnl
26 m4_popdef([alut_Cache])[]dnl
27 m4_popdef([alut_Flags])[]dnl
28 ])# ALUT_CHECK_FLAG