1dnl A version of AS_COMPILER_FLAG that supports linker flags
2dnl Based on:
3
4dnl as-compiler-flag.m4 0.1.0
5dnl autostars m4 macro for detection of compiler flags
6dnl David Schleef <ds@schleef.org>
7dnl $Id: as-compiler-flag.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $
8
9dnl TP_LINKER_FLAG(LDFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
10dnl Tries to compile with the given LDFLAGS.
11dnl
12dnl Runs ACTION-IF-ACCEPTED if the compiler/linker for the currently selected
13dnl AC_LANG can compile with the flags, and ACTION-IF-NOT-ACCEPTED otherwise.
14dnl
15dnl Note that LDFLAGS are passed to the linker via the compiler, so you
16dnl should check for -Wl,--no-add-needed rather than --no-add-needed.
17
18AC_DEFUN([TP_LINKER_FLAG],
19[
20  AC_MSG_CHECKING([to see if compiler/linker understand $1])
21
22  save_LDFLAGS="$LDFLAGS"
23  LDFLAGS="$LDFLAGS $1"
24
25  AC_COMPILE_IFELSE(AC_LANG_SOURCE([]), [flag_ok=yes], [flag_ok=no])
26
27  LDFLAGS="$save_LDFLAGS"
28
29  if test "X$flag_ok" = Xyes ; then
30    $2
31    true
32  else
33    $3
34    true
35  fi
36  AC_MSG_RESULT([$flag_ok])
37])
38
39dnl TP_ADD_LINKER_FLAG(VARIABLE, LDFLAGS)
40dnl Append LDFLAGS to VARIABLE if the linker supports them.
41AC_DEFUN([TP_ADD_LINKER_FLAG],
42[
43  TP_LINKER_FLAG([$2], [$1="[$]$1 $2"])
44])
45