chiark / gitweb /
vars.am: Associate more useful dependencies with test programs.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 11 Sep 2016 14:05:49 +0000 (15:05 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 11 Sep 2016 14:05:49 +0000 (15:05 +0100)
For a long time, probably forever, `make FOO.t' hasn't actually worked
to rebuild the test program because of deficiencies in make(1) suffix
rules.  Add GNU Make pattern rules, which can have dependencies, to
finally fix this.

vars.am

diff --git a/vars.am b/vars.am
index feb758844b403cea29445132886ef64429bd22c9..6915407268338e27bda9e48d096012fe809e495e 100644 (file)
--- a/vars.am
+++ b/vars.am
@@ -110,11 +110,23 @@ AM_CPPFLAGS                = $(CATACOMB_INCLUDES)
 
 TEST_EXTENSIONS                 = .t
 SUFFIXES               += .c .t$(EXEEXT) .to
+
+## This unpleasant duplication of rules makes the build system basically work
+## for non-GNU make(1) variants, while GNU Make will associate useful
+## additional dependencies with the test programs.  GNU Make seems not to
+## mind the duplicate rules, and uses the second (better) set; non-GNU Make
+## will think the second set refer to bizarrely-named targets which nobody is
+## apparently interested in.
 .c.to:
        $(AM_V_CC)$(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" $< -o $@
 .to.t$(EXEEXT):
        $(AM_V_CCLD)$(LINK) $< $(TEST_LIBS) $(top_builddir)/libcatacomb.la \
                $(mLib_LIBS) $(CATACOMB_LIBS) $(LIBS)
+%.to: %.c %.lo
+       $(AM_V_CC)$(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" $< -o $@
+%.t$(EXEEXT): %.to $(TEST_LIBS) $(top_builddir)/libcatacomb.la
+       $(AM_V_CCLD)$(LINK) $+ $(mLib_LIBS) $(CATACOMB_LIBS) $(LIBS)
+
 .PRECIOUS: %.to
 CLEANFILES             += *.to *.t$(EXEEXT)