Do not show deleted branch when reloading the branch view
[tig.git] / Makefile
blobe9f1b20aa9b22a7dacb9d3d699e74c6ce773502a
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.0
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 SOURCE = tig.c tig.h io.c io.h graph.c graph.h
45 TXTDOC = tig.1.txt tigrc.5.txt manual.txt NEWS README INSTALL BUGS
46 MANDOC = tig.1 tigrc.5 tigmanual.7
47 HTMLDOC = tig.1.html tigrc.5.html manual.html README.html NEWS.html
48 ALLDOC = $(MANDOC) $(HTMLDOC) manual.html-chunked manual.pdf
50 # Never include the release number in the tarname for tagged
51 # versions.
52 ifneq ($(if $(DIST_VERSION),$(words $(RPM_VERLIST))),2)
53 TARNAME = tig-$(RPM_VERSION)-$(RPM_RELEASE)
54 else
55 TARNAME = tig-$(RPM_VERSION)
56 endif
58 override CPPFLAGS += '-DTIG_VERSION="$(VERSION)"'
59 override CPPFLAGS += '-DSYSCONFDIR="$(sysconfdir)"'
61 ASCIIDOC ?= asciidoc
62 ASCIIDOC_FLAGS = -aversion=$(VERSION) -asysconfdir=$(sysconfdir)
63 XMLTO ?= xmlto
64 DOCBOOK2PDF ?= docbook2pdf
66 all: $(PROGS) $(TESTS)
67 all-debug: $(PROGS) $(TESTS)
68 all-debug: CFLAGS += $(DFLAGS)
69 doc: $(ALLDOC)
70 doc-man: $(MANDOC)
71 doc-html: $(HTMLDOC)
73 install: all
74 mkdir -p $(DESTDIR)$(bindir) && \
75 for prog in $(PROGS); do \
76 install -p -m 0755 "$$prog" "$(DESTDIR)$(bindir)"; \
77 done
79 install-doc-man: doc-man
80 mkdir -p $(DESTDIR)$(mandir)/man1 \
81 $(DESTDIR)$(mandir)/man5 \
82 $(DESTDIR)$(mandir)/man7
83 for doc in $(MANDOC); do \
84 sed 's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
85 case "$$doc" in \
86 *.1) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man1/$$doc" ;; \
87 *.5) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man5/$$doc" ;; \
88 *.7) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man7/$$doc" ;; \
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 *.xml
122 distclean: clean
123 $(RM) -r manual.html-chunked autom4te.cache
124 $(RM) *.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 dist: configure tig.spec
137 @mkdir -p $(TARNAME) && \
138 cp Makefile tig.spec configure config.h.in aclocal.m4 $(TARNAME) && \
139 sed -i "s/VERSION\s=\s[0-9]\+[.][0-9]\+/VERSION = $(VERSION)/" $(TARNAME)/Makefile
140 git archive --format=tar --prefix=$(TARNAME)/ HEAD | \
141 tar --delete $(TARNAME)/Makefile > $(TARNAME).tar && \
142 tar rf $(TARNAME).tar `find $(TARNAME)/*` && \
143 gzip -f -9 $(TARNAME).tar && \
144 md5sum $(TARNAME).tar.gz > $(TARNAME).tar.gz.md5
145 @$(RM) -r $(TARNAME)
147 rpm: dist
148 rpmbuild -ta $(TARNAME).tar.gz
150 # Other autoconf-related rules are hidden in config.make.in so that
151 # they don't confuse Make when we aren't actually using ./configure
152 configure: configure.ac acinclude.m4 contrib/*.m4
153 ./autogen.sh
155 .PHONY: all all-debug doc doc-man doc-html install install-doc \
156 install-doc-man install-doc-html clean spell-check dist rpm
158 graph.o: graph.c tig.h graph.h
159 io.o: io.c tig.h io.h
160 refs.o: refs.c tig.h io.h refs.h
161 test-graph.o: test-graph.c tig.h io.h graph.h
162 tig.o: tig.c tig.h io.h refs.h graph.h git.h
164 tig: tig.o io.o graph.o refs.o
165 test-graph: io.o graph.o
167 # To check the above.
169 # NOTE: Assumes GCC, and that no local headers are conditionally
170 # included (with the exception of config.h, which we take care of in
171 # config.make).
172 show-deps:
173 @echo "== without config.h =="
174 $(CC) -MM *.c
175 @echo "== with config.h =="
176 $(CC) -DHAVE_CONFIG_H -MM *.c
178 tig.spec: contrib/tig.spec.in
179 sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \
180 -e 's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
182 manual.html: manual.toc
183 manual.toc: manual.txt
184 sed -n '/^\[\[/,/\(---\|~~~\)/p' < $< | while read line; do \
185 case "$$line" in \
186 "----"*) echo ". <<$$ref>>"; ref= ;; \
187 "~~~~"*) echo "- <<$$ref>>"; ref= ;; \
188 "[["*"]]") ref="$$line" ;; \
189 *) ref="$$ref, $$line" ;; \
190 esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@
192 README.html: README SITES INSTALL asciidoc.conf
193 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -a readme $<
195 NEWS.html: NEWS asciidoc.conf
196 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article $<
198 tigmanual.7: manual.txt
200 %.1.html : %.1.txt asciidoc.conf
201 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
203 %.1.xml : %.1.txt asciidoc.conf
204 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
206 %.5.html : %.5.txt asciidoc.conf
207 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
209 %.5.xml : %.5.txt asciidoc.conf
210 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
212 %.7.xml : %.7.txt asciidoc.conf
213 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
215 %.html : %.txt asciidoc.conf
216 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -n $<
218 %.xml : %.txt asciidoc.conf
219 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d article $<
221 % : %.xml
222 $(XMLTO) man $<
224 %.html-chunked : %.xml
225 $(XMLTO) html -o $@ $<
227 %.pdf : %.xml
228 $(DOCBOOK2PDF) $<