Commit f38a65e637302db6b8298e127ac94c7b072600db

Steffen Jaeckel 2019-09-05T16:58:39

simplify some of the build rules

diff --git a/makefile b/makefile
index beab4fc..8de82d1 100644
--- a/makefile
+++ b/makefile
@@ -17,7 +17,7 @@ coverage: LIBNAME:=-Wl,--whole-archive $(LIBNAME)  -Wl,--no-whole-archive
 
 include makefile_include.mk
 
-%.o: %.c
+%.o: %.c $(HEADERS)
 ifneq ($V,1)
 	@echo "   * ${CC} $@"
 endif
@@ -58,8 +58,6 @@ bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_s
 
 #END_INS
 
-$(OBJECTS): $(HEADERS)
-
 $(LIBNAME):  $(OBJECTS)
 	$(AR) $(ARFLAGS) $@ $(OBJECTS)
 	$(RANLIB) $@
@@ -97,10 +95,7 @@ uninstall:
 	rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
 	rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
 
-test: demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
-	$(CC) $(CFLAGS) $^ $(LFLAGS) -o test
-
-test_standalone: demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
+test test_standalone: demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
 	$(CC) $(CFLAGS) $^ $(LFLAGS) -o test
 
 .PHONY: mtest
diff --git a/makefile.shared b/makefile.shared
index 25e2fe5..e6bb1ef 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -57,7 +57,7 @@ bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_s
 
 objs: $(OBJECTS)
 
-.c.o:
+.c.o: $(HEADERS)
 	$(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -o $@ -c $<
 
 LOBJECTS = $(OBJECTS:.o=.lo)
@@ -79,17 +79,8 @@ uninstall:
 	rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
 	rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc
 
-test: $(LIBNAME)
-	$(LTCOMPILE) $(CFLAGS) -c demo/main.c -o demo/main.o
-	$(LTCOMPILE) $(CFLAGS) -c demo/opponent.c -o demo/opponent.o
-	$(LTCOMPILE) $(CFLAGS) -c demo/test.c -o demo/test.o
-	$(LTLINK) $(LDFLAGS) -o test demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
-
-test_standalone: $(LIBNAME)
-	$(LTCOMPILE) $(CFLAGS) -c demo/main.c -o demo/main.o
-	$(LTCOMPILE) $(CFLAGS) -c demo/opponent.c -o demo/opponent.o
-	$(LTCOMPILE) $(CFLAGS) -c demo/test.c -o demo/test.o
-	$(LTLINK) $(LDFLAGS) -o test demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
+test test_standalone: demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
+	$(LTLINK) $(LDFLAGS) $^ -o test
 
 .PHONY: mtest
 mtest: