tig-0.10.1.git
[tig] / Makefile
... / ...
CommitLineData
1## Makefile for tig
2
3all:
4
5# Include setting from the configure script
6-include config.make
7
8prefix ?= $(HOME)
9bindir ?= $(prefix)/bin
10datarootdir ?= $(prefix)/share
11sysconfdir ?= $(prefix)/etc
12docdir ?= $(datarootdir)/doc
13mandir ?= $(datarootdir)/man
14# DESTDIR=
15
16# Get version either via git or from VERSION file. Allow either
17# to be overwritten by setting DIST_VERSION on the command line.
18ifneq (,$(wildcard .git))
19GITDESC = $(subst tig-,,$(shell git describe))
20WTDIRTY = $(if $(shell git diff-index HEAD 2>/dev/null),-dirty)
21VERSION = $(GITDESC)$(WTDIRTY)
22else
23VERSION = $(shell test -f VERSION && cat VERSION || echo "unknown-version")
24endif
25ifdef DIST_VERSION
26VERSION = $(DIST_VERSION)
27endif
28
29# Split the version "TAG-OFFSET-gSHA1-DIRTY" into "TAG OFFSET"
30# and append 0 as a fallback offset for "exact" tagged versions.
31RPM_VERLIST = $(filter-out g% dirty,$(subst -, ,$(VERSION))) 0
32RPM_VERSION = $(word 1,$(RPM_VERLIST))
33RPM_RELEASE = $(word 2,$(RPM_VERLIST))$(if $(WTDIRTY),.dirty)
34
35LDLIBS ?= -lcurses
36CFLAGS ?= -Wall -O2
37DFLAGS = -g -DDEBUG -Werror
38PROGS = tig
39MANDOC = tig.1 tigrc.5
40HTMLDOC = tig.1.html tigrc.5.html manual.html README.html
41ALLDOC = $(MANDOC) $(HTMLDOC) manual.html-chunked manual.pdf
42
43# Never include the release number in the tarname for tagged
44# versions.
45ifneq ($(if $(DIST_VERSION),$(words $(RPM_VERLIST))),2)
46TARNAME = tig-$(RPM_VERSION)-$(RPM_RELEASE)
47else
48TARNAME = tig-$(RPM_VERSION)
49endif
50
51override CPPFLAGS += '-DTIG_VERSION="$(VERSION)"'
52override CPPFLAGS += '-DSYSCONFDIR="$(sysconfdir)"'
53
54AUTORECONF ?= autoreconf
55ASCIIDOC ?= asciidoc
56ASCIIDOC_FLAGS = -aversion=$(VERSION) -asysconfdir=$(sysconfdir)
57XMLTO ?= xmlto
58DOCBOOK2PDF ?= docbook2pdf
59
60all: $(PROGS)
61all-debug: $(PROGS)
62all-debug: CFLAGS += $(DFLAGS)
63doc: $(ALLDOC)
64doc-man: $(MANDOC)
65doc-html: $(HTMLDOC)
66
67install: all
68 mkdir -p $(DESTDIR)$(bindir) && \
69 for prog in $(PROGS); do \
70 install -p -m 0755 $$prog $(DESTDIR)$(bindir); \
71 done
72
73install-doc-man: doc-man
74 mkdir -p $(DESTDIR)$(mandir)/man1 \
75 $(DESTDIR)$(mandir)/man5
76 for doc in $(MANDOC); do \
77 case "$$doc" in \
78 *.1) install -p -m 0644 $$doc $(DESTDIR)$(mandir)/man1 ;; \
79 *.5) install -p -m 0644 $$doc $(DESTDIR)$(mandir)/man5 ;; \
80 esac \
81 done
82
83install-doc-html: doc-html
84 mkdir -p $(DESTDIR)$(docdir)/tig
85 for doc in $(HTMLDOC); do \
86 case "$$doc" in \
87 *.html) install -p -m 0644 $$doc $(DESTDIR)$(docdir)/tig ;; \
88 esac \
89 done
90
91install-doc: install-doc-man install-doc-html
92
93clean:
94 $(RM) -r $(TARNAME) *.spec tig-*.tar.gz tig-*.tar.gz.md5
95 $(RM) $(PROGS) core *.o *.xml
96
97distclean: clean
98 $(RM) -r manual.html-chunked *.toc $(ALLDOC)
99 $(RM) -r autom4te.cache aclocal.m4 config.{h,log,make,status} config.h.in configure
100
101spell-check:
102 aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
103
104strip: $(PROGS)
105 strip $(PROGS)
106
107dist: configure tig.spec
108 @mkdir -p $(TARNAME) && \
109 cp tig.spec configure config.h.in aclocal.m4 $(TARNAME) && \
110 echo $(VERSION) > $(TARNAME)/VERSION
111 git archive --format=tar --prefix=$(TARNAME)/ HEAD | \
112 tar --delete $(TARNAME)/VERSION > $(TARNAME).tar && \
113 tar rf $(TARNAME).tar `find $(TARNAME)/*` && \
114 gzip -f -9 $(TARNAME).tar && \
115 md5sum $(TARNAME).tar.gz > $(TARNAME).tar.gz.md5
116 @rm -rf $(TARNAME)
117
118rpm: dist
119 rpmbuild -ta $(TARNAME).tar.gz
120
121configure: configure.ac acinclude.m4
122 $(AUTORECONF) -v
123
124# Maintainer stuff
125release-doc:
126 git checkout release && \
127 git merge master && \
128 $(MAKE) distclean doc-man doc-html && \
129 git add -f $(MANDOC) $(HTMLDOC) && \
130 git commit -m "Sync docs" && \
131 git checkout master
132
133release-dist: release-doc
134 git checkout release && \
135 $(MAKE) dist && \
136 git checkout master
137
138.PHONY: all all-debug doc doc-man doc-html install install-doc \
139 install-doc-man install-doc-html clean spell-check dist rpm
140
141tig.o: tig.c
142tig: tig.o
143
144tig.spec: contrib/tig.spec.in
145 sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \
146 -e 's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
147
148manual.html: manual.toc
149manual.toc: manual.txt
150 sed -n '/^\[\[/,/\(---\|~~~\)/p' < $< | while read line; do \
151 case "$$line" in \
152 "-----"*) echo ". <<$$ref>>"; ref= ;; \
153 "~~~~~"*) echo "- <<$$ref>>"; ref= ;; \
154 "[["*"]]") ref="$$line" ;; \
155 *) ref="$$ref, $$line" ;; \
156 esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@
157
158README.html: README asciidoc.conf
159 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -a readme $<
160
161%.1.html : %.1.txt asciidoc.conf
162 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
163
164%.1.xml : %.1.txt asciidoc.conf
165 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
166
167%.5.html : %.5.txt asciidoc.conf
168 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
169
170%.5.xml : %.5.txt asciidoc.conf
171 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
172
173%.html : %.txt asciidoc.conf
174 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -n $<
175
176%.xml : %.txt asciidoc.conf
177 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d article $<
178
179% : %.xml
180 $(XMLTO) man $<
181
182%.html-chunked : %.xml
183 $(XMLTO) html -o $@ $<
184
185%.pdf : %.xml
186 $(DOCBOOK2PDF) $<