1 # NOTE: Requires GNU make
5 # This should give a reasonable hint that GNU make is required in non-GNU make
6 .error GNU_make_is_required
:
8 # This should be fatal in non-GNU make
12 bindir = $(prefix)/bin
13 cmddir
= $(prefix)/libexec
/topgit
14 sharedir
= $(prefix)/share
/topgit
15 hooksdir
= $(cmddir
)/hooks
17 commands_in
:= $(wildcard tg-
*.sh
)
18 hooks_in
= hooks
/pre-commit.sh
20 commands_out
= $(patsubst %.sh
,%,$(commands_in
))
21 hooks_out
= $(patsubst %.sh
,%,$(hooks_in
))
22 help_out
= $(patsubst %.sh
,%.txt
,tg-help.sh
$(commands_in
))
23 html_out
= $(patsubst %.sh
,%.html
,tg-help.sh tg-tg.sh
$(commands_in
))
28 SHELL_PATH_SQ
= $(subst ','\'',$(SHELL_PATH))
30 version := $(shell test -d .git && git describe --match "topgit-[0-9]*" --abbrev=4 --dirty 2>/dev/null | sed -e 's
/^topgit-
//' )
35 ifneq ($(strip $(version)),)
36 version_arg = -e s/TG_VERSION=.*/TG_VERSION=$(version)/
41 all:: shell_compatibility_test precheck $(commands_out) $(hooks_out) $(help_out) tg-tg.txt
43 please_set_SHELL_PATH_to_a_more_modern_shell:
46 shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
48 tg $(commands_out) $(hooks_out): % : %.sh Makefile TG-PREFIX
50 @sed -e '1s|
#!.*/sh|#!$(SHELL_PATH_SQ)|' \
51 -e
's#@cmddir@#$(cmddir)#g;' \
52 -e
's#@hooksdir@#$(hooksdir)#g' \
53 -e
's#@bindir@#$(bindir)#g' \
54 -e
's#@sharedir@#$(sharedir)#g' \
55 -e
's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
61 $(help_out
): README create-help.sh
62 @CMD
=`echo $@ | sed -e 's/tg-//' -e 's/\.txt//'` && \
63 echo
'[HELP]' $$CMD && \
64 $(SHELL_PATH
) .
/create-help.sh
$$CMD
66 .PHONY
: doc install-doc html
70 install-doc
:: install-html
72 html
:: topgit.html
$(html_out
)
74 tg-tg.txt
: README create-html-usage.pl
$(wildcard tg-
*.sh
)
76 @perl .
/create-html-usage.pl
--text
< README
> $@
78 topgit.html
: README create-html-usage.pl
$(wildcard tg-
*.sh
)
80 @perl .
/create-html-usage.pl
< README | rst2html.py
- $@
82 $(html_out
): create-html.sh
83 @CMD
=`echo $@ | sed -e 's/tg-//' -e 's/\.html//'` && \
84 echo
'[HTML]' $$CMD && \
85 $(SHELL_PATH
) .
/create-html.sh
$$CMD
93 @echo skipping precheck because DESTDIR is set
99 install -d
-m
755 "$(DESTDIR)$(bindir)"
100 install tg
"$(DESTDIR)$(bindir)"
101 install -d
-m
755 "$(DESTDIR)$(cmddir)"
102 install $(commands_out
) "$(DESTDIR)$(cmddir)"
103 install -d
-m
755 "$(DESTDIR)$(hooksdir)"
104 install $(hooks_out
) "$(DESTDIR)$(hooksdir)"
105 install -d
-m
755 "$(DESTDIR)$(sharedir)"
106 install -m
644 $(help_out
) tg-tg.txt
"$(DESTDIR)$(sharedir)"
107 install -m
644 leaves.awk
"$(DESTDIR)$(sharedir)"
112 install -d
-m
755 "$(DESTDIR)$(sharedir)"
113 install -m
644 topgit.html
$(html_out
) "$(DESTDIR)$(sharedir)"
118 rm -f tg
$(commands_out
) $(hooks_out
) $(help_out
) topgit.html
$(html_out
)
122 $(bindir):$(cmddir
):$(hooksdir
):$(sharedir
):$(SHELL_PATH
):$(version
)
127 @if
test x
"$$TRACK_PREFIX" != x
"`cat TG-PREFIX 2>/dev/null`"; then \
128 echo
"* new prefix flags"; \
129 echo
"$$TRACK_PREFIX" >TG-PREFIX
; \