Rework README to include the list of online resources
[tig.git] / Makefile
blob03ccd235ae3b65d5684ceed7fcdb074becf5779a
1 ## Makefile for tig
3 # The last tagged version. Can be overridden either by the version from
4 # git or from the value of the DIST_VERSION environment variable.
5 VERSION = 1.2
7 all:
9 # Include kernel specific configuration
10 kernel_name := $(shell sh -c 'uname -s 2>/dev/null || echo unknown')
11 -include contrib/config.make-$(kernel_name)
13 # Include setting from the configure script
14 -include config.make
16 prefix ?= $(HOME)
17 bindir ?= $(prefix)/bin
18 datarootdir ?= $(prefix)/share
19 sysconfdir ?= $(prefix)/etc
20 docdir ?= $(datarootdir)/doc
21 mandir ?= $(datarootdir)/man
22 # DESTDIR=
24 ifneq (,$(wildcard .git))
25 GITDESC = $(subst tig-,,$(shell git describe))
26 WTDIRTY = $(if $(shell git diff-index HEAD 2>/dev/null),-dirty)
27 VERSION = $(GITDESC)$(WTDIRTY)
28 endif
29 ifdef DIST_VERSION
30 VERSION = $(DIST_VERSION)
31 endif
33 # Split the version "TAG-OFFSET-gSHA1-DIRTY" into "TAG OFFSET"
34 # and append 0 as a fallback offset for "exact" tagged versions.
35 RPM_VERLIST = $(filter-out g% dirty,$(subst -, ,$(VERSION))) 0
36 RPM_VERSION = $(word 1,$(RPM_VERLIST))
37 RPM_RELEASE = $(word 2,$(RPM_VERLIST))$(if $(WTDIRTY),.dirty)
39 LDLIBS ?= -lcurses
40 CFLAGS ?= -Wall -O2
41 DFLAGS = -g -DDEBUG -Werror -O0
42 PROGS = tig
43 TESTS = test-graph
44 TXTDOC = doc/tig.1.asciidoc doc/tigrc.5.asciidoc doc/manual.asciidoc NEWS README INSTALL BUGS
45 MANDOC = doc/tig.1 doc/tigrc.5 doc/tigmanual.7
46 HTMLDOC = doc/tig.1.html doc/tigrc.5.html doc/manual.html README.html INSTALL.html NEWS.html
47 ALLDOC = $(MANDOC) $(HTMLDOC) doc/manual.html-chunked doc/manual.pdf
49 # Never include the release number in the tarname for tagged
50 # versions.
51 ifneq ($(if $(DIST_VERSION),$(words $(RPM_VERLIST))),2)
52 TARNAME = tig-$(RPM_VERSION)-$(RPM_RELEASE)
53 else
54 TARNAME = tig-$(RPM_VERSION)
55 endif
57 override CPPFLAGS += '-DTIG_VERSION="$(VERSION)"'
58 override CPPFLAGS += '-DSYSCONFDIR="$(sysconfdir)"'
60 ASCIIDOC ?= asciidoc
61 ASCIIDOC_FLAGS = -aversion=$(VERSION) -asysconfdir=$(sysconfdir) -f doc/asciidoc.conf
62 XMLTO ?= xmlto
63 DOCBOOK2PDF ?= docbook2pdf
65 all: $(PROGS) $(TESTS)
66 all-debug: $(PROGS) $(TESTS)
67 all-debug: CFLAGS += $(DFLAGS)
68 doc: $(ALLDOC)
69 doc-man: $(MANDOC)
70 doc-html: $(HTMLDOC)
72 install: all
73 mkdir -p $(DESTDIR)$(bindir) && \
74 for prog in $(PROGS); do \
75 install -p -m 0755 "$$prog" "$(DESTDIR)$(bindir)"; \
76 done
78 install-doc-man: doc-man
79 mkdir -p $(DESTDIR)$(mandir)/man1 \
80 $(DESTDIR)$(mandir)/man5 \
81 $(DESTDIR)$(mandir)/man7
82 for doc in $(MANDOC); do \
83 sed 's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
84 bdoc=$$(basename $$doc); \
85 case "$$doc" in \
86 *.1) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man1/$$bdoc" ;; \
87 *.5) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man5/$$bdoc" ;; \
88 *.7) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man7/$$bdoc" ;; \
89 esac; \
90 $(RM) "$$doc+"; \
91 done
93 install-release-doc-man:
94 GIT_INDEX_FILE=.tmp-doc-index git read-tree origin/release
95 GIT_INDEX_FILE=.tmp-doc-index git checkout-index -f --prefix=./ $(MANDOC)
96 rm -f .tmp-doc-index
97 $(MAKE) install-doc-man
99 install-doc-html: doc-html
100 mkdir -p $(DESTDIR)$(docdir)/tig
101 for doc in $(HTMLDOC); do \
102 sed 's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
103 case "$$doc" in \
104 *.html) install -p -m 0644 "$$doc+" "$(DESTDIR)$(docdir)/tig/$$doc" ;; \
105 esac; \
106 $(RM) "$$doc+"; \
107 done
109 install-release-doc-html:
110 GIT_INDEX_FILE=.tmp-doc-index git read-tree origin/release
111 GIT_INDEX_FILE=.tmp-doc-index git checkout-index -f --prefix=./ $(HTMLDOC)
112 rm -f .tmp-doc-index
113 $(MAKE) install-doc-html
115 install-doc: install-doc-man install-doc-html
116 install-release-doc: install-release-doc-man install-release-doc-html
118 clean:
119 $(RM) -r $(TARNAME) *.spec tig-*.tar.gz tig-*.tar.gz.md5
120 $(RM) $(PROGS) $(TESTS) core *.o compat/*.o *.xml
122 distclean: clean
123 $(RM) -r doc/manual.html-chunked autom4te.cache release-docs
124 $(RM) doc/*.toc $(ALLDOC) aclocal.m4 configure
125 $(RM) config.h config.log config.make config.status config.h.in
127 spell-check:
128 for file in $(TXTDOC) tig.c; do \
129 aspell --lang=en --dont-backup \
130 --personal=./contrib/aspell.dict check $$file; \
131 done
133 strip: $(PROGS)
134 strip $(PROGS)
136 update-headers:
137 @for file in *.[ch]; do \
138 grep -q '/* Copyright' "$$file" && \
139 sed '0,/.*\*\//d' < "$$file" | \
140 grep -v '/* vim: set' > "$$file.tmp"; \
141 { cat contrib/header.h "$$file.tmp"; \
142 echo "/* vim: set ts=8 sw=8 noexpandtab: */"; } > "$$file"; \
143 rm "$$file.tmp"; \
144 echo "Updated $$file"; \
145 done
147 dist: configure tig.spec
148 @mkdir -p $(TARNAME) && \
149 cp Makefile tig.spec configure config.h.in aclocal.m4 $(TARNAME) && \
150 sed -i "s/VERSION\s=\s[0-9]\+[.][0-9]\+/VERSION = $(VERSION)/" $(TARNAME)/Makefile
151 git archive --format=tar --prefix=$(TARNAME)/ HEAD | \
152 tar --delete $(TARNAME)/Makefile > $(TARNAME).tar && \
153 tar rf $(TARNAME).tar `find $(TARNAME)/*` && \
154 gzip -f -9 $(TARNAME).tar && \
155 md5sum $(TARNAME).tar.gz > $(TARNAME).tar.gz.md5
156 @$(RM) -r $(TARNAME)
158 rpm: dist
159 rpmbuild -ta $(TARNAME).tar.gz
161 # Other autoconf-related rules are hidden in config.make.in so that
162 # they don't confuse Make when we aren't actually using ./configure
163 configure: configure.ac acinclude.m4 contrib/*.m4
164 ./autogen.sh
166 .PHONY: all all-debug doc doc-man doc-html install install-doc \
167 install-doc-man install-doc-html clean spell-check dist rpm
169 ifdef NO_MKSTEMPS
170 COMPAT_CPPFLAGS += -DNO_MKSTEMPS
171 COMPAT_OBJS += compat/mkstemps.o
172 endif
174 ifdef NO_SETENV
175 COMPAT_CPPFLAGS += -DNO_SETENV
176 COMPAT_OBJS += compat/setenv.o
177 endif
179 override CPPFLAGS += $(COMPAT_CPPFLAGS)
181 graph.o: graph.c tig.h graph.h
182 io.o: io.c tig.h io.h
183 refs.o: refs.c tig.h io.h refs.h
184 test-graph.o: test-graph.c tig.h io.h graph.h
185 tig.o: tig.c tig.h io.h refs.h graph.h git.h
187 tig: tig.o io.o graph.o refs.o $(COMPAT_OBJS)
188 test-graph: io.o graph.o
190 # To check the above.
192 # NOTE: Assumes GCC, and that no local headers are conditionally
193 # included (with the exception of config.h, which we take care of in
194 # config.make).
195 show-deps:
196 @echo "== without config.h =="
197 $(CC) -MM *.c
198 @echo "== with config.h =="
199 $(CC) -DHAVE_CONFIG_H -MM *.c
201 tig.spec: contrib/tig.spec.in
202 sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \
203 -e 's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
205 doc/manual.html: doc/manual.toc
206 doc/manual.html: ASCIIDOC_FLAGS += -ainclude-manual-toc
207 %.toc: %.asciidoc
208 sed -n '/^\[\[/,/\(---\|~~~\)/p' < $< | while read line; do \
209 case "$$line" in \
210 "----"*) echo ". <<$$ref>>"; ref= ;; \
211 "~~~~"*) echo "- <<$$ref>>"; ref= ;; \
212 "[["*"]]") ref="$$line" ;; \
213 *) ref="$$ref, $$line" ;; \
214 esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@
216 README.html: README doc/asciidoc.conf
217 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -a readme $<
219 INSTALL.html: INSTALL doc/asciidoc.conf
220 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article $<
222 NEWS.html: NEWS doc/asciidoc.conf
223 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article $<
225 doc/tigmanual.7: doc/manual.asciidoc
227 %.1.html : %.1.asciidoc doc/asciidoc.conf
228 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
230 %.1.xml : %.1.asciidoc doc/asciidoc.conf
231 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
233 %.5.html : %.5.asciidoc doc/asciidoc.conf
234 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
236 %.5.xml : %.5.asciidoc doc/asciidoc.conf
237 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
239 %.7.xml : %.7.asciidoc doc/asciidoc.conf
240 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
242 %.html : %.asciidoc doc/asciidoc.conf
243 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -n $<
245 %.xml : %.asciidoc doc/asciidoc.conf
246 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d article $<
248 % : %.xml
249 $(XMLTO) man -o doc $<
251 %.html-chunked : %.xml
252 $(XMLTO) html -o $@ $<
254 %.pdf : %.xml
255 $(DOCBOOK2PDF) -o doc $<