From e0c60792f3a2ebfd30ffb304c4d307bde405a531 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:06:48 +0200
Subject: [PATCH] Adapted libspki to always use the installed nettle library,
 don't look for it in the build tree.

---
 spki/ChangeLog                      | 23 +++++++++++++++++++++++
 spki/Makefile.in                    |  3 +--
 spki/certificate.c                  |  6 +++---
 spki/certificate.h                  |  8 ++++----
 spki/configure.ac                   |  9 +++++----
 spki/parse-transport.c              |  2 +-
 spki/parse.c                        |  2 +-
 spki/parse.h                        |  2 +-
 spki/tag.c                          |  4 ++--
 spki/tag.h                          |  4 ++--
 spki/testsuite/Makefile.in          |  7 +++----
 spki/testsuite/check-signature-test |  2 +-
 spki/testsuite/delegate-test        |  4 ++--
 spki/testsuite/make-signature-test  |  4 ++--
 spki/testsuite/reduce-test          |  6 +++---
 spki/testsuite/testutils.h          |  2 +-
 spki/tools/Makefile.in              |  4 ++--
 spki/verify.c                       |  6 +++---
 18 files changed, 60 insertions(+), 38 deletions(-)

diff --git a/spki/ChangeLog b/spki/ChangeLog
index c7f69c88d..4aa0ce1f7 100644
--- a/spki/ChangeLog
+++ b/spki/ChangeLog
@@ -1,5 +1,28 @@
 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.
+	* configure.ac: Use a regular AC_CHECK_LIB to check for nettle.
+	Deleted check for nettle_buildir.
+	* certificate.h, certificate.c: Use angles, <>, when including
+	nettle header files.
+	* parse.h, parse-transport.c, parse.c: Likewise.
+	* tag.h, tag.c, verify,c: Likewise.
+	* testsuite/testutils.h: Likewise.
+	* Makefile.in (PRE_CPPFLAGS): Delete reference to nettle_buildir.
+	(PRE_LDFLAGS): Deleted.
+ 	* testsuite/Makefile.in (PRE_CPPFLAGS): Delete reference to
+	nettle_buildir.
+	(PRE_LDFLAGS): Likewise.
+	(check): Don't set LD_LIBRARY_PATH (used to point at
+	nettle_buildir/.lib).
+	* tools/Makefile.in (PRE_CPPFLAGS): Delete reference to nettle_buildir.
+	(PRE_LDFLAGS): Likewise.
+	* testsuite/check-signature-test: Use installed sexp-conv.
+	* testsuite/delegate-test: Likewise.
+	* testsuite/make-signature-test: Likewise.
+	* testsuite/reduce-test: Likewise.
+
 	* Fixed copyright headers on many files, used to say "The nettle
 	library is free software". Now refers to the "libspki library"
 	instead.
diff --git a/spki/Makefile.in b/spki/Makefile.in
index 4d225374e..75bae3c18 100644
--- a/spki/Makefile.in
+++ b/spki/Makefile.in
@@ -14,8 +14,7 @@ MKDIR_P = @MKDIR_P@
 
 SUBDIRS = tools testsuite
 
-PRE_CPPFLAGS = -I. -I$(srcdir) -Inettle_builddir
-PRE_LDFLAGS = -Lnettle_builddir
+PRE_CPPFLAGS = -I. -I$(srcdir)
 
 include config.make
 
diff --git a/spki/certificate.c b/spki/certificate.c
index b68ada72f..72988300b 100644
--- a/spki/certificate.c
+++ b/spki/certificate.c
@@ -28,9 +28,9 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "nettle/md5.h"
-#include "nettle/sha.h"
-#include "nettle/sexp.h"
+#include <nettle/md5.h>
+#include <nettle/sha.h>
+#include <nettle/sexp.h>
 
 #include "certificate.h"
 #include "parse.h"
diff --git a/spki/certificate.h b/spki/certificate.h
index 014f62c67..56330435e 100644
--- a/spki/certificate.h
+++ b/spki/certificate.h
@@ -24,10 +24,10 @@
 #define LIBSPKI_CERTIFICATE_H_INCLUDED
 
 
-#include "nettle/md5.h"
-#include "nettle/sha.h"
-#include "nettle/realloc.h"
-#include "nettle/buffer.h"
+#include <nettle/md5.h>
+#include <nettle/sha.h>
+#include <nettle/realloc.h>
+#include <nettle/buffer.h>
 
 /* This should be the only file ever including spki-types.h
  * directly. */
