Skip to content
Snippets Groups Projects
Commit 620faec9 authored by Jorrit Fahlke's avatar Jorrit Fahlke
Browse files

This should actually have been checked in in revision 5830:

Rewrite the DUNE_CHECK_LIB_EXT macro:

 * Essentially copy and adapt the definition of AC_CHECK_LIB.  This should
   make sure the two macros behave the same even in corner cases (except for
   the added functionality, of course).

 * Properly document what exactly is allowed in the arguments.

[[Imported from SVN: r5833]]
parent 27a168a2
No related branches found
No related tags found
No related merge requests found
dnl -*- autoconf -*-
# DUNE_CHECK_LIB_EXT(PATH, LIBRARY, FUNCTION, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
#
# Just like AC_CHECK_LIB, but in allow a library path to be specified. The
# default ACTION-IF-FOUND is extended to also add that library path to LIBS.
#
# DUNE_CHECK_LIB_EXT(PATH, LIBRARY, FUNCTION, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
# PATH Path to search for the library. This should be something suitable
# to be used inside a double quoted shell string.
#
# LIBRARY Name of the library. This should be something suitable to be used
# inside a double quoted shell string. If this containes shell
# subtitutions, no config.h template will be generated by the default
# action.
#
# FUNCTION Function to check for. This should be something suitable to be
# used inside a double quoted shell string.
#
# ACTION-IF-FOUND Action to perform when the library was found. If empty, set
# prepend "-L{PATH} -l{LIBRARY}" and create a preprocessor define
# HAVE_LIB{LIBRARY} (the preprocessor define's name is passed through
# AS_TR_CPP to make it suitable first).
#
# ACTION-IF-NOT-FOUND Action to perform when the library was not found.
#
# OTHER-LIBRARIES If linking agains LIBRARY will only succeed in the presence
# of other libraries not already in LIBS, specify them here. These
# libraries will not be added to LIBS in the default ACTION-IF-FOUND.
AC_DEFUN([DUNE_CHECK_LIB_EXT],
[
dune_cle_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -L$1"
m4_if(m4_eval([$# <= 3]), [1],
[AC_CHECK_LIB([$2], [$3],
[
LIBS="-L$1 -l$2 $LIBS"
AC_DEFINE([HAVE_LIB]m4_translit([[$2]], [-a-z], [_A-Z]), [1],
[Define to 1 if you have the `$2' library (-l$2).])
])],
[AC_CHECK_LIB(m4_shift($@))])
LDFLAGS="$dune_cle_save_LDFLAGS"
])
[m4_ifval([$4], , [AH_TEMPLATE(AS_TR_CPP([HAVE_LIB$2]),
[Define to 1 if you have the `$2' library (-L$1 -l$2).])])dnl
AS_VAR_PUSHDEF([dune_Lib],
[dune_cv_lib_$1]AS_LITERAL_IF([$1], , [['']])dnl
[_$2]AS_LITERAL_IF([$2], , [['']])dnl
[_$3])dnl
AC_CACHE_CHECK([for $3 in -L$1 -l$2], [dune_Lib],
[dune_check_lib_ext_save_LIBS=$LIBS
LIBS="-L$1 -l$2 $6 $LIBS"
AC_LINK_IFELSE([AC_LANG_CALL([], [$3])],
[AS_VAR_SET([dune_Lib], [yes])],
[AS_VAR_SET([dune_Lib], [no])])
LIBS=$dune_check_lib_ext_save_LIBS])
AS_VAR_IF([dune_Lib], [yes],
[m4_default([$4], [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_LIB$2]))
LIBS="-L$1 -l$2 $LIBS"
])],
[$5])
AS_VAR_POPDEF([dune_Lib])dnl
])# DUNE_CHECK_LIB_EXT
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment