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
))
25 version
:= $(shell test -d .git
&& git describe
--match
"topgit-[0-9]*" --abbrev
=4 --dirty
2>/dev
/null | sed
-e
's/^topgit-//' )
29 ifneq ($(strip $(version
)),)
30 version_arg
= -e s
/TG_VERSION
=.
*/TG_VERSION
=$(version
)/
35 all:: precheck
$(commands_out
) $(hooks_out
) $(help_out
)
37 tg
$(commands_out
) $(hooks_out
): % : %.sh Makefile TG-PREFIX
39 @sed
-e
's#@cmddir@#$(cmddir)#g;' \
40 -e
's#@hooksdir@#$(hooksdir)#g' \
41 -e
's#@bindir@#$(bindir)#g' \
42 -e
's#@sharedir@#$(sharedir)#g' \
48 $(help_out
): README create-help.sh
49 @CMD
=`echo $@ | sed -e 's/tg-//' -e 's/\.txt//'` && \
50 echo
'[HELP]' $$CMD && \
51 .
/create-help.sh
$$CMD
55 html
:: topgit.html
$(html_out
)
57 topgit.html
: README create-html-usage.pl
59 @perl .
/create-html-usage.pl
< README | rst2html.py
- $@
61 $(html_out
): create-html.sh
62 @CMD
=`echo $@ | sed -e 's/tg-//' -e 's/\.html//'` && \
63 echo
'[HTML]' $$CMD && \
64 .
/create-html.sh
$$CMD
72 @echo skipping precheck because DESTDIR is set
78 install -d
-m
755 "$(DESTDIR)$(bindir)"
79 install tg
"$(DESTDIR)$(bindir)"
80 install -d
-m
755 "$(DESTDIR)$(cmddir)"
81 install $(commands_out
) "$(DESTDIR)$(cmddir)"
82 install -d
-m
755 "$(DESTDIR)$(hooksdir)"
83 install $(hooks_out
) "$(DESTDIR)$(hooksdir)"
84 install -d
-m
755 "$(DESTDIR)$(sharedir)"
85 install -m
644 $(help_out
) "$(DESTDIR)$(sharedir)"
86 install -m
644 README
"$(DESTDIR)$(sharedir)/tg-tg.txt"
87 install -m
644 leaves.awk
"$(DESTDIR)$(sharedir)"
92 install -d
-m
755 "$(DESTDIR)$(sharedir)"
93 install -m
644 topgit.html
$(html_out
) "$(DESTDIR)$(sharedir)"
98 rm -f tg
$(commands_out
) $(hooks_out
) $(help_out
) topgit.html
$(html_out
)
102 $(bindir):$(cmddir
):$(hooksdir
):$(sharedir
):$(version
)
107 @if
test x
"$$TRACK_PREFIX" != x
"`cat TG-PREFIX 2>/dev/null`"; then \
108 echo
"* new prefix flags"; \
109 echo
"$$TRACK_PREFIX" >TG-PREFIX
; \