From 73bba12d8ba1bff2b2c0266a7fdbe1ee8ab0ad6a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 28 Apr 2017 16:53:56 +0200 Subject: [PATCH] Check for libreadline --- Makefile.config.in | 1 + configure.ac | 8 ++++++++ nix.spec.in | 2 ++ release.nix | 6 +++--- shell.nix | 2 +- src/nix/local.mk | 4 +++- src/nix/repl.cc | 4 ++++ 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Makefile.config.in b/Makefile.config.in index 6948dad5a..3cae30d48 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -5,6 +5,7 @@ CXX = @CXX@ CXXFLAGS = @CXXFLAGS@ ENABLE_S3 = @ENABLE_S3@ HAVE_SODIUM = @HAVE_SODIUM@ +HAVE_READLINE = @HAVE_READLINE@ LIBCURL_LIBS = @LIBCURL_LIBS@ OPENSSL_LIBS = @OPENSSL_LIBS@ PACKAGE_NAME = @PACKAGE_NAME@ diff --git a/configure.ac b/configure.ac index c7026cf95..ac37456ae 100644 --- a/configure.ac +++ b/configure.ac @@ -196,6 +196,14 @@ if test "$gc" = yes; then fi +# Check for readline, needed by "nix repl". +AX_LIB_READLINE +if test "$ax_cv_lib_readline" != "no"; then + have_readline=1 +fi +AC_SUBST(HAVE_READLINE, [$have_readline]) + + AC_ARG_ENABLE(init-state, AC_HELP_STRING([--disable-init-state], [do not initialise DB etc. in `make install']), init_state=$enableval, init_state=yes) diff --git a/nix.spec.in b/nix.spec.in index 390893d64..3ba2dfc94 100644 --- a/nix.spec.in +++ b/nix.spec.in @@ -20,9 +20,11 @@ Requires: curl Requires: bzip2 Requires: gzip Requires: xz +Requires: readline BuildRequires: bzip2-devel BuildRequires: sqlite-devel BuildRequires: libcurl-devel +BuildRequires: readline-devel # Hack to make that shitty RPM scanning hack shut up. Provides: perl(Nix::SSH) diff --git a/release.nix b/release.nix index 534c218c1..7adc87386 100644 --- a/release.nix +++ b/release.nix @@ -299,7 +299,7 @@ let src = jobs.tarball; diskImage = (diskImageFun vmTools.diskImageFuns) { extraPackages = - [ "sqlite" "sqlite-devel" "bzip2-devel" "emacs" "libcurl-devel" "openssl-devel" "xz-devel" ] + [ "sqlite" "sqlite-devel" "bzip2-devel" "emacs" "libcurl-devel" "openssl-devel" "xz-devel" "readline-devel" ] ++ extraPackages; }; memSize = 1024; meta.schedulingPriority = 50; @@ -321,14 +321,14 @@ let src = jobs.tarball; diskImage = (diskImageFun vmTools.diskImageFuns) { extraPackages = - [ "libsqlite3-dev" "libbz2-dev" "libcurl-dev" "libcurl3-nss" "libssl-dev" "liblzma-dev" ] + [ "libsqlite3-dev" "libbz2-dev" "libcurl-dev" "libcurl3-nss" "libssl-dev" "liblzma-dev" "libreadline-dev" ] ++ extraPackages; }; memSize = 1024; meta.schedulingPriority = 50; postInstall = "make installcheck"; configureFlags = "--sysconfdir=/etc"; debRequires = - [ "curl" "libsqlite3-0" "libbz2-1.0" "bzip2" "xz-utils" "libssl1.0.0" "liblzma5" ] + [ "curl" "libsqlite3-0" "libbz2-1.0" "bzip2" "xz-utils" "libssl1.0.0" "liblzma5" "libreadline6" ] ++ extraDebPackages; debMaintainer = "Eelco Dolstra "; doInstallCheck = true; diff --git a/shell.nix b/shell.nix index 37a936fd2..bbce68564 100644 --- a/shell.nix +++ b/shell.nix @@ -35,7 +35,7 @@ with import {}; shellHook = '' export prefix=$(pwd)/inst - configureFlags+=" --prefix=prefix" + configureFlags+=" --prefix=$prefix" PKG_CONFIG_PATH=$prefix/lib/pkgconfig:$PKG_CONFIG_PATH PATH=$prefix/bin:$PATH ''; diff --git a/src/nix/local.mk b/src/nix/local.mk index 21f190e47..e71cf16fa 100644 --- a/src/nix/local.mk +++ b/src/nix/local.mk @@ -6,6 +6,8 @@ nix_SOURCES := $(wildcard $(d)/*.cc) nix_LIBS = libexpr libmain libstore libutil libformat -nix_LDFLAGS = -lreadline +ifeq ($(HAVE_READLINE), 1) + nix_LDFLAGS += -lreadline +endif $(eval $(call install-symlink, nix, $(bindir)/nix-hash)) diff --git a/src/nix/repl.cc b/src/nix/repl.cc index 17203d3c2..13488bf1d 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -1,3 +1,5 @@ +#if HAVE_LIBREADLINE + #include #include @@ -726,3 +728,5 @@ struct CmdRepl : StoreCommand static RegisterCommand r1(make_ref()); } + +#endif