diff --git a/ChangeLog b/ChangeLog
index a2c294945085e2b494ed2ac290fd3837bcb48174..bfea990445c335600ad8a54e8d0f83d44b804331 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-09-18  Niels Möller  <nisse@lysator.liu.se>
+
+	* Makefile.in: New stampfiles, libnettle.stamp and
+	libhogweed.stamp, updated when both static and shared libraries
+	are rebuilt. Used as link dependencies in subdirectories.
+	* examples/Makefile.in: Make executable targets depend on
+	../libnettle.stamp and libhogweed.stamp, not directly on the
+	static library files.
+	* testsuite/Makefile.in: Likewise.
+	* tools/Makefile.in: Likewise.
+
 2013-09-09  Niels Möller  <nisse@lysator.liu.se>
 
 	* gcm.c [HAVE_NATIVE_gcm_gf_mul_8]: Make use of (optional)
diff --git a/Makefile.in b/Makefile.in
index c900c587f55b0935ac5a17678303e108369a62d3..60b954d9644089f7d7c556013c4ca0a05e9e0708 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -190,11 +190,13 @@ libnettle.a: $(nettle_OBJS)
 	-rm -f $@
 	$(AR) $(ARFLAGS) $@ $(nettle_OBJS)
 	$(RANLIB) $@
+	echo nettle > libnettle.stamp
 
 libhogweed.a: $(hogweed_OBJS)
 	-rm -f $@
 	$(AR) $(ARFLAGS) $@ $(hogweed_OBJS)
 	$(RANLIB) $@
+	echo hogweed > libhogweed.stamp
 
 .c.$(OBJEXT):
 	$(COMPILE) $(CCPIC_MAYBE) -c $< \
@@ -210,6 +212,7 @@ $(LIBNETTLE_FORLINK): $(nettle_PURE_OBJS)
 	  && [ -z "$(LIBNETTLE_SONAME)" ] \
 	  || { rm -f $(LIBNETTLE_SONAME) \
 	       && $(LN_S) $(LIBNETTLE_FORLINK) $(LIBNETTLE_SONAME) ; } )
+	echo nettle > libnettle.stamp
 
 $(LIBHOGWEED_FORLINK): $(hogweed_PURE_OBJS) $(LIBNETTLE_FORLINK)
 	$(LIBHOGWEED_LINK) $(hogweed_PURE_OBJS) -o $@ $(LIBHOGWEED_LIBS)
@@ -220,6 +223,7 @@ $(LIBHOGWEED_FORLINK): $(hogweed_PURE_OBJS) $(LIBNETTLE_FORLINK)
 	  && [ -z "$(LIBHOGWEED_SONAME)" ] \
 	  || { rm -f $(LIBHOGWEED_SONAME) \
 	       && $(LN_S) $(LIBHOGWEED_FORLINK) $(LIBHOGWEED_SONAME) ; } )
+	echo hogweed > libhogweed.stamp
 
 .c.p$(OBJEXT):
 	$(COMPILE) $(SHLIBCFLAGS) -c $< -o $@ \
@@ -577,7 +581,7 @@ clean-here:
 	-rm -f $(TARGETS) $(IMPLICIT_TARGETS) *.$(OBJEXT) *.p$(OBJEXT) *.s \
 		ecc-192.h ecc-224.h ecc-256.h ecc-384.h ecc-521.h \
 		eccdata$(EXEEXT_FOR_BUILD) eccdata.stamp
-	-rm -rf .lib
+	-rm -rf .lib libnettle.stamp libhogweed.stamp
 
 distclean-here: clean-here
 	-rm -f config.h stamp-h config.log config.status machine.m4 \
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 563d0dc784b94012d9adf1e0c99c0a88b82921d5..219e613e92327f4eb7db2fc68d3867e5ce73cdb3 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -117,8 +117,8 @@ hogweed-benchmark$(EXEEXT): $(HOGWEED_BENCH_OBJS)
 	-lhogweed -lnettle $(BENCH_LIBS) $(LIBS) $(OPENSSL_LIBFLAGS) \
 	-o hogweed-benchmark$(EXEEXT)
 
