[PATCH] contrib/credential: Amend and 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.
* Add an install target rule.
* Strip @ from $(RM) to let the clean target rule be verbose.
* Define .PHONY for all special targets (all, clean, install).
Signed-off-by: Thomas Uhle <thomas.uhle@mailbox.tu-dresden.de>
---
contrib/credential/libsecret/Makefile | 30 ++++++++++++++-------
contrib/credential/osxkeychain/Makefile | 36 ++++++++++++++++++-------
2 files changed, 46 insertions(+), 20 deletions(-)
diff --git a/contrib/credential/libsecret/Makefile b/contrib/credential/libsecret/Makefile
index 97ce9c9..8ee6cce 100644
--- a/contrib/credential/libsecret/Makefile
+++ b/contrib/credential/libsecret/Makefile
@@ -1,17 +1,21 @@
# 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
-
-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
+INSTALL ?= install
+RM ?= rm -f
+
+MAIN:=git-credential-libsecret
+all:: $(MAIN)
+
INCS:=$(shell $(PKG_CONFIG) --cflags libsecret-1 glib-2.0)
LIBS:=$(shell $(PKG_CONFIG) --libs libsecret-1 glib-2.0)
@@ -22,7 +26,13 @@ OBJS:=$(SRCS:.c=.o)
$(CC) $(CFLAGS) $(CPPFLAGS) $(INCS) -o $@ -c $<
$(MAIN): $(OBJS)
- $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
+ $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
+
+install: $(MAIN)
+ $(INSTALL) -d -m 755 $(DESTDIR)$(gitexecdir)
+ $(INSTALL) -m 755 $< $(DESTDIR)$(gitexecdir)
clean:
- @$(RM) $(MAIN) $(OBJS)
+ $(RM) $(MAIN) $(OBJS)
+
+.PHONY: all install clean
diff --git a/contrib/credential/osxkeychain/Makefile b/contrib/credential/osxkeychain/Makefile
index 0948297..b1d7c29 100644
--- a/contrib/credential/osxkeychain/Makefile
+++ b/contrib/credential/osxkeychain/Makefile
@@ -1,19 +1,35 @@
# The default target of this Makefile is...
-all:: git-credential-osxkeychain
-
-CC = gcc
-RM = rm -f
-CFLAGS = -g -O2 -Wall
+all::
-include ../../../config.mak.autogen
-include ../../../config.mak
-git-credential-osxkeychain: git-credential-osxkeychain.o
- $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) \
+prefix ?= /usr/local
+gitexecdir ?= $(prefix)/libexec/git-core
+
+CC ?= gcc
+CFLAGS ?= -g -O2 -Wall
+INSTALL ?= install
+RM ?= rm -f
+
+MAIN:=git-credential-osxkeychain
+all:: $(MAIN)
+
+SRCS:=$(MAIN).c
+OBJS:=$(SRCS:.c=.o)
+
+%.o: %.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
+
+$(MAIN): $(OBJS)
+ $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) \
-framework Security -framework CoreFoundation
-git-credential-osxkeychain.o: git-credential-osxkeychain.c
- $(CC) -c $(CFLAGS) $<
+install: $(MAIN)
+ $(INSTALL) -d -m 755 $(DESTDIR)$(gitexecdir)
+ $(INSTALL) -m 755 $< $(DESTDIR)$(gitexecdir)
clean:
- $(RM) git-credential-osxkeychain git-credential-osxkeychain.o
+ $(RM) $(MAIN) $(OBJS)
+
+.PHONY: all install clean
base-commit: 60f3f52f17cceefa5299709b189ce6fe2d181e7b
--
2.47.3