# $Id$ # if the given code compiles without the flag, execute argument 4 # if the given code only compiles with the flag, execute argument 3 # otherwise fail AC_DEFUN([CHECK_COMPILER_FLAG_NEEDED],[ AC_REQUIRE([AC_PROG_CC]) AC_MSG_CHECKING(whether we need $1 as a flag for $CC) cache=`echo $1 | sed 'y% .=/+-%____p_%'` AC_CACHE_VAL(cv_prog_cc_flag_needed_$cache, [ echo '$2' > conftest.c echo 'void f(){}' >>conftest.c if test -z "`$CC $CFLAGS -Werror -Wall -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=no" else [ if test -z "`$CC $CFLAGS $1 -Werror -Wall -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=yes" else echo 'Test with flag fails too' fi ] fi rm -f conftest* ]) if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then AC_MSG_RESULT(yes) : $3 else AC_MSG_RESULT(no) : $4 fi ])