From 7b24dccfb0bb1e827d845dce3732bac73abbcd77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Fri, 13 Jul 2012 23:18:13 +0200
Subject: [PATCH] Always use the installed nettle library, don't look for it in
 the build tree.

---
 .bootstrap      | 30 +++++++++++++-----------------
 ChangeLog       | 12 ++++++++++++
 Makefile.in     |  2 +-
 configure.ac    | 31 +++++++++++--------------------
 src/Makefile.in | 22 ++++++++++------------
 5 files changed, 47 insertions(+), 50 deletions(-)

diff --git a/.bootstrap b/.bootstrap
index 3d0155260..bd0474716 100755
--- a/.bootstrap
+++ b/.bootstrap
@@ -1,10 +1,10 @@
 #! /bin/sh
 
 # Build all automatically generated files that are not present in the
-# CVS repository.
+# repository.
 
 # This script is for use in the source directory, before you run
-# configure. To get started from a fresh CVS checkout, you also need
+# configure. To get started from a fresh checkout, you also need
 # to run configure and make bootstrap from your build directory.
 
 set -e
@@ -27,36 +27,32 @@ relative_symlink() {
 }
 
 relative_symlink misc/run-tests \
-    argp/testsuite nettle/testsuite nettle/examples \
-    spki/testsuite sftp/testsuite src/testsuite
+    argp/testsuite spki/testsuite sftp/testsuite src/testsuite
 
 relative_symlink aclocal.m4 \
-    argp nettle spki sftp
+    argp spki sftp
 
 relative_symlink misc/vsnprintf.c \
     argp sftp
     
-relative_symlink misc/getopt.c \
-    src/testsuite nettle/examples nettle/tools spki/tools
-relative_symlink misc/getopt1.c \
-    src/testsuite nettle/examples nettle/tools spki/tools
-relative_symlink misc/getopt.h \
-    src/testsuite nettle/examples nettle/tools spki/tools
+relative_symlink misc/getopt.c src/testsuite spki/tools
+relative_symlink misc/getopt1.c src/testsuite spki/tools
+relative_symlink misc/getopt.h src/testsuite spki/tools
 
-relative_symlink config.guess nettle spki
-relative_symlink config.sub nettle spki
+relative_symlink config.guess spki
+relative_symlink config.sub spki
 
-relative_symlink install-sh argp nettle spki sftp
-relative_symlink texinfo.tex nettle
+relative_symlink install-sh argp spki sftp
+relative_symlink texinfo.tex
 
-relative_symlink INSTALL nettle spki
+relative_symlink INSTALL spki
 
 if [ "$1" = "links" ] ; then
     # Skip the time consuming autoconf stuff
     exit 0;
 fi
 
-for subdir in argp nettle spki sftp; do
+for subdir in argp spki sftp; do
     (cd $subdir && ./.bootstrap)
 done
 
diff --git a/ChangeLog b/ChangeLog
index 25869e131..0beef4e7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2012-07-13  Niels Möller  <nisse@lysator.liu.se>
 
