[rename] renamed kdbus related macros
[platform/upstream/dbus.git] / m4 / tp-compiler-flag.m4
1 dnl A version of AS_COMPILER_FLAG that supports both C and C++.
2 dnl Based on:
3
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 $
8
9 dnl TP_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
10 dnl Tries to compile with the given CFLAGS and CXXFLAGS.
11 dnl
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.
14
15 AC_DEFUN([TP_COMPILER_FLAG],
16 [
17   AC_MSG_CHECKING([to see if compiler understands $1])
18
19   save_CFLAGS="$CFLAGS"
20   save_CXXFLAGS="$CXXFLAGS"
21   CFLAGS="$CFLAGS $1"
22   CXXFLAGS="$CXXFLAGS $1"
23
24   AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
25   CFLAGS="$save_CFLAGS"
26   CXXFLAGS="$save_CXXFLAGS"
27
28   if test "X$flag_ok" = Xyes ; then
29     $2
30     true
31   else
32     $3
33     true
34   fi
35   AC_MSG_RESULT([$flag_ok])
36 ])
37
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],
41 [
42   TP_COMPILER_FLAG([$2], [$1="[$]$1 $2"])
43 ])