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>
6 dnl Tim-Philipp Müller <tim centricular net>
8 dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
9 dnl Tries to compile with the given CFLAGS.
10 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
11 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
13 AC_DEFUN([AS_COMPILER_FLAG],
15 AC_MSG_CHECKING([to see if compiler understands $1])
20 AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
23 if test "X$flag_ok" = Xyes ; then
30 AC_MSG_RESULT([$flag_ok])
33 dnl AS_CXX_COMPILER_FLAG(CPPFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
34 dnl Tries to compile with the given CPPFLAGS.
35 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
36 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
38 AC_DEFUN([AS_CXX_COMPILER_FLAG],
40 AC_REQUIRE([AC_PROG_CXX])
42 AC_MSG_CHECKING([to see if c++ compiler understands $1])
44 save_CPPFLAGS="$CPPFLAGS"
45 CPPFLAGS="$CPPFLAGS $1"
49 AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
50 CPPFLAGS="$save_CPPFLAGS"
52 if test "X$flag_ok" = Xyes ; then
62 AC_MSG_RESULT([$flag_ok])