contrib/credential: harmonize Makefiles

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Uhle committed Oct 20, 2025 at 20:20 UTC 9b8ff6dc9ac876cc6d0c8eb68bdcf944e844e4c1
2 files changed +27 -23
contrib/credential/libsecret/Makefile
+14 -15
@@ -1,28 +1,27 @@
1 # The default target of this Makefile is...
2 -all::
3 -
4 -MAIN:=git-credential-libsecret
5 -all:: $(MAIN)
6 -
7 -CC = gcc
8 -RM = rm -f
9 -CFLAGS = -g -O2 -Wall
10 -PKG_CONFIG = pkg-config
2 +all:: git-credential-libsecret
3
4 -include ../../../config.mak.autogen
5 -include ../../../config.mak
6
7 +prefix ?= /usr/local
8 +gitexecdir ?= $(prefix)/libexec/git-core
9 +
10 +CC ?= gcc
11 +CFLAGS ?= -g -O2 -Wall
12 +PKG_CONFIG ?= pkg-config
13 +RM ?= rm -f
14 +
15 INCS:=$(shell $(PKG_CONFIG) --cflags libsecret-1 glib-2.0)
16 LIBS:=$(shell $(PKG_CONFIG) --libs libsecret-1 glib-2.0)
17
18 -SRCS:=$(MAIN).c
19 -OBJS:=$(SRCS:.c=.o)
20 -
18 %.o: %.c
19 $(CC) $(CFLAGS) $(CPPFLAGS) $(INCS) -o $@ -c $<
20
24 -$(MAIN): $(OBJS)
25 - $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
21 +git-credential-libsecret: git-credential-libsecret.o
22 + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
23
24 clean:
28 - @$(RM) $(MAIN) $(OBJS)
25 + $(RM) git-credential-libsecret git-credential-libsecret.o
26 +
27 +.PHONY: all clean
contrib/credential/osxkeychain/Makefile
+13 -8
@@ -1,19 +1,24 @@
1 # The default target of this Makefile is...
2 all:: git-credential-osxkeychain
3
4 -CC = gcc
5 -RM = rm -f
6 -CFLAGS = -g -O2 -Wall
7 -
4 -include ../../../config.mak.autogen
5 -include ../../../config.mak
6
7 +prefix ?= /usr/local
8 +gitexecdir ?= $(prefix)/libexec/git-core
9 +
10 +CC ?= gcc
11 +CFLAGS ?= -g -O2 -Wall
12 +RM ?= rm -f
13 +
14 +%.o: %.c
15 + $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
16 +
17 git-credential-osxkeychain: git-credential-osxkeychain.o
12 - $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) \
18 + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) \
19 -framework Security -framework CoreFoundation
20
15 -git-credential-osxkeychain.o: git-credential-osxkeychain.c
16 - $(CC) -c $(CFLAGS) $<
17 -
21 clean:
22 $(RM) git-credential-osxkeychain git-credential-osxkeychain.o
23 +
24 +.PHONY: all clean