renatofilho@522: dnl as-compiler-flag.m4 0.1.0
renatofilho@522: 
renatofilho@522: dnl autostars m4 macro for detection of compiler flags
renatofilho@522: 
renatofilho@522: dnl David Schleef <ds@schleef.org>
renatofilho@522: 
renatofilho@522: dnl $Id: as-compiler-flag.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $
renatofilho@522: 
renatofilho@522: dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
renatofilho@522: dnl Tries to compile with the given CFLAGS.
renatofilho@522: dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
renatofilho@522: dnl and ACTION-IF-NOT-ACCEPTED otherwise.
renatofilho@522: 
renatofilho@522: AC_DEFUN([AS_COMPILER_FLAG],
renatofilho@522: [
renatofilho@522:   AC_MSG_CHECKING([to see if compiler understands $1])
renatofilho@522: 
renatofilho@522:   save_CFLAGS="$CFLAGS"
renatofilho@522:   CFLAGS="$CFLAGS $1"
renatofilho@522: 
renatofilho@522:   AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
renatofilho@522:   CFLAGS="$save_CFLAGS"
renatofilho@522: 
renatofilho@522:   if test "X$flag_ok" = Xyes ; then
renatofilho@522:     $2
renatofilho@522:     true
renatofilho@522:   else
renatofilho@522:     $3
renatofilho@522:     true
renatofilho@522:   fi
renatofilho@522:   AC_MSG_RESULT([$flag_ok])
renatofilho@522: ])