[4.0] 76dd3b7 Rework autocrap configuration for libedit/libreadline

Lasse Karstensen lkarsten at varnish-software.com
Mon Sep 22 16:38:23 CEST 2014


commit 76dd3b7be9e27b48e5673949606795df03e2201e
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>
 
-#ifdef HAVE_EDIT_READLINE_READLINE_H
-#  include <edit/readline/readline.h>
+#ifdef HAVE_LIBEDIT
+#  include <editline/readline.h>
 #elif HAVE_READLINE_READLINE_H
 #  include <readline/readline.h>
 #  ifdef HAVE_READLINE_HISTORY_H
 #    include <readline/history.h>
+#  else
+#    error missing history.h - this should have got caught in configure
 #  endif
 #else
-#  include <editline/readline.h>
+#  error missing readline.h - this should have got caught in configure
 #endif
 
 #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_SUBST(PCRE_LIBS)
 
 PKG_CHECK_MODULES([LIBEDIT], [libedit], 
-	[AC_DEFINE([HAVE_LIBEDIT], [1], [Define we have libedit])],
-	[AX_LIB_READLINE])
-if test "$ac_cv_have_readline" = no; then
-  AC_MSG_ERROR([libedit or readline not found])
-fi
+	# 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}"
+	 AX_LIB_READLINE
+	 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.
 AC_HEADER_STDC



More information about the varnish-commit mailing list