1 dnl A version of AS_COMPILER_FLAG that supports both C and C++.
4 dnl as-compiler-flag.m4 0.1.0
5 dnl autostars m4 macro for detection of compiler flags
6 dnl David Schleef <ds@schleef.org>
7 dnl $Id: as-compiler-flag.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $
9 dnl TP_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
10 dnl Tries to compile with the given CFLAGS and CXXFLAGS.
12 dnl Runs ACTION-IF-ACCEPTED if the compiler for the currently selected
13 dnl AC_LANG can compile with the flags, and ACTION-IF-NOT-ACCEPTED otherwise.
15 AC_DEFUN([TP_COMPILER_FLAG],
17 AC_MSG_CHECKING([to see if compiler understands $1])
20 save_CXXFLAGS="$CXXFLAGS"
22 CXXFLAGS="$CXXFLAGS $1"
24 AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
26 CXXFLAGS="$save_CXXFLAGS"
28 if test "X$flag_ok" = Xyes ; then
35 AC_MSG_RESULT([$flag_ok])
38 dnl TP_ADD_COMPILER_FLAG(VARIABLE, CFLAGS)
39 dnl Append CFLAGS to VARIABLE if the compiler supports them.
40 AC_DEFUN([TP_ADD_COMPILER_FLAG],
42 TP_COMPILER_FLAG([$2], [$1="[$]$1 $2"])