dnl  **************************************************
dnl    Copyright (C) 2004   Matteo Settenvini
dnl  **************************************************

dnl ---------- AX_CHECK_LDFLAG ---------------------
dnl This macro checks if a particular flag for the 
dnl C++ compiler works. If it is so, it adds the flag 
dnl to the end of the first parameter. 
dnl Example of usage : AC_CHECK_LDFLAG([LDFLAGS],[--as-needed])
dnl -------------------------------------------------
AC_DEFUN([AC_CHECK_LDFLAG],
[   if test -z "$1" -o -z "$2"; then
	AC_MSG_FAILURE([Wrong parameters passed to the m4 macro. 
Please contact the package mantainer.])
  fi
  AC_REQUIRE([AC_PROG_CC])dnl
  AC_MSG_CHECKING([whether the linker supports the $2 flag])
  ac_check_ldflags=$LDFLAGS
  LDFLAGS="-Wl,$2"
  AC_LANG_PUSH([C])
  AC_LINK_IFELSE(
    AC_LANG_PROGRAM([], [return 0;]),
    [AC_MSG_RESULT([yes])
      LDFLAGS=$ac_check_ldflags
      $1="-Wl,$2 $[$1]" ],
    [AC_MSG_RESULT([no])
      LDFLAGS=$ac_check_ldflags ]
  )
  AC_LANG_POP
])dnl ------- AC_CHECK_LDFLAG ----------------------

