From dfa7f945417d75d586617262a424772470f96fd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Fri, 25 Nov 2005 18:10:59 +0100
Subject: [PATCH] * testsuite/Makefile.in: Use %-rules for building the -test
 executables, in addition to the suffix rules. Hopefully, this should make all
 of GNU make, BSD make and Solaris make happy. Use $(EXEEXT) and $(OBJEXT)
 more consistently.

Rev: src/nettle/examples/Makefile.in:1.12
Rev: src/nettle/testsuite/Makefile.in:1.19
---
 examples/Makefile.in  | 36 +++++++++++++++++++++++++++++-------
 testsuite/Makefile.in | 15 ++++++++++++---
 2 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/examples/Makefile.in b/examples/Makefile.in
index cce21672..a71301ba 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -24,15 +24,37 @@ DISTFILES= $(SOURCES) Makefile.in $(TS_ALL) run-tests setup-env teardown-env \
 all: $(TARGETS)
 
 .c.$(OBJEXT):
-	$(COMPILE) -c $<
-.o$(EXEEXT):
-	$(LINK) $< io.o -lnettle $(LIBS) -o $@
+	$(COMPILE) -c $< && $(DEP_PROCESS)
 
-nettle-benchmark: nettle-benchmark.o nettle-openssl.o
-	$(LINK) nettle-benchmark.o nettle-openssl.o io.o \
+# For Solaris and BSD make, we have to use an explicit rule for each executable
+rsa-keygen$(EXEEXT): rsa-keygen.$(OBJEXT)
+	$(LINK) rsa-keygen.$(OBJEXT) io.$(OBJEXT) \
+	-lnettle $(LIBS) -o rsa-keygen$(EXEEXT)
+
+rsa-sign$(EXEEXT): rsa-sign.$(OBJEXT)
+	$(LINK) rsa-sign.$(OBJEXT) io.$(OBJEXT) \
+	-lnettle $(LIBS) -o rsa-sign$(EXEEXT)
+
+rsa-verify$(EXEEXT): rsa-verify.$(OBJEXT)
+	$(LINK) rsa-verify.$(OBJEXT) io.$(OBJEXT) \
+	-lnettle $(LIBS) -o rsa-verify$(EXEEXT)
+
+rsa-encrypt$(EXEEXT): rsa-encrypt.$(OBJEXT)
+	$(LINK) rsa-encrypt.$(OBJEXT) io.$(OBJEXT) \
+	-lnettle $(LIBS) -o rsa-encrypt$(EXEEXT)
+
+rsa-decrypt$(EXEEXT): rsa-decrypt.$(OBJEXT)
+	$(LINK) rsa-decrypt.$(OBJEXT) io.$(OBJEXT) \
+	-lnettle $(LIBS) -o rsa-decrypt$(EXEEXT)
+
+# .$(OBJEXT)$(EXEEXT):
+# 	$(LINK) $< io.$(OBJEXT) -lnettle $(LIBS) -o $@
+
+nettle-benchmark$(EXEEXT): nettle-benchmark.$(OBJEXT) nettle-openssl.$(OBJEXT)
+	$(LINK) nettle-benchmark.$(OBJEXT) nettle-openssl.$(OBJEXT) io.$(OBJEXT) \
 	-lnettle $(LIBS) $(OPENSSL_LIBFLAGS) -o $@
 
-$(TARGETS) : io.o ../libnettle.a
+$(TARGETS) : io.$(OBJEXT) ../libnettle.a
 
 
 check: $(TS_ALL)
@@ -49,7 +71,7 @@ distdir: $(DISTFILES)
 	cp $? $(distdir)
 
 clean:
-	-rm -f $(TARGETS) *.o
+	-rm -f $(TARGETS) *.$(OBJEXT)
 
 distclean: clean
 	-rm -f Makefile *.d
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index 9963df61..bfacc082 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -46,13 +46,22 @@ all: $(TARGETS) $(EXTRA_TARGETS)
 .SUFFIXES: -test.c -test.$(OBJEXT) -test$(EXEEXT)
 
 .c.$(OBJEXT):
-	$(COMPILE) -I.. -c $< && $(DEP_PROCESS)
+	$(COMPILE) -c $< && $(DEP_PROCESS)
+
+# It seems really tricky to write suffix rules for the transformation
+# foo-test.o -> foo-test, that work with all make variants. We use a a
+# %-rule that works with Solaris make and GNU-make and a two-suffix
+# -test.o-test: that works for BSD make and GNU make. For BSD make, we
+# also need a -test.c-test.o rule.
+
+%$(EXEEXT): %.$(OBJEXT)
+	$(LINK) $< testutils.$(OBJEXT) -lnettle $(LIBS) -o $@
 
 -test.c-test.$(OBJEXT):
-	$(COMPILE) -I.. -c $< && $(DEP_PROCESS)
+	$(COMPILE) -c $< && $(DEP_PROCESS)
 
 -test.$(OBJEXT)-test$(EXEEXT):
-	$(LINK) $< testutils.o -lnettle $(LIBS) -o $@
+	$(LINK) $< testutils.$(OBJEXT) -lnettle $(LIBS) -o $@
 
 $(TARGETS) $(EXTRA_TARGETS) : testutils.$(OBJEXT) ../libnettle.a
 
-- 
GitLab