(not as ambarrassing as breaking master, but still I forgot the attachment this
time)

After an embarrassingly failing initial attempt, here's a patch to (hopefully)
fix #1555 and other build issues regarding libedit vs. libreadline.

@fgs: As discussed on irc, would be cool if you could check this on the build 
farm

@all: would appreciate more test on different configs, especially more exotic
ones like bsd, macos and the like

Nils

_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
>From 51cca2159306f0f7e2611e82d4ed157ee6dd8fe0 Mon Sep 17 00:00:00 2001
From: Nils Goroll <[email protected]>
Date: Tue, 5 Aug 2014 17:42:01 +0200
Subject: [PATCH] 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
---
 bin/varnishadm/varnishadm.c |  8 +++++---
 configure.ac                | 24 +++++++++++++++++++-----
 2 files changed, 24 insertions(+), 8 deletions(-)

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
-- 
2.0.1

_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to