]> git.ipfire.org Git - thirdparty/git.git/commitdiff
contrib/credential: harmonize Makefiles
authorThomas Uhle <thomas.uhle@mailbox.tu-dresden.de>
Mon, 20 Oct 2025 18:20:22 +0000 (20:20 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Oct 2025 19:34:57 +0000 (12:34 -0700)
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>
contrib/credential/libsecret/Makefile
contrib/credential/osxkeychain/Makefile

index 97ce9c92fb8ae57bc48c29a32d2bbb0fb76ccb76..7cacc576818338a286815fb32d38351fcee65ed3 100644 (file)
@@ -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
index 0948297e20f196c904fb57b7d0f2f16ac474d797..c7d9121022b0e5de6f7530107e9deb0c3c957a82 100644 (file)
@@ -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