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
11 # Update if you add any code that requires a newer version of git
12 GIT_MINIMUM_VERSION ?
= 1.8.5
15 bindir = $(prefix)/bin
16 cmddir
= $(prefix)/libexec
/topgit
17 sharedir
= $(prefix)/share
/topgit
18 hooksdir
= $(cmddir
)/hooks
20 commands_in
:= $(wildcard tg-
[!-]*.sh
)
21 utils_in
:= $(wildcard tg--
*.sh
)
22 hooks_in
= hooks
/pre-commit.sh
24 commands_out
= $(patsubst %.sh
,%,$(commands_in
))
25 utils_out
= $(patsubst %.sh
,%,$(utils_in
))
26 hooks_out
= $(patsubst %.sh
,%,$(hooks_in
))
27 PROGRAMS
= $(commands_out
) $(utils_out
)
28 help_out
= $(patsubst %.sh
,%.txt
,tg-help.sh tg-status.sh
$(commands_in
))
29 html_out
= $(patsubst %.sh
,%.html
,tg-help.sh tg-status.sh tg-tg.sh
$(commands_in
))
32 SHELL_PATH_SQ
= $(subst ','\'',$(SHELL_PATH))
34 version := $(shell test -d .git && git describe --match "topgit-[0-9]*" --abbrev=4 --dirty 2>/dev/null | sed -e 's
/^topgit-
//' )
39 ifneq ($(strip $(version)),)
40 version_arg = -e s/TG_VERSION=.*/TG_VERSION=$(version)/
45 all:: shell_compatibility_test precheck $(commands_out) $(utils_out) $(hooks_out) bin-wrappers/tg $(help_out) tg-tg.txt
47 please_set_SHELL_PATH_to_a_more_modern_shell:
50 shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
52 tg $(commands_out) $(utils_out) $(hooks_out): % : %.sh Makefile TG-BUILD-SETTINGS
54 @sed -e '1s|
#!.*/sh|#!$(SHELL_PATH_SQ)|' \
55 -e
's#@cmddir@#$(cmddir)#g;' \
56 -e
's#@hooksdir@#$(hooksdir)#g' \
57 -e
's#@bindir@#$(bindir)#g' \
58 -e
's#@sharedir@#$(sharedir)#g' \
59 -e
's#@mingitver@#$(GIT_MINIMUM_VERSION)#g' \
60 -e
's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
66 bin-wrappers
/tg
: $(commands_out
) $(utils_out
) $(hooks_out
) tg
68 @
[ -d bin-wrappers
] || mkdir bin-wrappers
69 @echo
'#!$(SHELL_PATH_SQ)' >"$@"
70 @curdir
="$$(pwd -P)"; \
71 echo
"TG_INST_CMDDIR='$$curdir' && export TG_INST_CMDDIR" >>"$@"; \
72 echo
"TG_INST_SHAREDIR='$$curdir' && export TG_INST_SHAREDIR" >>"$@"; \
73 echo
"TG_INST_HOOKSDIR='$$curdir' && export TG_INST_HOOKSDIR" >>"$@"; \
74 echo
"exec '$$curdir/tg' \"\$$@\"" >>"$@"
77 $(help_out
): README create-help.sh
78 @CMD
=`echo $@ | sed -e 's/tg-//' -e 's/\.txt//'` && \
79 echo
'[HELP]' $$CMD && \
80 $(SHELL_PATH
) .
/create-help.sh
$$CMD
82 .PHONY
: doc install-doc html
86 install-doc
:: install-html
88 html
:: topgit.html
$(html_out
)
90 tg-tg.txt
: README create-html-usage.pl
$(commands_in
)
92 @perl .
/create-html-usage.pl
--text
< README
> $@
94 topgit.html
: README create-html-usage.pl
$(commands_in
)
96 @perl .
/create-html-usage.pl
< README | rst2html.py
- $@
98 $(html_out
): create-html.sh
99 @CMD
=`echo $@ | sed -e 's/tg-//' -e 's/\.html//'` && \
100 echo
'[HTML]' $$CMD && \
101 $(SHELL_PATH
) .
/create-html.sh
$$CMD
109 @echo skipping precheck because DESTDIR is set
115 install -d
-m
755 "$(DESTDIR)$(bindir)"
116 install tg
"$(DESTDIR)$(bindir)"
117 install -d
-m
755 "$(DESTDIR)$(cmddir)"
118 install $(commands_out
) $(utils_out
) "$(DESTDIR)$(cmddir)"
119 install -d
-m
755 "$(DESTDIR)$(hooksdir)"
120 install $(hooks_out
) "$(DESTDIR)$(hooksdir)"
121 install -d
-m
755 "$(DESTDIR)$(sharedir)"
122 install -m
644 $(help_out
) tg-tg.txt
"$(DESTDIR)$(sharedir)"
123 install -m
644 leaves.awk
"$(DESTDIR)$(sharedir)"
128 install -d
-m
755 "$(DESTDIR)$(sharedir)"
129 install -m
644 topgit.html
$(html_out
) "$(DESTDIR)$(sharedir)"
134 rm -f tg
$(commands_out
) $(utils_out
) $(hooks_out
) $(help_out
) topgit.html
$(html_out
)
135 rm -f TG-BUILD-SETTINGS
139 define BUILD_SETTINGS
140 TG_INST_BINDIR
='$(bindir)'
141 TG_INST_CMDDIR
='$(cmddir)'
142 TG_INST_HOOKSDIR
='$(hooksdir)'
143 TG_INST_SHAREDIR
='$(sharedir)'
144 SHELL_PATH
='$(SHELL_PATH)'
145 TG_VERSION
='$(version)'
146 TG_GIT_MINIMUM_VERSION
='$(GIT_MINIMUM_VERSION)'
148 export BUILD_SETTINGS
150 TG-BUILD-SETTINGS
: FORCE
151 @if
test x
"$$BUILD_SETTINGS" != x
"`cat $@ 2>/dev/null`"; then \
152 echo
"* new build settings"; \
153 echo
"$$BUILD_SETTINGS" >$@
; \