From 6e484cd4204e32316d5c0a25a60ee6e92677d19b Mon Sep 17 00:00:00 2001
From: Steffen Jaeckel <s@jaeckel.eu>
Date: Fri, 5 May 2017 15:35:06 +0200
Subject: [PATCH] use make internal macros

---
 makefile.mingw  | 12 ++++++------
 makefile.shared |  4 ++--
 makefile.unix   | 14 +++++++-------
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/makefile.mingw b/makefile.mingw
index bcf033a..1270dea 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -255,20 +255,20 @@ $(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS)
 
 #Demo tools/utilities
 hashsum: demos/hashsum.o $(LIBMAIN_S)
-	$(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 crypt: demos/crypt.o $(LIBMAIN_S)
-	$(CC) demos/crypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 small: demos/small.o $(LIBMAIN_S)
-	$(CC) demos/small.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 tv_gen: demos/tv_gen.o $(LIBMAIN_S)
-	$(CC) demos/tv_gen.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 
 #Tests + timing tests
 timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S)
-	$(CC) demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 	@echo NOTICE: start the tests by: timing.exe
 test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S)
-	$(CC) demos/test.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 	@echo NOTICE: start the tests by: test.exe
 
 all: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) hashsum crypt small tv_gen timing test
diff --git a/makefile.shared b/makefile.shared
index 748bf05..c14647f 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -263,11 +263,11 @@ timing: library $(LIBTEST) $(TIMINGS)
 
 # build the demos from a template
 define DEMO_template
-$(1): demos/$(1).o library
+$(1): demos/$(1).o $$(LIBNAME)
 ifneq ($V,1)
 	@echo "   * $${CC} $$@"
 endif
-	$$(LT) --mode=link --tag=CC $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(LDFLAGS) -o $(1) $$< $$(LIBNAME) $$(EXTRALIBS)
+	$$(LT) --mode=link --tag=CC $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
 endef
 
 $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
diff --git a/makefile.unix b/makefile.unix
index 57e1e3a..7d0d3a0 100644
--- a/makefile.unix
+++ b/makefile.unix
@@ -258,20 +258,20 @@ $(LIBMAIN_S): $(OBJECTS)
 
 #Demo tools/utilities
 hashsum: demos/hashsum.o $(LIBMAIN_S)
-	$(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 ltcrypt: demos/ltcrypt.o $(LIBMAIN_S)
-	$(CC) demos/ltcrypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 small: demos/small.o $(LIBMAIN_S)
-	$(CC) demos/small.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 tv_gen: demos/tv_gen.o $(LIBMAIN_S)
-	$(CC) demos/tv_gen.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 
 #Tests + timing tests
 timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S)
-	$(CC) demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 	@echo "NOTICE: start the timing tests by: ./timing"
-test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S)
-	$(CC) demos/test.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
+test: demos/test.o $(LIBTEST_S) $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 	@echo "NOTICE: start the tests by: ./test"
 
 all: $(LIBMAIN_S) $(LIBTEST_S) hashsum ltcrypt small tv_gen timing test