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 help_out
= $(patsubst %.sh
,%.txt
,tg-help.sh tg-status.sh
$(commands_in
))
28 html_out
= $(patsubst %.sh
,%.html
,tg-help.sh tg-status.sh tg-tg.sh
$(commands_in
))
31 SHELL_PATH_SQ
= $(subst ','\'',$(SHELL_PATH))
33 version := $(shell test -d .git && git describe --match "topgit-[0-9]*" --abbrev=4 --dirty 2>/dev/null | sed -e 's
/^topgit-
//' )
38 ifneq ($(strip $(version)),)
39 version_arg = -e s/TG_VERSION=.*/TG_VERSION=$(version)/
44 all:: shell_compatibility_test precheck $(commands_out) $(utils_out) $(hooks_out) bin-wrappers/tg $(help_out) tg-tg.txt
46 please_set_SHELL_PATH_to_a_more_modern_shell:
49 shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
51 tg $(commands_out) $(utils_out) $(hooks_out): % : %.sh Makefile TG-BUILD-SETTINGS
53 @sed -e '1s|
#!.*/sh|#!$(SHELL_PATH_SQ)|' \
54 -e
's#@cmddir@#$(cmddir)#g;' \
55 -e
's#@hooksdir@#$(hooksdir)#g' \
56 -e
's#@bindir@#$(bindir)#g' \
57 -e
's#@sharedir@#$(sharedir)#g' \
58 -e
's#@mingitver@#$(GIT_MINIMUM_VERSION)#g' \
59 -e
's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
65 bin-wrappers
/tg
: $(commands_out
) $(utils_out
) $(hooks_out
) tg
67 @
[ -d bin-wrappers
] || mkdir bin-wrappers
68 @echo
'#!$(SHELL_PATH_SQ)' >"$@"
69 @curdir
="$$(pwd -P)"; \
70 echo
"TG_INST_CMDDIR='$$curdir' && export TG_INST_CMDDIR" >>"$@"; \
71 echo
"TG_INST_SHAREDIR='$$curdir' && export TG_INST_SHAREDIR" >>"$@"; \
72 echo
"TG_INST_HOOKSDIR='$$curdir' && export TG_INST_HOOKSDIR" >>"$@"; \
73 echo
"exec '$$curdir/tg' \"\$$@\"" >>"$@"
76 $(help_out
): README create-help.sh
77 @CMD
=`echo $@ | sed -e 's/tg-//' -e 's/\.txt//'` && \
78 echo
'[HELP]' $$CMD && \
79 $(SHELL_PATH
) .
/create-help.sh
$$CMD
81 .PHONY
: doc install-doc html
85 install-doc
:: install-html
87 html
:: topgit.html
$(html_out
)
89 tg-tg.txt
: README create-html-usage.pl
$(commands_in
)
91 @perl .
/create-html-usage.pl
--text
< README
> $@
93 topgit.html
: README create-html-usage.pl
$(commands_in
)
95 @perl .
/create-html-usage.pl
< README | rst2html.py
- $@
97 $(html_out
): create-html.sh
98 @CMD
=`echo $@ | sed -e 's/tg-//' -e 's/\.html//'` && \
99 echo
'[HTML]' $$CMD && \
100 $(SHELL_PATH
) .
/create-html.sh
$$CMD
108 @echo skipping precheck because DESTDIR is set
114 install -d
-m
755 "$(DESTDIR)$(bindir)"
115 install tg
"$(DESTDIR)$(bindir)"
116 install -d
-m
755 "$(DESTDIR)$(cmddir)"
117 install $(commands_out
) $(utils_out
) "$(DESTDIR)$(cmddir)"
118 install -d
-m
755 "$(DESTDIR)$(hooksdir)"
119 install $(hooks_out
) "$(DESTDIR)$(hooksdir)"
120 install -d
-m
755 "$(DESTDIR)$(sharedir)"
121 install -m
644 $(help_out
) tg-tg.txt
"$(DESTDIR)$(sharedir)"
122 install -m
644 leaves.awk
"$(DESTDIR)$(sharedir)"
127 install -d
-m
755 "$(DESTDIR)$(sharedir)"
128 install -m
644 topgit.html
$(html_out
) "$(DESTDIR)$(sharedir)"
133 rm -f tg
$(commands_out
) $(utils_out
) $(hooks_out
) $(help_out
) topgit.html
$(html_out
)
134 rm -f TG-BUILD-SETTINGS
138 define BUILD_SETTINGS
139 TG_INST_BINDIR
='$(bindir)'
140 TG_INST_CMDDIR
='$(cmddir)'
141 TG_INST_HOOKSDIR
='$(hooksdir)'
142 TG_INST_SHAREDIR
='$(sharedir)'
143 SHELL_PATH
='$(SHELL_PATH)'
144 TG_VERSION
='$(version)'
145 TG_GIT_MINIMUM_VERSION
='$(GIT_MINIMUM_VERSION)'
147 export BUILD_SETTINGS
149 TG-BUILD-SETTINGS
: FORCE
150 @if
test x
"$$BUILD_SETTINGS" != x
"`cat $@ 2>/dev/null`"; then \
151 echo
"* new build settings"; \
152 echo
"$$BUILD_SETTINGS" >$@
; \