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