diff --git a/examples/Makefile.am b/examples/Makefile.am
index 6a228ea1873c40cf4f2b96b2b51fdcec5a0ce0dd..63f53769b374aea9705041b04951bbfb02c3b776 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,11 +1,16 @@
 CFLAGS = -I$(top_srcdir) @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 
+# We need .. to be searched before standard places, in order to pick
+# up the newly built libnettle.a/libnettle.so, rather than any
+# installed version.
+AM_LDFLAGS = -L..
+
 EXTRA_PROGRAMS = rsa-keygen rsa-sign rsa-verify
 noinst_PROGRAMS = nettle-benchmark sexp-conv @RSA_EXAMPLES@
 
-LDADD = io.o ../libnettle.a
-nettle_benchmark_LDADD = ../libnettle.a
+LDADD = io.o -lnettle
+nettle_benchmark_LDADD = -lnettle
 
 TS_PROGS = rsa-sign-test rsa-verify-test sexp-conv-test
 
@@ -13,6 +18,7 @@ EXTRA_DIST = io.c io.h run-tests setup-env teardown-env $(TS_PROGS)
 
 .PHONY: run-tests
 run-tests: $(TS_PROGS)
-	srcdir="$(srcdir)" "$(srcdir)"/run-tests $(TS_PROGS)
+	LD_LIBRARY_PATH=../.lib srcdir="$(srcdir)" \
+	  "$(srcdir)"/run-tests $(TS_PROGS)
 
 check: run-tests
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 51b505dd5b81f170a723534e8d14076810ae31fa..46d7d6ee8dc690ca36e873fe3c0aa91a4b818bfe 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -1,6 +1,11 @@
 CFLAGS = -I$(top_srcdir) @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 
+# We need .. to be searched before standard places, in order to pick
+# up the newly built libnettle.a/libnettle.so, rather than any
+# installed version.
+AM_LDFLAGS = -L..
+
 TS_PROGS = aes-test arcfour-test blowfish-test cast128-test \
            base16-test base64-test \
 	   des-test des3-test des-compat-test \
@@ -16,12 +21,13 @@ TS_PROGS = aes-test arcfour-test blowfish-test cast128-test \
 
 noinst_PROGRAMS = $(TS_PROGS)
 
-LDADD = testutils.o ../libnettle.a
+LDADD = testutils.o -lnettle
 EXTRA_DIST = testutils.c testutils.h \
 	     run-tests rfc1750.txt
 
 .PHONY: run-tests
 run-tests: $(TS_PROGS)
-	srcdir="$(srcdir)" "$(srcdir)"/run-tests $(TS_PROGS)
+	LD_LIBRARY_PATH=../.lib srcdir="$(srcdir)" \
+	  "$(srcdir)"/run-tests $(TS_PROGS)
 
 check: run-tests