This repository has been archived by the owner on Jan 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMakefile
53 lines (43 loc) · 1.51 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
prefix ?= $(HOME)
bindir := $(prefix)/bin
cmddir := $(prefix)/libexec/topgit
sharedir := $(prefix)/share/topgit
hooksdir := $(cmddir)/hooks
commands_in := $(wildcard tg-*.sh)
hooks_in = hooks/pre-commit.sh
commands_out := $(patsubst %.sh,%,$(commands_in))
hooks_out := $(patsubst %.sh,%,$(hooks_in))
help_out := $(patsubst %.sh,%.txt,$(commands_in))
version = $(shell test -d .git && git describe --match "topgit-[0-9]*" --abbrev=4 HEAD 2>/dev/null | sed -e 's/^topgit-//' )
ifneq ($(strip $(version)),)
version_arg = -e s/TG_VERSION=.*/TG_VERSION=$(version)/
endif
all:: precheck $(commands_out) $(hooks_out) $(help_out)
tg $(commands_out) $(hooks_out): % : %.sh Makefile
@echo "[SED] $@"
@sed -e 's#@cmddir@#$(cmddir)#g;' \
-e 's#@hooksdir@#$(hooksdir)#g' \
-e 's#@bindir@#$(bindir)#g' \
-e 's#@sharedir@#$(sharedir)#g' \
$(version_arg) \
[email protected] >$@+ && \
chmod +x $@+ && \
mv $@+ $@
$(help_out): README create-help.sh
@CMD=`echo $@ | sed -e 's/tg-//' -e 's/\.txt//'` && \
echo '[HELP]' $$CMD && \
./create-help.sh $$CMD
precheck:: tg
./$+ precheck
install:: all
install -d -m 755 "$(DESTDIR)$(bindir)"
install tg "$(DESTDIR)$(bindir)"
install -d -m 755 "$(DESTDIR)$(cmddir)"
install $(commands_out) "$(DESTDIR)$(cmddir)"
install -d -m 755 "$(DESTDIR)$(hooksdir)"
install $(hooks_out) "$(DESTDIR)$(hooksdir)"
install -d -m 755 "$(DESTDIR)$(sharedir)"
install -m 644 $(help_out) "$(DESTDIR)$(sharedir)"
install -m 644 leaves.awk "$(DESTDIR)$(sharedir)"
clean::
rm -f tg $(commands_out) $(hooks_out) $(help_out)