-$(TARGETS) : io.$(OBJEXT) ../libnettle.a
-$(HOGWEED_TARGETS): ../libhogweed.a
+$(TARGETS) : io.$(OBJEXT) ../libnettle.stamp
+$(HOGWEED_TARGETS): ../libhogweed.stamp
 
 check: $(TS_ALL)
 	LD_LIBRARY_PATH=../.lib PATH="../.lib:$$PATH" srcdir="$(srcdir)" \
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index bf0e53c6c457f0d2a34dc08581ca61bf2b264581..44fcf48666cbfdac2c70abceb7914d3ca9801937 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -96,7 +96,7 @@ test-rules:
 include $(srcdir)/.test-rules.make
 
 $(TARGETS) $(EXTRA_TARGETS): testutils.$(OBJEXT) ../nettle-internal.$(OBJEXT) \
-	../libnettle.a @IF_HOGWEED@ ../libhogweed.a
+	../libnettle.stamp @IF_HOGWEED@ ../libhogweed.stamp
 
 # For use as, e.g.,
 #
diff --git a/tools/Makefile.in b/tools/Makefile.in
index f7b3352935fd20833b6f3d4f16918f46ab5a51e0..25c00b1dded8ecc76aa22cbbfced9794249fd8bf 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -36,23 +36,23 @@ SOURCES = $(sexp_conv_SOURCES) nettle-hash.c nettle-lfib-stream.c pkcs1-conv.c
 DISTFILES = $(SOURCES) Makefile.in input.h misc.h output.h parse.h
 
 sexp_conv_OBJS = $(sexp_conv_SOURCES:.c=.$(OBJEXT)) $(getopt_OBJS)
-sexp-conv$(EXEEXT): $(sexp_conv_OBJS) ../libnettle.a
+sexp-conv$(EXEEXT): $(sexp_conv_OBJS) ../libnettle.stamp
 	$(LINK) $(sexp_conv_OBJS) -lnettle $(LIBS) -o $@
 
-nettle-lfib-stream$(EXEEXT): nettle-lfib-stream.$(OBJEXT) ../libnettle.a
+nettle-lfib-stream$(EXEEXT): nettle-lfib-stream.$(OBJEXT) ../libnettle.stamp
 	$(LINK) nettle-lfib-stream.$(OBJEXT) -lnettle $(LIBS) -o $@
 
 pkcs1_conv_OBJS = $(pkcs1_conv_SOURCES:.c=.$(OBJEXT)) $(getopt_OBJS)
-pkcs1-conv$(EXEEXT): $(pkcs1_conv_OBJS) ../libnettle.a ../libhogweed.a
+pkcs1-conv$(EXEEXT): $(pkcs1_conv_OBJS) ../libnettle.stamp ../libhogweed.stamp
 	$(LINK) $(pkcs1_conv_OBJS) -lhogweed -lnettle $(LIBS) -o $@
 
 # FIXME: Avoid linking with gmp
 nettle_hash_OBJS = $(nettle_hash_SOURCES:.c=.$(OBJEXT)) $(getopt_OBJS)
-nettle-hash$(EXEEXT): $(nettle_hash_OBJS) ../libnettle.a
+nettle-hash$(EXEEXT): $(nettle_hash_OBJS) ../libnettle.stamp
 	$(LINK) $(nettle_hash_OBJS) -lnettle -o $@
 
 nettle_pbkdf2_OBJS = $(nettle_pbkdf2_SOURCES:.c=.$(OBJEXT)) $(getopt_OBJS)
-nettle-pbkdf2$(EXEEXT): $(nettle_pbkdf2_OBJS) ../libnettle.a
+nettle-pbkdf2$(EXEEXT): $(nettle_pbkdf2_OBJS) ../libnettle.stamp
 	$(LINK) $(nettle_pbkdf2_OBJS) -lnettle -o $@