+	Always use the installed nettle library, don't look for it in the
+	build tree.
+	* .bootstrap: Deleted all references to the nettle subdirectory.
+	* configure.ac: Deleted --with-system-nettle option, and all setup
+	for using a bundled nettle library. Use a regular AC_CHECK_LIB to
+	check for libhogweed (nettle's public key library).
+	* src/Makefile.in (LOCAL_NETTLE_DEP): Deleted variable, and all
+	uses.
+	(PRE_CPPFLAGS): Deleted nettle_builddir.
+	(PRE_LDFLAGS): Likewise.
+	* Makefile.in (SUBDIRS): Deleted nettle.
+
 	* src/testsuite/functions.sh (need_tcputils): Deleted function.
 	* src/testsuite/lshd-random-input-test: Use ./tcpconnect, rather
 	than the possibly installed version from tcputils. Don't use
diff --git a/Makefile.in b/Makefile.in
index 4c1ee486f..bdd785efd 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -13,7 +13,7 @@ AUTOCONF = autoconf
 # The directories that make all should recurse into
 BUILD_SUBDIRS = @BUILD_SUBDIRS@ src sftp doc
 
-SUBDIRS = argp nettle spki src sftp doc contrib misc
+SUBDIRS = argp spki src sftp doc contrib misc
 
 all check:
 	set -e; for d in $(BUILD_SUBDIRS); do \
diff --git a/configure.ac b/configure.ac
index 7eb79d4e6..8e87c6172 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,10 +145,6 @@ AC_ARG_WITH(system-argp,
   AC_HELP_STRING([--with-system-argp], [Use the argp parser in libc]),,
   [with_system_argp=no])
 
-AC_ARG_WITH(system-nettle,
-  AC_HELP_STRING([--with-system-nettle], [Use the installed nettle library]),,
-  [with_system_nettle=no])
-
 AC_ARG_WITH(system-libspki,
   AC_HELP_STRING([--with-system-libspki], [Use the installed spki library]),,
   [with_system_libspki=no])
@@ -416,12 +412,22 @@ AC_SEARCH_LIBS(gethostbyname, nsl)
 AC_SEARCH_LIBS(inet_ntop, nsl)
 AC_CHECK_LIB(socket, setsockopt)
 
+# FIXME: Don't add any of gmp, nettle or hogweed to LIBS, since not
+# all programs need them. But maybe need them in LIBS temporarily, for
+# LSH_RPATH_FIX to work.
+
 AC_CHECK_LIB(gmp, __gmpz_getlimbn,,
     [AC_MSG_ERROR(
     [GNU MP not found, or not 3.1 or up, see http://gmplib.org/.])])
 
 LSH_RPATH_FIX
 
+AC_CHECK_LIB(hogweed, nettle_dsa_sha1_sign, [true],
+    [AC_MSG_ERROR(
+    [Nettle library not found; needs version 2.2 or later. See http://www.lysator.liu.se/~nisse/nettle/.])], [-lnettle -lgmp])
+
+LSH_RPATH_FIX
+
 AC_CHECK_LIB([oop], [oop_sys_new],,
   [AC_MSG_ERROR([liboop is missing. Get liboop from http://liboop.ofb.net])])
 
@@ -619,20 +625,6 @@ if test x$with_system_argp = xno ; then
   LIB_ARGP="-largp"
 fi
 
-LOCAL_NETTLE_DEP=''
-
-if test x$with_system_nettle = xno ; then
-  AC_CONFIG_COMMANDS([nettle-symlinks],
-  [nettle_srcdir="`cd "$srcdir/nettle" && pwd`"
-  for d in spki src ; do
-    (mkdir $d 2>/dev/null; cd $d && rm -f nettle nettle_builddir && ln -s ../nettle nettle_builddir && ln -s $nettle_srcdir nettle)
-  done])
-  BUILD_SUBDIRS="$BUILD_SUBDIRS nettle"
-  LOCAL_NETTLE_DEP="nettle_builddir/libnettle.a nettle_builddir/libhogweed.a"
-fi
-
-AC_SUBST(LOCAL_NETTLE_DEP)
-
 if test x$with_system_libspki = xno ; then
   AC_CONFIG_COMMANDS([libspki-symlinks],
   [spki_srcdir="`cd "$srcdir/spki" && pwd`"
@@ -1165,8 +1157,7 @@ if test x$enable_ipv6 = xyes ; then
   AC_DEFINE(WITH_IPV6)
 fi
 
-# Unconditionally configure nettle; otherwise make dist won't work
-AC_CONFIG_SUBDIRS(argp nettle spki sftp)
+AC_CONFIG_SUBDIRS(argp spki sftp)
 
 # Set these flags *last*, or else the test programs won't compile
 if test x$GCC = xyes ; then
diff --git a/src/Makefile.in b/src/Makefile.in
index a374e2764..6dec04106 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -18,8 +18,6 @@ MKDIR_P = @MKDIR_P@
 
 AUTOHEADER = autoheader
 
-LOCAL_NETTLE_DEP = @LOCAL_NETTLE_DEP@
-
 SUBDIRS = testsuite
 
 include config.make
@@ -29,8 +27,8 @@ include $(srcdir)/.dist_headers
 
 # The *_builddir directories, if they exist at all, are symlinks
 # created by the configure script.
-PRE_CPPFLAGS = -I. -Iargp_builddir -Inettle_builddir -Ispki_builddir
-PRE_LDFLAGS = -Largp_builddir -Lnettle_builddir -Lspki_builddir
+PRE_CPPFLAGS = -I. -Iargp_builddir -Ispki_builddir
+PRE_LDFLAGS = -Largp_builddir -Lspki_builddir
 
 SCHEME = $(SCHEME_PROGRAM) -l $(srcdir)/scm/$(SCHEME_NAME)-compat.scm
 
@@ -304,28 +302,28 @@ packet_types.h: ssh.h invert-defs
 lsh$(EXEEXT): $(lsh_OBJS)
 	$(LINK) $(lsh_OBJS) $(LIBS) -o $@
 
-lsh-transport$(EXEEXT): $(lsh_transport_OBJS) $(LOCAL_NETTLE_DEP)
+lsh-transport$(EXEEXT): $(lsh_transport_OBJS)
 	$(LINK) $(lsh_transport_OBJS) -lspki -lhogweed -lnettle $(LIBS) -o $@
 
-lsh-keygen$(EXEEXT): $(lsh_keygen_OBJS) $(LOCAL_NETTLE_DEP)
+lsh-keygen$(EXEEXT): $(lsh_keygen_OBJS)
 	$(LINK) $(lsh_keygen_OBJS) -lspki -lhogweed -lnettle $(LIBS) -o $@
 
-lsh-decrypt-key$(EXEEXT): $(lsh_decrypt_key_OBJS) $(LOCAL_NETTLE_DEP)
+lsh-decrypt-key$(EXEEXT): $(lsh_decrypt_key_OBJS)
 	$(LINK) $(lsh_decrypt_key_OBJS) -lspki -lhogweed -lnettle $(LIBS) -o $@
 
-lsh-decode-key$(EXEEXT): $(lsh_decode_key_OBJS) $(LOCAL_NETTLE_DEP)
+lsh-decode-key$(EXEEXT): $(lsh_decode_key_OBJS)
 	$(LINK) $(lsh_decode_key_OBJS) -lspki -lhogweed -lnettle $(LIBS) -o $@
 
-lsh-export-key$(EXEEXT): $(lsh_export_key_OBJS) $(LOCAL_NETTLE_DEP)
+lsh-export-key$(EXEEXT): $(lsh_export_key_OBJS)
 	$(LINK) $(lsh_export_key_OBJS) -lspki -lhogweed -lnettle $(LIBS) -o $@
 
-lsh-make-seed$(EXEEXT): $(lsh_make_seed_OBJS) $(LOCAL_NETTLE_DEP)
+lsh-make-seed$(EXEEXT): $(lsh_make_seed_OBJS)
 	$(LINK) $(lsh_make_seed_OBJS) -lspki -lhogweed -lnettle $(LIBS) -o $@
 
-lshd$(EXEEXT): $(lshd_OBJS) $(LOCAL_NETTLE_DEP)
+lshd$(EXEEXT): $(lshd_OBJS)
 	$(LINK) $(lshd_OBJS) -lspki -lhogweed -lnettle $(LIBS) -o $@
 
-lshd-userauth$(EXEEXT): $(lshd_userauth_OBJS) $(LOCAL_NETTLE_DEP)
+lshd-userauth$(EXEEXT): $(lshd_userauth_OBJS)
 	$(LINK) $(lshd_userauth_OBJS) -lspki -lhogweed -lnettle $(LIBS) -o $@
 
 lshd-connection$(EXEEXT): $(lshd_connection_OBJS)
-- 
GitLab