bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opening a can of worms: a readline gnulib module?


From: Simon Josefsson
Subject: Re: Opening a can of worms: a readline gnulib module?
Date: Fri, 12 Aug 2005 10:01:31 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Simon Josefsson <address@hidden> writes:

>> Also check this:
>>
>> http://ac-archive.sourceforge.net/Installed_Packages/vl_lib_readline.html
>>
>> It also mentions libedit and libeditline (apparently those are other
>> GNU readline-like implementations).
>
> That seem like a quite useful macro, and it solve the termcap problem
> by having two nested for loops.  Nice.  And I hadn't realized
> edit/editline also provided the readline API.  I'll try to work on
> incorporating those ideas in this macro.

I installed the patch below.  It builds on the same platforms, but now
finds the readline library properly on Fedora too.  Supporting
libedit/libeditline too is doable, just add AC_LIB_LINKFLAGS_BODY
checks and another for loop.  But there are some unclean things about
it: at the end, you'll have to copy LIBEDIT or LIBEDITLINE into
LIBREADLINE to avoid requiring the application to link with @LIBEDIT@
@LIBREADLINE@ @address@hidden  Left as an exercise for the reader...

checking for readline... yes
checking how to link with libreadline... -lreadline -ltermcap
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes

2005-08-12  Simon Josefsson  <address@hidden>

        * readline.m4: Look for termcap, curses or ncurses if required.


--- readline.m4 11 Aug 2005 21:30:33 +0200      1.1
+++ readline.m4 12 Aug 2005 09:55:49 +0200      
@@ -1,9 +1,12 @@
-# readline.m4 serial 1
+# readline.m4 serial 2
 dnl Copyright (C) 2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
+dnl Written by Simon Josefsson, with help from Bruno Haible and Oskar
+dnl Liljeblad.
+
 AC_DEFUN([gl_FUNC_READLINE],
 [
   AC_LIBSOURCES([readline.c, readline.h])
@@ -26,22 +29,34 @@
   AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
     gl_cv_lib_readline=no
     am_save_LIBS="$LIBS"
-    LIBS="$LIBS $LIBREADLINE"
+    for extra_lib in "" termcap curses ncurses; do
+      LIBS="$am_save_LIBS $LIBREADLINE"
+      if test -n "$extra_lib"; then
+        LIBS="$LIBS -l$extra_lib"
+      fi
     AC_TRY_LINK([#include <stdio.h>
 #include <readline/readline.h>],
       [readline((char*)0);],
       gl_cv_lib_readline=yes)
+      if test "$gl_cv_lib_readline" = yes; then
+        LIBREADLINE="$LIBREADLINE -l$extra_lib"
+        LTLIBREADLINE="$LTLIBREADLINE -l$extra_lib"
+        break
+      fi
+    done
     LIBS="$am_save_LIBS"
   ])
+
   if test "$gl_cv_lib_readline" = yes; then
-    AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline() library.])
+    AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline library.])
   fi
+
   if test "$gl_cv_lib_readline" = yes; then
     AC_MSG_CHECKING([how to link with libreadline])
     AC_MSG_RESULT([$LIBREADLINE])
   else
-    dnl If $LIBREADLINE didn't lead to a usable library, we don't need 
$INCREADLINE
-    dnl either.
+    dnl If $LIBREADLINE didn't lead to a usable library, we don't
+    dnl need $INCREADLINE either.
     CPPFLAGS="$am_save_CPPFLAGS"
     LIBREADLINE=
     LTLIBREADLINE=




reply via email to

[Prev in Thread] Current Thread [Next in Thread]