1 dnl as-compiler-flag.m4 0.1.0
3 dnl autostars m4 macro for detection of compiler flags
5 dnl David Schleef <ds@schleef.org>
7 dnl $Id: as-compiler-flag.m4,v 1.1 2005/12/15 23:35:19 ds Exp $
9 dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
10 dnl Tries to compile with the given CFLAGS.
11 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
12 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
14 AC_DEFUN([AS_COMPILER_FLAG],
16 AC_MSG_CHECKING([to see if compiler understands $1])
21 AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
24 if test "X$flag_ok" = Xyes ; then
31 AC_MSG_RESULT([$flag_ok])
34 dnl AS_COMPILER_FLAGS(VAR, FLAGS)
35 dnl Tries to compile with the given CFLAGS.
37 AC_DEFUN([AS_COMPILER_FLAGS],
42 AC_MSG_CHECKING([for supported compiler flags])
46 CFLAGS="$CFLAGS $each"
47 AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
50 if test "X$flag_ok" = Xyes ; then
51 flags_supported="$flags_supported $each"
53 flags_unsupported="$flags_unsupported $each"
56 AC_MSG_RESULT([$flags_supported])
57 if test "X$flags_unsupported" != X ; then
58 AC_MSG_WARN([unsupported compiler flags: $flags_unsupported])
60 $1="$$1 $flags_supported"