[master] 7c0e75f Rework autocrap configuration for libedit/libreadline

Nils Goroll nils.goroll at uplex.de
Mon Aug 18 21:27:48 CEST 2014

commit 7c0e75f0abc29ead11f945318274cf4e5669eedb
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Aug 18 21:26:17 2014 +0200

    Rework autocrap configuration for libedit/libreadline
    As before, libedit is preferred over libreadline.
    Fail configure if neither is found or if libedit includes are missing.
    Require readline history support (as varnishadm needs it).
    Previously, if only libreadline was found, all binaries were linked
    against it. Now only binaries getting linked with LIBEDIT_LIBS will
    get linked aginst readline if libedit is not found.
    If configure succeeds, a build should not fail any longer due to
    libedit/libreadline headers missing.
    Fixes #1555

diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index 0c2ecc1..26019a5 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -34,15 +34,17 @@
 #include <stdio.h>
-#  include <edit/readline/readline.h>
+#  include <editline/readline.h>
 #  include <readline/readline.h>
 #    include <readline/history.h>
+#  else
+#    error missing history.h - this should have got caught in configure
 #  endif
-#  include <editline/readline.h>
+#  error missing readline.h - this should have got caught in configure
 #include <errno.h>
diff --git a/configure.ac b/configure.ac
index ced8495..c8a36f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,11 +140,25 @@ AC_SUBST(PCRE_CFLAGS)
-	[AC_DEFINE([HAVE_LIBEDIT], [1], [Define we have libedit])],
-if test "$ac_cv_have_readline" = no; then
-  AC_MSG_ERROR([libedit or readline not found])
+	# having the module does not imply having the header
+	[AC_CHECK_HEADERS([editline/readline.h],
+			  [AC_DEFINE([HAVE_LIBEDIT], [1], [Define if we have libedit])],
+			  [AC_MSG_ERROR([Found libedit, but header file is missing. Hint: Install dev package?])])],
+	[
+	 # AX_LIB_READLINE overwrites LIBS which leads to every binary getting
+	 # linked against libreadline uselessly. So we re-use LIBEDIT_LIBS which
+	 # we have for libedit to add the lib specifically where needed
+	 save_LIBS="${LIBS}"
+	 LIBS="${save_LIBS}"
+	 if test "$ax_cv_lib_readline" = "no"; then
+		AC_MSG_ERROR([neither libedit nor another readline compatible library found])
+	 fi
+	 if test "x$ax_cv_lib_readline_history" != "xyes"; then
+		AC_MSG_ERROR([need readline history support])
+	 fi
+	 LIBEDIT_LIBS="$ax_cv_lib_readline"
+	])
 # Checks for header files.

More information about the varnish-commit mailing list