From bf4817a8f69bc96a62e2c916011c2f4fab89fee8 Mon Sep 17 00:00:00 2001 From: Martin Ebourne Date: Wed, 4 Jan 2006 00:31:49 +0000 Subject: Rewrite configure check for readline lib to match libraries to headers and be more selective. Also changes --enable-gnu-readline which intentionally used to prefer editline over readline even when specified (for licence goodness), to now prefer readline if requested. This is probably less confusing to a user. --- infrastructure/m4/vl_lib_readline.m4 | 75 +++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 23 deletions(-) (limited to 'infrastructure/m4/vl_lib_readline.m4') diff --git a/infrastructure/m4/vl_lib_readline.m4 b/infrastructure/m4/vl_lib_readline.m4 index 7c9217d6..a0571bfa 100644 --- a/infrastructure/m4/vl_lib_readline.m4 +++ b/infrastructure/m4/vl_lib_readline.m4 @@ -1,4 +1,4 @@ -dnl @synopsis VL_LIB_READLINE +dnl @synopsis VL_LIB_READLINE([ACTION-IF-TRUE], [ACTION-IF-FALSE]) dnl dnl Searches for a readline compatible library. If found, defines dnl `HAVE_LIBREADLINE'. If the found library has the `add_history' @@ -46,6 +46,8 @@ dnl dnl Modifications to add --enable-gnu-readline to work around licensing dnl problems between the traditional BSD licence and the GPL. dnl Martin Ebourne, 2005/7/11 +dnl Rewrite to match headers with libraries and be more selective. +dnl Martin Ebourne, 2006/1/4 dnl dnl @category InstalledPackages dnl @author Ville Laurikari @@ -56,16 +58,34 @@ AC_DEFUN([VL_LIB_READLINE], [ AC_ARG_ENABLE( [gnu-readline], AC_HELP_STRING([--enable-gnu-readline], - [Allow use of GNU readline (may violate GNU licence)]) + [Use GNU readline if present (may violate GNU licence)]) ) - vl_gnu_readline_lib="" + vl_cv_lib_readline_compat_found=no if test "x$enable_gnu_readline" = "xyes"; then - vl_gnu_readline_lib=readline + VL_LIB_READLINE_CHECK([readline], + [readline], + [readline/readline.h readline.h], + [readline/history.h history.h]) fi - AC_CACHE_CHECK([for a readline compatible library], - vl_cv_lib_readline, [ + if test "x$vl_cv_lib_readline_compat_found" = "xno"; then + VL_LIB_READLINE_CHECK([editline], + [edit editline], + [editline/readline.h], + [editline/readline.h]) + fi + if test "x$vl_cv_lib_readline_compat_found" = "xyes"; then + m4_ifvaln([$1],[$1],[:])dnl + m4_ifvaln([$2],[else $2])dnl + fi +]) + +dnl VL_LIB_READLINE_CHECK(name, libraries, headers, history headers) +AC_DEFUN([VL_LIB_READLINE_CHECK], [ + AC_CACHE_CHECK([for $1 library], + [vl_cv_lib_$1], [ ORIG_LIBS="$LIBS" - for readline_lib in edit editline $vl_gnu_readline_lib; do + vl_cv_lib_$1="" + for readline_lib in $2; do for termcap_lib in "" termcap curses ncurses; do if test -z "$termcap_lib"; then TRY_LIB="-l$readline_lib" @@ -73,34 +93,43 @@ AC_DEFUN([VL_LIB_READLINE], [ TRY_LIB="-l$readline_lib -l$termcap_lib" fi LIBS="$ORIG_LIBS $TRY_LIB" - AC_TRY_LINK_FUNC(readline, vl_cv_lib_readline="$TRY_LIB") - if test -n "$vl_cv_lib_readline"; then + AC_TRY_LINK_FUNC([readline], [vl_cv_lib_$1="$TRY_LIB"]) + if test -n "$vl_cv_lib_$1"; then break fi done - if test -n "$vl_cv_lib_readline"; then + if test -n "$vl_cv_lib_$1"; then break fi done - if test -z "$vl_cv_lib_readline"; then - vl_cv_lib_readline="no" + if test -z "$vl_cv_lib_$1"; then + vl_cv_lib_$1=no LIBS="$ORIG_LIBS" fi ]) - if test "x$vl_cv_lib_readline" != "xno"; then - AC_DEFINE(HAVE_LIBREADLINE, 1, + vl_cv_lib_readline_compat_found=no + if test "x$vl_cv_lib_$1" != "xno"; then + AC_CHECK_HEADERS([$3], [vl_cv_lib_readline_compat_found=yes]) + fi + + if test "x$vl_cv_lib_readline_compat_found" = "xyes"; then + AC_DEFINE([HAVE_LIBREADLINE], 1, [Define if you have a readline compatible library]) - AC_CHECK_HEADERS(readline.h readline/readline.h) - AC_CACHE_CHECK([whether readline supports history], - vl_cv_lib_readline_history, [ - vl_cv_lib_readline_history="no" - AC_TRY_LINK_FUNC(add_history, vl_cv_lib_readline_history="yes") + + AC_CACHE_CHECK([whether $1 supports history], + [vl_cv_lib_$1_history], [ + vl_cv_lib_$1_history=no + AC_TRY_LINK_FUNC([add_history], [vl_cv_lib_$1_history=yes]) ]) - if test "x$vl_cv_lib_readline_history" = "xyes"; then - AC_DEFINE(HAVE_READLINE_HISTORY, 1, - [Define if your readline library has \`add_history']) - AC_CHECK_HEADERS(history.h readline/history.h) + if test "x$vl_cv_lib_$1_history" = "xyes"; then + vl_cv_lib_$1_history=no + AC_CHECK_HEADERS( + [$4], + [AC_DEFINE([HAVE_READLINE_HISTORY], [1], + [Define if your readline library has add_history])]) fi + else + LIBS="$ORIG_LIBS" fi ])dnl -- cgit v1.2.3