5 # Include setting from the configure script
9 bindir ?= $(prefix)/bin
10 datarootdir ?= $(prefix)/share
11 docdir ?= $(datarootdir)/doc
12 mandir ?= $(datarootdir)/man
15 # Get version either via git or from VERSION file. Allow either
16 # to be overwritten by setting DIST_VERSION on the command line.
17 ifneq (,$(wildcard .git))
18 GITDESC = $(subst tig-,,$(shell git describe))
19 WTDIRTY = $(if $(shell git diff-index HEAD 2>/dev/null),-dirty)
20 VERSION = $(GITDESC)$(WTDIRTY)
22 VERSION = $(shell test -f VERSION && cat VERSION || echo "unknown-version")
25 VERSION = $(DIST_VERSION)
28 # Split the version "TAG-OFFSET-gSHA1-DIRTY" into "TAG OFFSET"
29 # and append 0 as a fallback offset for "exact" tagged versions.
30 RPM_VERLIST = $(filter-out g% dirty,$(subst -, ,$(VERSION))) 0
31 RPM_VERSION = $(word 1,$(RPM_VERLIST))
32 RPM_RELEASE = $(word 2,$(RPM_VERLIST))$(if $(WTDIRTY),.dirty)
36 DFLAGS = -g -DDEBUG -Werror
38 MANDOC = tig.1 tigrc.5
39 HTMLDOC = tig.1.html tigrc.5.html manual.html README.html
40 ALLDOC = $(MANDOC) $(HTMLDOC) manual.html-chunked manual.pdf
42 # Never include the release number in the tarname for tagged
44 ifneq ($(if $(DIST_VERSION),$(words $(RPM_VERLIST))),2)
45 TARNAME = tig-$(RPM_VERSION)-$(RPM_RELEASE)
47 TARNAME = tig-$(RPM_VERSION)
50 override CFLAGS += '-DTIG_VERSION="$(VERSION)"'
52 AUTORECONF ?= autoreconf
54 ASCIIDOC_FLAGS = -aversion=$(VERSION)
56 DOCBOOK2PDF ?= docbook2pdf
60 all-debug: CFLAGS += $(DFLAGS)
66 mkdir -p $(DESTDIR)$(bindir) && \
67 for prog in $(PROGS); do \
68 install -p -m 0755 $$prog $(DESTDIR)$(bindir); \
71 install-doc-man: doc-man
72 mkdir -p $(DESTDIR)$(mandir)/man1 \
73 $(DESTDIR)$(mandir)/man5
74 for doc in $(MANDOC); do \
76 *.1) install -p -m 0644 $$doc $(DESTDIR)$(mandir)/man1 ;; \
77 *.5) install -p -m 0644 $$doc $(DESTDIR)$(mandir)/man5 ;; \
81 install-doc-html: doc-html
82 mkdir -p $(DESTDIR)$(docdir)/tig
83 for doc in $(HTMLDOC); do \
85 *.html) install -p -m 0644 $$doc $(DESTDIR)$(docdir)/tig ;; \
89 install-doc: install-doc-man install-doc-html
92 $(RM) -r $(TARNAME) *.spec tig-*.tar.gz tig-*.tar.gz.md5
93 $(RM) $(PROGS) core *.o *.xml
96 $(RM) -r manual.html-chunked *.toc $(ALLDOC)
97 $(RM) -r autom4te.cache aclocal.m4 config.{h,log,make,status} config.h.in configure
100 aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
105 dist: configure tig.spec
106 @mkdir -p $(TARNAME) && \
107 cp tig.spec configure config.h.in aclocal.m4 $(TARNAME) && \
108 echo $(VERSION) > $(TARNAME)/VERSION
109 git archive --format=tar --prefix=$(TARNAME)/ HEAD | \
110 tar --delete $(TARNAME)/VERSION > $(TARNAME).tar && \
111 tar rf $(TARNAME).tar `find $(TARNAME)/*` && \
112 gzip -f -9 $(TARNAME).tar && \
113 md5sum $(TARNAME).tar.gz > $(TARNAME).tar.gz.md5
117 rpmbuild -ta $(TARNAME).tar.gz
119 configure: configure.ac acinclude.m4
124 git checkout release && \
125 git merge master && \
126 $(MAKE) distclean doc-man doc-html && \
127 git add -f $(MANDOC) $(HTMLDOC) && \
128 git commit -m "Sync docs" && \
131 release-dist: release-doc
132 git checkout release && \
136 .PHONY: all all-debug doc doc-man doc-html install install-doc \
137 install-doc-man install-doc-html clean spell-check dist rpm
142 tig.spec: contrib/tig.spec.in
143 sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \
144 -e 's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
146 manual.html: manual.toc
147 manual.toc: manual.txt
148 sed -n '/^\[\[/,/\(---\|~~~\)/p' < $< | while read line; do \
150 "-----"*) echo ". <<$$ref>>"; ref= ;; \
151 "~~~~~"*) echo "- <<$$ref>>"; ref= ;; \
152 "[["*"]]") ref="$$line" ;; \
153 *) ref="$$ref, $$line" ;; \
154 esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@
156 README.html: README asciidoc.conf
157 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -a readme $<
159 %.1.html : %.1.txt asciidoc.conf
160 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
162 %.1.xml : %.1.txt asciidoc.conf
163 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
165 %.5.html : %.5.txt asciidoc.conf
166 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
168 %.5.xml : %.5.txt asciidoc.conf
169 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
171 %.html : %.txt asciidoc.conf
172 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -n $<
174 %.xml : %.txt asciidoc.conf
175 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d article $<
180 %.html-chunked : %.xml
181 $(XMLTO) html -o $@ $<