diff: get pathname of combined diff headers
[tig.git] / Makefile
blobd08fe60e24f3e1aec8f622839f3d4ae9d1c5de2a
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 AUTORECONF ?= autoreconf
62 ASCIIDOC ?= asciidoc
63 ASCIIDOC_FLAGS = -aversion=$(VERSION) -asysconfdir=$(sysconfdir)
64 XMLTO ?= xmlto
65 DOCBOOK2PDF ?= docbook2pdf
67 all: $(PROGS) $(TESTS)
68 all-debug: $(PROGS) $(TESTS)
69 all-debug: CFLAGS += $(DFLAGS)
70 doc: $(ALLDOC)
71 doc-man: $(MANDOC)
72 doc-html: $(HTMLDOC)
74 install: all
75 mkdir -p $(DESTDIR)$(bindir) && \
76 for prog in $(PROGS); do \
77 install -p -m 0755 "$$prog" "$(DESTDIR)$(bindir)"; \
78 done
80 install-doc-man: doc-man
81 mkdir -p $(DESTDIR)$(mandir)/man1 \
82 $(DESTDIR)$(mandir)/man5 \
83 $(DESTDIR)$(mandir)/man7
84 for doc in $(MANDOC); do \
85 sed 's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
86 case "$$doc" in \
87 *.1) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man1/$$doc" ;; \
88 *.5) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man5/$$doc" ;; \
89 *.7) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man7/$$doc" ;; \
90 esac; \
91 $(RM) "$$doc+"; \
92 done
94 install-release-doc-man:
95 GIT_INDEX_FILE=.tmp-doc-index git read-tree origin/release
96 GIT_INDEX_FILE=.tmp-doc-index git checkout-index -f --prefix=./ $(MANDOC)
97 rm -f .tmp-doc-index
98 $(MAKE) install-doc-man
100 install-doc-html: doc-html
101 mkdir -p $(DESTDIR)$(docdir)/tig
102 for doc in $(HTMLDOC); do \
103 sed 's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
104 case "$$doc" in \
105 *.html) install -p -m 0644 "$$doc+" "$(DESTDIR)$(docdir)/tig/$$doc" ;; \
106 esac; \
107 $(RM) "$$doc+"; \
108 done
110 install-release-doc-html:
111 GIT_INDEX_FILE=.tmp-doc-index git read-tree origin/release
112 GIT_INDEX_FILE=.tmp-doc-index git checkout-index -f --prefix=./ $(HTMLDOC)
113 rm -f .tmp-doc-index
114 $(MAKE) install-doc-html
116 install-doc: install-doc-man install-doc-html
117 install-release-doc: install-release-doc-man install-release-doc-html
119 clean:
120 $(RM) -r $(TARNAME) *.spec tig-*.tar.gz tig-*.tar.gz.md5
121 $(RM) $(PROGS) $(TESTS) core *.o *.xml
123 distclean: clean
124 $(RM) -r manual.html-chunked autom4te.cache
125 $(RM) *.toc $(ALLDOC) aclocal.m4 configure
126 $(RM) config.h config.log config.make config.status config.h.in
128 spell-check:
129 for file in $(TXTDOC) tig.c; do \
130 aspell --lang=en --dont-backup \
131 --personal=./contrib/aspell.dict check $$file; \
132 done
134 strip: $(PROGS)
135 strip $(PROGS)
137 dist: configure tig.spec
138 @mkdir -p $(TARNAME) && \
139 cp Makefile tig.spec configure config.h.in aclocal.m4 $(TARNAME) && \
140 sed -i "s/VERSION\s=\s[0-9]\+[.][0-9]\+/VERSION = $(VERSION)/" $(TARNAME)/Makefile
141 git archive --format=tar --prefix=$(TARNAME)/ HEAD | \
142 tar --delete $(TARNAME)/Makefile > $(TARNAME).tar && \
143 tar rf $(TARNAME).tar `find $(TARNAME)/*` && \
144 gzip -f -9 $(TARNAME).tar && \
145 md5sum $(TARNAME).tar.gz > $(TARNAME).tar.gz.md5
146 @$(RM) -r $(TARNAME)
148 rpm: dist
149 rpmbuild -ta $(TARNAME).tar.gz
151 configure: configure.ac acinclude.m4
152 $(AUTORECONF) -v -I contrib
154 .PHONY: all all-debug doc doc-man doc-html install install-doc \
155 install-doc-man install-doc-html clean spell-check dist rpm
157 io.o: io.c io.h tig.h
158 graph.o: graph.c graph.h tig.h
159 refs.o: refs.c refs.h tig.h
160 tig.o: tig.c tig.h graph.h io.h refs.h git.h
161 tig: tig.o io.o graph.o refs.o
162 test-graph.o: test-graph.c io.h tig.h graph.h
163 test-graph: io.o graph.o
165 tig.spec: contrib/tig.spec.in
166 sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \
167 -e 's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
169 manual.html: manual.toc
170 manual.toc: manual.txt
171 sed -n '/^\[\[/,/\(---\|~~~\)/p' < $< | while read line; do \
172 case "$$line" in \
173 "----"*) echo ". <<$$ref>>"; ref= ;; \
174 "~~~~"*) echo "- <<$$ref>>"; ref= ;; \
175 "[["*"]]") ref="$$line" ;; \
176 *) ref="$$ref, $$line" ;; \
177 esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@
179 README.html: README SITES INSTALL asciidoc.conf
180 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -a readme $<
182 NEWS.html: NEWS asciidoc.conf
183 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article $<
185 tigmanual.7: manual.txt
187 %.1.html : %.1.txt asciidoc.conf
188 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
190 %.1.xml : %.1.txt asciidoc.conf
191 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
193 %.5.html : %.5.txt asciidoc.conf
194 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
196 %.5.xml : %.5.txt asciidoc.conf
197 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
199 %.7.xml : %.7.txt asciidoc.conf
200 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
202 %.html : %.txt asciidoc.conf
203 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -n $<
205 %.xml : %.txt asciidoc.conf
206 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d article $<
208 % : %.xml
209 $(XMLTO) man $<
211 %.html-chunked : %.xml
212 $(XMLTO) html -o $@ $<
214 %.pdf : %.xml
215 $(DOCBOOK2PDF) $<