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

[PATCH] Clean up Makefile

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Apr 13, 2005, 21:55 UTC
Message-ID
<Pine.LNX.4.21.0504131752410.30848-100000@iabervon.org>
In-Reply-To
<Pine.LNX.4.21.0504131556510.30848-100000@iabervon.org>

Use a pattern rule for building executables, and a list of common objects (which could be made into a library).

Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Index: Makefile
===================================================================
--- 833bb44b8e49daf0424f44cf300748da17945859/Makefile  (mode:100644 sha1:929aa49a3dbe683ad52094099797bc636a7949a6)
+++ 783978eb212c1402ba2612bb32626e93af78b72d/Makefile  (mode:100644 sha1:2b626ec05b2e29016d26b5cb7b4f82ec5c4e79d6)
@@ -20,6 +20,8 @@
 	gitmerge.sh gitpull.sh gitrm.sh gittag.sh gittrack.sh gitexport.sh \
 	gitapply.sh
 
+COMMON=	read-cache.o
+
 GEN_SCRIPT= gitversion.sh
 
 VERSION= VERSION
@@ -31,46 +33,8 @@
 
 LIBS= -lssl -lz
 
-init-db: init-db.o
-
-update-cache: update-cache.o read-cache.o
-	$(CC) $(CFLAGS) -o update-cache update-cache.o read-cache.o $(LIBS)
-
-show-diff: show-diff.o read-cache.o
-	$(CC) $(CFLAGS) -o show-diff show-diff.o read-cache.o $(LIBS)
-
-write-tree: write-tree.o read-cache.o
-	$(CC) $(CFLAGS) -o write-tree write-tree.o read-cache.o $(LIBS)
-
-read-tree: read-tree.o read-cache.o
-	$(CC) $(CFLAGS) -o read-tree read-tree.o read-cache.o $(LIBS)
-
-commit-tree: commit-tree.o read-cache.o
-	$(CC) $(CFLAGS) -o commit-tree commit-tree.o read-cache.o $(LIBS)
-
-cat-file: cat-file.o read-cache.o
-	$(CC) $(CFLAGS) -o cat-file cat-file.o read-cache.o $(LIBS)
-
-ls-tree: ls-tree.o read-cache.o
-	$(CC) $(CFLAGS) -o ls-tree ls-tree.o read-cache.o $(LIBS)
-
-checkout-cache: checkout-cache.o read-cache.o
-	$(CC) $(CFLAGS) -o checkout-cache checkout-cache.o read-cache.o $(LIBS)
-
-diff-tree: diff-tree.o read-cache.o
-	$(CC) $(CFLAGS) -o diff-tree diff-tree.o read-cache.o $(LIBS)
-
-fsck-cache: fsck-cache.o read-cache.o
-	$(CC) $(CFLAGS) -o fsck-cache fsck-cache.o read-cache.o $(LIBS)
-
-rev-tree: rev-tree.o read-cache.o
-	$(CC) $(CFLAGS) -o rev-tree rev-tree.o read-cache.o $(LIBS)
-
-show-files: show-files.o read-cache.o
-	$(CC) $(CFLAGS) -o show-files show-files.o read-cache.o $(LIBS)
-
-check-files: check-files.o read-cache.o
-	$(CC) $(CFLAGS) -o check-files check-files.o read-cache.o $(LIBS)
+$(PROG):%: %.o $(COMMON)
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
 read-cache.o: cache.h
 show-diff.o: cache.h

--	-Daniel
*This .sig left intentionally blank*
Previous: Daniel BarkalowNext: Daniel Barkalow
Message 2 of 5 in “Various cleanups”
  1. Daniel BarkalowApr 13, 2005
  2. Clean up MakefileDaniel Barkalow, Apr 13, 2005
  3. Reorganize common codeDaniel Barkalow, Apr 13, 2005
  4. Daniel BarkalowApr 14, 2005
  5. Petr BaudisApr 14, 2005

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.