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

[PATCH v2] contrib/credential: Amend and harmonize Makefiles

From
Thomas Uhle <thomas.uhle@mailbox.tu-dresden.de>
Date
Oct 20, 2025, 18:20 UTC
Message-ID
<0a61b0b3-365b-c198-6afd-f26fcd5a9c20@mailbox.tu-dresden.de>
In-Reply-To
<48d92664-41af-bb59-1844-7bb57f21924f@mailbox.tu-dresden.de>
Update these Makefiles to be in line with other Makefiles from contrib
such as for contacts or subtree by making the following changes:
* Make the default settings after including config.mak.autogen and
  config.mak.
* Add the missing $(CPPFLAGS) to the compiler command as well as the
  missing $(CFLAGS) to the linker command.
* Use a pattern rule for compilation instead of a dedicated rule for
  each compile unit.
* Get rid of $(MAIN), $(SRCS) and $(OBJS) and simply use their values
  such as git-credential-libsecret and git-credential-libsecret.o.
* Strip @ from $(RM) to let the clean target rule be verbose.
* Define .PHONY for all special targets (all, clean).
Signed-off-by: Thomas Uhle <thomas.uhle@mailbox.tu-dresden.de>
---
Changes in v2:
* Revert the changes in contrib/credentials/osxkeychain/Makefile that
  have introduced $(MAIN), $(SRCS) and $(OBJS) as placeholders for
  git-credential-osxkeychain, git-credential-osxkeychain.c and
  git-credential-osxkeychain.o similar to
  contrib/credential/libsecret/Makefile.  Instead replace $(MAIN),
  $(SRCS) and $(OBJS) in contrib/credential/libsecret/Makefile.
* Remove install target rule again to send this change as a separate
  patch later as requested.
* Adapt commit message.
* Link to v1: https://lore.kernel.org/git/48d92664-41af-bb59-1844-7bb57f21924f@mailbox.tu-dresden.de/
 contrib/credential/libsecret/Makefile   | 29 ++++++++++++-------------
 contrib/credential/osxkeychain/Makefile | 21 +++++++++++-------
 2 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/contrib/credential/libsecret/Makefile b/contrib/credential/libsecret/Makefile
index 97ce9c9..7cacc57 100644
--- a/contrib/credential/libsecret/Makefile
+++ b/contrib/credential/libsecret/Makefile
@@ -1,28 +1,27 @@
 # The default target of this Makefile is...
-all::
-
-MAIN:=git-credential-libsecret
-all:: $(MAIN)
-
-CC = gcc
-RM = rm -f
-CFLAGS = -g -O2 -Wall
-PKG_CONFIG = pkg-config
+all:: git-credential-libsecret

 -include ../../../config.mak.autogen
 -include ../../../config.mak

+prefix ?= /usr/local
+gitexecdir ?= $(prefix)/libexec/git-core
+
+CC ?= gcc
+CFLAGS ?= -g -O2 -Wall
+PKG_CONFIG ?= pkg-config
+RM ?= rm -f
+
 INCS:=$(shell $(PKG_CONFIG) --cflags libsecret-1 glib-2.0)
 LIBS:=$(shell $(PKG_CONFIG) --libs libsecret-1 glib-2.0)

-SRCS:=$(MAIN).c
-OBJS:=$(SRCS:.c=.o)
-
 %.o: %.c
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCS) -o $@ -c $<

-$(MAIN): $(OBJS)
-	$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
+git-credential-libsecret: git-credential-libsecret.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)

 clean:
-	@$(RM) $(MAIN) $(OBJS)
+	$(RM) git-credential-libsecret git-credential-libsecret.o
+
+.PHONY: all clean
diff --git a/contrib/credential/osxkeychain/Makefile b/contrib/credential/osxkeychain/Makefile
index 0948297..c7d9121 100644
--- a/contrib/credential/osxkeychain/Makefile
+++ b/contrib/credential/osxkeychain/Makefile
@@ -1,19 +1,24 @@
 # The default target of this Makefile is...
 all:: git-credential-osxkeychain

-CC = gcc
-RM = rm -f
-CFLAGS = -g -O2 -Wall
-
 -include ../../../config.mak.autogen
 -include ../../../config.mak

+prefix ?= /usr/local
+gitexecdir ?= $(prefix)/libexec/git-core
+
+CC ?= gcc
+CFLAGS ?= -g -O2 -Wall
+RM ?= rm -f
+
+%.o: %.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
+
 git-credential-osxkeychain: git-credential-osxkeychain.o
-	$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) \
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) \
 		-framework Security -framework CoreFoundation

-git-credential-osxkeychain.o: git-credential-osxkeychain.c
-	$(CC) -c $(CFLAGS) $<
-
 clean:
 	$(RM) git-credential-osxkeychain git-credential-osxkeychain.o
+
+.PHONY: all clean

base-commit: 60f3f52f17cceefa5299709b189ce6fe2d181e7b
-- 
2.47.3
Previous: Thomas Uhle
Message 8 of 8 in “contrib/credential: Amend and harmonize Makefiles”
  1. contrib/credential: Amend and harmonize MakefilesThomas Uhle, Oct 10, 2025
  2. Junio C HamanoOct 10, 2025
  3. Thomas UhleOct 10, 2025
  4. Junio C HamanoOct 10, 2025
  5. Thomas UhleOct 11, 2025
  6. Junio C HamanoOct 11, 2025
  7. Thomas UhleOct 11, 2025
  8. contrib/credential: Amend and harmonize MakefilesThomas Uhle, Oct 20, 2025

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.