osxkeychain: define build targets in the top-level Makefile.

The fix for git-credential-osxkeychain in 4580bcd235 (osxkeychain: avoid incorrectly skipping store operation, 2025-11-14) introduced linkage with libgit.a, and its Makefile was adjusted accordingly. However, the build fails as of 864f55e190 because several macOS-specific refinements were applied to the top-level Makefile and config.mak.uname, such as: - 363837afe7 (macOS: make Homebrew use configurable, 2025-12-24) - cee341e9dd (macOS: use iconv from Homebrew if needed and present, 2025-12-24) - d281241518 (utf8.c: enable workaround for iconv under macOS 14/15, 2026-01-12) Since libgit.a and its corresponding header files depend on many flags defined in the top-level Makefile, these flags must be consistently defined when building git-credential-osxkeychain. Continuing to manually adjust the git-credential-osxkeychain Makefile is cumbersome and fragile. Define the build targets for git-credential-osxkeychain in the top-level Makefile and modify its local Makefile to simply rely on those targets. Helped-by: Junio C Hamano <gitster@pobox.com> Reported-by: D. Ben Knoble <ben.knoble@gmail.com> Helped-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> Signed-off-by: Koji Nakamaru <koji.nakamaru@gree.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Koji Nakamaru committed Feb 20, 2026 at 01:39 UTC 3e9cc24e68ef311500406ef4d170be30e36e1231
2 files changed +27 -59
Makefile
+21
@@ -2874,6 +2874,10 @@ objects: $(OBJECTS)
2874 dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
2875 dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
2876
2877 +ifeq ($(uname_S),Darwin)
2878 + dep_dirs += $(addsuffix .depend,$(sort $(dir contrib/credential/osxkeychain/git-credential-osxkeychain.o)))
2879 +endif
2880 +
2881 ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
2882 $(dep_dirs):
2883 @mkdir -p $@
@@ -4058,3 +4062,20 @@ $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
4062
4063 contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
4064 $(AR) $(ARFLAGS) $@ $^
4065 +
4066 +contrib/credential/osxkeychain/git-credential-osxkeychain: contrib/credential/osxkeychain/git-credential-osxkeychain.o $(LIB_FILE) GIT-LDFLAGS
4067 + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
4068 + $(filter %.o,$^) $(LIB_FILE) $(EXTLIBS) -framework Security -framework CoreFoundation
4069 +
4070 +contrib/credential/osxkeychain/git-credential-osxkeychain.o: contrib/credential/osxkeychain/git-credential-osxkeychain.c GIT-CFLAGS
4071 + $(QUIET_LINK)$(CC) -o $@ -c $(dep_args) $(compdb_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
4072 +
4073 +install-git-credential-osxkeychain: contrib/credential/osxkeychain/git-credential-osxkeychain
4074 + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
4075 + $(INSTALL) $(INSTALL_STRIP) $< '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
4076 +
4077 +.PHONY: clean-git-credential-osxkeychain
4078 +clean-git-credential-osxkeychain:
4079 + $(RM) \
4080 + contrib/credential/osxkeychain/git-credential-osxkeychain \
4081 + contrib/credential/osxkeychain/git-credential-osxkeychain.o
contrib/credential/osxkeychain/Makefile
+6 -59
@@ -1,66 +1,13 @@
1 # The default target of this Makefile is...
2 all:: git-credential-osxkeychain
3
4 -include ../../../config.mak.uname
5 --include ../../../config.mak.autogen
6 --include ../../../config.mak
4 +git-credential-osxkeychain:
5 + $(MAKE) -C ../../.. contrib/credential/osxkeychain/git-credential-osxkeychain
6
8 -ifdef ZLIB_NG
9 - BASIC_CFLAGS += -DHAVE_ZLIB_NG
10 - ifdef ZLIB_NG_PATH
11 - BASIC_CFLAGS += -I$(ZLIB_NG_PATH)/include
12 - EXTLIBS += $(call libpath_template,$(ZLIB_NG_PATH)/$(lib))
13 - endif
14 - EXTLIBS += -lz-ng
15 -else
16 - ifdef ZLIB_PATH
17 - BASIC_CFLAGS += -I$(ZLIB_PATH)/include
18 - EXTLIBS += $(call libpath_template,$(ZLIB_PATH)/$(lib))
19 - endif
20 - EXTLIBS += -lz
21 -endif
22 -ifndef NO_ICONV
23 - ifdef NEEDS_LIBICONV
24 - ifdef ICONVDIR
25 - BASIC_CFLAGS += -I$(ICONVDIR)/include
26 - ICONV_LINK = $(call libpath_template,$(ICONVDIR)/$(lib))
27 - else
28 - ICONV_LINK =
29 - endif
30 - ifdef NEEDS_LIBINTL_BEFORE_LIBICONV
31 - ICONV_LINK += -lintl
32 - endif
33 - EXTLIBS += $(ICONV_LINK) -liconv
34 - endif
35 -endif
36 -ifndef LIBC_CONTAINS_LIBINTL
37 - EXTLIBS += -lintl
38 -endif
39 -
40 -prefix ?= /usr/local
41 -gitexecdir ?= $(prefix)/libexec/git-core
42 -
43 -CC ?= gcc
44 -CFLAGS ?= -g -O2 -Wall -I../../.. $(BASIC_CFLAGS)
45 -LDFLAGS ?= $(BASIC_LDFLAGS) $(EXTLIBS)
46 -INSTALL ?= install
47 -RM ?= rm -f
48 -
49 -%.o: %.c
50 - $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
51 -
52 -git-credential-osxkeychain: git-credential-osxkeychain.o ../../../libgit.a
53 - $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) \
54 - -framework Security -framework CoreFoundation
55 -
56 -install: git-credential-osxkeychain
57 - $(INSTALL) -d -m 755 $(DESTDIR)$(gitexecdir)
58 - $(INSTALL) -m 755 $< $(DESTDIR)$(gitexecdir)
59 -
60 -../../../libgit.a:
61 - cd ../../..; make libgit.a
7 +install:
8 + $(MAKE) -C ../../.. install-git-credential-osxkeychain
9
10 clean:
64 - $(RM) git-credential-osxkeychain git-credential-osxkeychain.o
11 + $(MAKE) -C ../../.. clean-git-credential-osxkeychain
12
66 -.PHONY: all install clean
13 +.PHONY: all git-credential-osxkeychain install clean