diff --git a/spki/configure.ac b/spki/configure.ac
index 9314bfa4a..8b3a46667 100644
--- a/spki/configure.ac
+++ b/spki/configure.ac
@@ -73,10 +73,11 @@ AC_CHECK_LIB(gmp, __gmpz_getlimbn,,
 # Add -R flags needed to run programs linked with gmp
 LSH_RPATH_FIX
 
-if test -d nettle_buildir; then
-  CPPFLAGS="$CCPFLAGS -Inettle_builddir"
-  LD_FLAGS="$LDFLAGS -Lnettle_builddir"
-fi
+AC_CHECK_LIB(nettle, nettle_sha1_digest,,
+    [AC_MSG_ERROR(
+    [Nettle library not found. See http://www.lysator.liu.se/~nisse/nettle/.])])
+
+LSH_RPATH_FIX
 
 # Set these flags *last*, or else the test programs won't compile
 if test x$GCC = xyes ; then
diff --git a/spki/parse-transport.c b/spki/parse-transport.c
index 911abf184..d54a0819b 100644
--- a/spki/parse-transport.c
+++ b/spki/parse-transport.c
@@ -26,7 +26,7 @@
 
 #include "parse.h"
 
-#include "nettle/sexp.h"
+#include <nettle/sexp.h>
 
 enum spki_type
 spki_transport_iterator_first(struct spki_iterator *i,
diff --git a/spki/parse.c b/spki/parse.c
index 5ce7b3c19..fb36dd576 100644
--- a/spki/parse.c
+++ b/spki/parse.c
@@ -27,7 +27,7 @@
 #include <assert.h>
 #include <string.h>
 
-#include "nettle/sexp.h"
+#include <nettle/sexp.h>
 
 #include "parse.h"
 #include "tag.h"
diff --git a/spki/parse.h b/spki/parse.h
index ee13c5502..6f44bbd01 100644
--- a/spki/parse.h
+++ b/spki/parse.h
@@ -23,7 +23,7 @@
 #ifndef LIBSPKI_PARSE_H_INCLUDED
 #define LIBSPKI_PARSE_H_INCLUDED
 
-#include "nettle/sexp.h"
+#include <nettle/sexp.h>
 
 #include "certificate.h"
 
diff --git a/spki/tag.c b/spki/tag.c
index e2a9228a4..f3c354fea 100644
--- a/spki/tag.c
+++ b/spki/tag.c
@@ -30,8 +30,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "nettle/buffer.h"
-#include "nettle/sexp.h"
+#include <nettle/buffer.h>
+#include <nettle/sexp.h>
 
 #include "tag.h"
 
diff --git a/spki/tag.h b/spki/tag.h
index 5f8444998..580d4e66c 100644
--- a/spki/tag.h
+++ b/spki/tag.h
@@ -27,8 +27,8 @@
 
 struct sexp_iterator;
 
-#include "nettle/realloc.h"
-#include "nettle/buffer.h"
+#include <nettle/realloc.h>
+#include <nettle/buffer.h>
 
 struct spki_tag;
 
diff --git a/spki/testsuite/Makefile.in b/spki/testsuite/Makefile.in
index 2e74e9f91..33a058e7c 100644
--- a/spki/testsuite/Makefile.in
+++ b/spki/testsuite/Makefile.in
@@ -7,8 +7,8 @@ top_srcdir = @top_srcdir@
 
 include ../config.make
 
-PRE_CPPFLAGS = -I.. -I$(top_srcdir) -I../nettle_builddir
-PRE_LDFLAGS = -L.. -L../nettle_builddir
+PRE_CPPFLAGS = -I.. -I$(top_srcdir)
+PRE_LDFLAGS = -L..
 
 TS_SOURCES = principal-test.c date-test.c tag-test.c read-acl-test.c \
 	     lookup-acl-test.c read-cert-test.c cdsa-reduce-test.c
@@ -52,8 +52,7 @@ test-rules:
 include $(srcdir)/.test-rules.make
 
 check: $(TS_ALL)
-	LD_LIBRARY_PATH=../nettle_builddir/.lib srcdir=$(srcdir) \
-		$(srcdir)/run-tests $(TS_ALL)
+	srcdir=$(srcdir) $(srcdir)/run-tests $(TS_ALL)
 
 Makefile: $(srcdir)/Makefile.in ../config.status
 	cd .. && $(SHELL) ./config.status testsuite/$@
diff --git a/spki/testsuite/check-signature-test b/spki/testsuite/check-signature-test
index 28776a1e2..318fc79f1 100755
--- a/spki/testsuite/check-signature-test
+++ b/spki/testsuite/check-signature-test
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 conv () {
-    echo "$1" | ../../nettle/tools/sexp-conv -s transport | tee test.in
+    echo "$1" | sexp-conv -s transport | tee test.in
 }
 
 die () {
diff --git a/spki/testsuite/delegate-test b/spki/testsuite/delegate-test
index 71c32d9ce..0a786e6a2 100755
--- a/spki/testsuite/delegate-test
+++ b/spki/testsuite/delegate-test
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 conv () {
-    ../../nettle/tools/sexp-conv -s transport | tee test.in
+    sexp-conv -s transport | tee test.in
 }
 
 die () {
@@ -12,7 +12,7 @@ die () {
 check_sexp () {
     file="$1"
     shift
-    ../../nettle/tools/sexp-conv -s canonical > test.canonical || die "sexp-conv failed"
+    sexp-conv -s canonical > test.canonical || die "sexp-conv failed"
     cmp "$file" test.canonical || die "$@"
 }
     
diff --git a/spki/testsuite/make-signature-test b/spki/testsuite/make-signature-test
index 74c7a0494..d2e2a5b5c 100755
--- a/spki/testsuite/make-signature-test
+++ b/spki/testsuite/make-signature-test
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 conv () {
-    echo "$1" | ../../nettle/tools/sexp-conv -s transport | tee test.in
+    echo "$1" sexp-conv -s transport | tee test.in
 }
 
 die () {
@@ -10,7 +10,7 @@ die () {
 }
 
 echo foo | ../tools/spki-make-signature "$srcdir/key-1" \
-         | ../../nettle/tools/sexp-conv -s transport > test.in
+         | sexp-conv -s transport > test.in
 
 echo foo | ../tools/spki-check-signature "`cat test.in`" \
      || die "Valid signature failed"
diff --git a/spki/testsuite/reduce-test b/spki/testsuite/reduce-test
index aaa53a453..71737450f 100755
--- a/spki/testsuite/reduce-test
+++ b/spki/testsuite/reduce-test
@@ -1,9 +1,9 @@
 #! /bin/sh
 
-# Test case from Oscar C�novas Reverte
+# Test case from Oscar Cánovas Reverte
 
 conv () {
-    ../../nettle/tools/sexp-conv -s transport
+    sexp-conv -s transport
 }
 
 die () {
@@ -14,7 +14,7 @@ die () {
 check_sexp () {
     file="$1"
     shift
-    ../../nettle/tools/sexp-conv -s canonical > test.canonical || die "sexp-conv failed"
+    sexp-conv -s canonical > test.canonical || die "sexp-conv failed"
     cmp "$file" test.canonical || die "$@"
 }
 
diff --git a/spki/testsuite/testutils.h b/spki/testsuite/testutils.h
index a64c92164..99be5299e 100644
--- a/spki/testsuite/testutils.h
+++ b/spki/testsuite/testutils.h
@@ -6,7 +6,7 @@
 #include "parse.h"
 #include "tag.h"
 
-#include "nettle/sexp.h"
+#include <nettle/sexp.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/spki/tools/Makefile.in b/spki/tools/Makefile.in
index 4add7746d..6f87507c6 100644
--- a/spki/tools/Makefile.in
+++ b/spki/tools/Makefile.in
@@ -7,8 +7,8 @@ top_srcdir = @top_srcdir@
 
 include ../config.make
 
-PRE_CPPFLAGS = -I.. -I$(top_srcdir) -I../nettle_builddir
-PRE_LDFLAGS = -L.. -L../nettle_builddir
+PRE_CPPFLAGS = -I.. -I$(top_srcdir)
+PRE_LDFLAGS = -L..
 
 PROGRAM_LIBS = -lspki -lhogweed -lnettle $(LIBS)
 
diff --git a/spki/verify.c b/spki/verify.c
index e56c57e36..f516c9038 100644
--- a/spki/verify.c
+++ b/spki/verify.c
@@ -24,9 +24,9 @@
 # include "config.h"
 #endif
 
-#include "nettle/bignum.h"
-#include "nettle/dsa.h"
-#include "nettle/rsa.h"
+#include <nettle/bignum.h>
+#include <nettle/dsa.h>
+#include <nettle/rsa.h>
 
 #include "certificate.h"
 #include "parse.h"
-- 
GitLab