Skip to content

Commit ac6152f

Browse files
uhlegitster
authored andcommitted
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4b71b29 commit ac6152f

File tree

2 files changed

+46
-20
lines changed

2 files changed

+46
-20
lines changed
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# The default target of this Makefile is...
22
all::
33

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
11-
124
-include ../../../config.mak.autogen
135
-include ../../../config.mak
146

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+
INSTALL ?= install
14+
RM ?= rm -f
15+
16+
MAIN:=git-credential-libsecret
17+
all:: $(MAIN)
18+
1519
INCS:=$(shell $(PKG_CONFIG) --cflags libsecret-1 glib-2.0)
1620
LIBS:=$(shell $(PKG_CONFIG) --libs libsecret-1 glib-2.0)
1721

@@ -22,7 +26,13 @@ OBJS:=$(SRCS:.c=.o)
2226
$(CC) $(CFLAGS) $(CPPFLAGS) $(INCS) -o $@ -c $<
2327

2428
$(MAIN): $(OBJS)
25-
$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
29+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
30+
31+
install: $(MAIN)
32+
$(INSTALL) -d -m 755 $(DESTDIR)$(gitexecdir)
33+
$(INSTALL) -m 755 $< $(DESTDIR)$(gitexecdir)
2634

2735
clean:
28-
@$(RM) $(MAIN) $(OBJS)
36+
$(RM) $(MAIN) $(OBJS)
37+
38+
.PHONY: all install clean
Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
# 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
2+
all::
73

84
-include ../../../config.mak.autogen
95
-include ../../../config.mak
106

11-
git-credential-osxkeychain: git-credential-osxkeychain.o
12-
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) \
7+
prefix ?= /usr/local
8+
gitexecdir ?= $(prefix)/libexec/git-core
9+
10+
CC ?= gcc
11+
CFLAGS ?= -g -O2 -Wall
12+
INSTALL ?= install
13+
RM ?= rm -f
14+
15+
MAIN:=git-credential-osxkeychain
16+
all:: $(MAIN)
17+
18+
SRCS:=$(MAIN).c
19+
OBJS:=$(SRCS:.c=.o)
20+
21+
%.o: %.c
22+
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
23+
24+
$(MAIN): $(OBJS)
25+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) \
1326
-framework Security -framework CoreFoundation
1427

15-
git-credential-osxkeychain.o: git-credential-osxkeychain.c
16-
$(CC) -c $(CFLAGS) $<
28+
install: $(MAIN)
29+
$(INSTALL) -d -m 755 $(DESTDIR)$(gitexecdir)
30+
$(INSTALL) -m 755 $< $(DESTDIR)$(gitexecdir)
1731

1832
clean:
19-
$(RM) git-credential-osxkeychain git-credential-osxkeychain.o
33+
$(RM) $(MAIN) $(OBJS)
34+
35+
.PHONY: all install clean

0 commit comments

Comments
 (0)