git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Makefile: Use generic rule to build test programs

From
Julian Phillips <julian@quantumfyre.co.uk>
Date
May 30, 2007, 23:18 UTC
Message-ID
<20070530232206.25366.89397.julian@quantumfyre.co.uk>

Use a generic make rule to build all the test programs, rather than specifically mentioning each one.

Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
---
On Tue, 29 May 2007, Junio C Hamano wrote:
> Hmmm.  One wonders if we can do something about these apparent
> similarities with all these rules...
Something like this?
 Makefile |   24 +++++-------------------
 1 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/Makefile b/Makefile
index 7527734..cac0a4a 100644
--- a/Makefile
+++ b/Makefile
@@ -942,7 +942,7 @@ endif
 
 ### Testing rules
 
-TEST_PROGRAMS = test-chmtime$X test-genrandom$X
+TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X
 
 all:: $(TEST_PROGRAMS)
 
@@ -955,26 +955,12 @@ export NO_SVN_TESTS
 test: all
 	$(MAKE) -C t/ all
 
-test-date$X: test-date.c date.o ctype.o
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
+test-date$X: date.o ctype.o
 
-test-delta$X: test-delta.o diff-delta.o patch-delta.o $(GITLIBS)
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
+test-delta$X: diff-delta.o patch-delta.o
 
-test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
-
-test-sha1$X: test-sha1.o $(GITLIBS)
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
-
-test-match-trees$X: test-match-trees.o $(GITLIBS)
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
-
-test-chmtime$X: test-chmtime.c
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $<
-
-test-genrandom$X: test-genrandom.c
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $<
+test-%$X: test-%.o $(GITLIBS)
+	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
 check-sha1:: test-sha1$X
 	./test-sha1.sh
-- 
1.5.2
Next: Shawn O. Pearce
Message 1 of 2 in “Makefile: Use generic rule to build test programs”
  1. Makefile: Use generic rule to build test programsJulian Phillips, May 30, 2007
  2. Shawn O. PearceMay 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.