[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
readline: Adaption for NetBSD.
Mats Erik Andersson
readline: Adaption for NetBSD.
Tue, 6 Mar 2012 01:39:42 +0100
I would like to propose a modification to the M4 file
for the module `readline', which provides a functional
detection also for NetBSD. The main obstacle is that
NetBSD uses the library `editline', and offer readline
functionality as a wrapper based on said library. The
present state of the Gnulib module is not able to detect
We have been using a somewhat similar local script
in GNU Inetutils, successfully since four months,
but I still had to introduce changes in order to
cope with caching issues.
I found that AC_CACHE_CHECK must be performed prior
to AC_LIB_LINKFLAGS_BODY, since `-lreadline' is no
longer the basis. Also, the string `, requires ...'
must be removed to avoid duplicates; removed once
applied, that is. (Visible in OpenBSD.)
There ought to be more room for better caching,
but this is a functional starter. It behaves
correctly for GNU/Linux with and without `<readline/readline.h>'.
Mats Erik Andersson, for GNU Inetutils
diff --git a/m4/readline.m4 b/m4/readline.m4
index 903886d..e2c12cc 100644
@@ -1,4 +1,4 @@
-# readline.m4 serial 10
+# readline.m4 serial 11
dnl Copyright (C) 2005-2006, 2009-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -13,18 +13,18 @@ AC_DEFUN([gl_FUNC_READLINE],
- dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
- dnl INCREADLINE accordingly.
+ AC_CACHE_CHECK([for readline], [gl_cv_lib_readline], [
+ dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
+ dnl INCREADLINE accordingly.
- dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
- dnl because if the user has installed libreadline and not disabled its use
- dnl via --without-libreadline-prefix, he wants to use it. The AC_LINK_IFELSE
- dnl will then succeed.
- AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE])
+ dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
+ dnl because if the user has installed libreadline and not disabled its use
+ dnl via --without-libreadline-prefix, he wants to use it. The
+ dnl will then succeed.
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE])
- AC_CACHE_CHECK([for readline], [gl_cv_lib_readline], [
dnl On some systems, -lreadline doesn't link without an additional
@@ -53,12 +53,31 @@ AC_DEFUN([gl_FUNC_READLINE],
+ dnl In case of failure, examine whether libedit can act
+ dnl as replacement. Small NetBSD systems use editline
+ dnl as wrapper for readline.
+ if test "$gl_cv_lib_readline" = no; then
+ LIBS="$am_save_LIBS -ledit -ltermcap"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
+ dnl This wrapper does not reference libreadline at all.
+ dnl Set the correct linking according to editline(3).
+ LIBREADLINE='-ledit -ltermcap'
+ LTLIBREADLINE='-ledit -ltermcap'
if test "$gl_cv_lib_readline" != no; then
AC_DEFINE([HAVE_READLINE], , [Define if you have the readline library.])
extra_lib=`echo "$gl_cv_lib_readline" | sed -n -e 's/yes, requires //p'`
if test -n "$extra_lib"; then
+ # Prevent duplicates next time around.
+ gl_cv_lib_readline=`echo "$gl_cv_lib_readline" | sed -e
AC_MSG_CHECKING([how to link with libreadline])
|[Prev in Thread]
||[Next in Thread]|
- readline: Adaption for NetBSD.,
Mats Erik Andersson <=