Set version to 0.13.1
[topgit/pro.git] / Makefile
blobcdac55b381d8a048e3ffb2e6d603ab461370451c
1 # NOTE: Requires GNU make
3 all::
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
9 export MAKE
11 prefix ?= $(HOME)
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-//' )
27 -include config.mak
29 ifneq ($(strip $(version)),)
30 version_arg = -e s/TG_VERSION=.*/TG_VERSION=$(version)/
31 endif
33 .PHONY: FORCE
35 all:: precheck $(commands_out) $(hooks_out) $(help_out)
37 tg $(commands_out) $(hooks_out): % : %.sh Makefile TG-PREFIX
38 @echo "[SED] $@"
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' \
43 $(version_arg) \
44 $@.sh >$@+ && \
45 chmod +x $@+ && \
46 mv $@+ $@
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
53 .PHONY: html
55 html:: topgit.html $(html_out)
57 topgit.html: README create-html-usage.pl
58 @echo '[HTML] topgit'
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
66 .PHONY: precheck
68 precheck:: tg
69 ifeq ($(DESTDIR),)
70 ./$+ precheck
71 else
72 @echo skipping precheck because DESTDIR is set
73 endif
75 .PHONY: install
77 install:: all
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)"
89 .PHONY: install-html
91 install-html:: html
92 install -d -m 755 "$(DESTDIR)$(sharedir)"
93 install -m 644 topgit.html $(html_out) "$(DESTDIR)$(sharedir)"
95 .PHONY: clean
97 clean::
98 rm -f tg $(commands_out) $(hooks_out) $(help_out) topgit.html $(html_out)
99 rm -f TG-PREFIX
101 define TRACK_PREFIX
102 $(bindir):$(cmddir):$(hooksdir):$(sharedir):$(version)
103 endef
104 export TRACK_PREFIX
106 TG-PREFIX: FORCE
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; \