chiark / gitweb /
Add version information to man pages
[tig] / Makefile
CommitLineData
5f7b975a
JH
1prefix = $(HOME)
2bindir= $(prefix)/bin
3mandir = $(prefix)/man
bb8afc29 4docdir = $(prefix)/share/doc
5f7b975a
JH
5# DESTDIR=
6
a6ec85e1 7LDLIBS = -lcurses
900666fc 8CFLAGS = -Wall -O2
19f862bd 9DFLAGS = -g -DDEBUG -Werror
b801d8b2 10PROGS = tig
ec4b9d91
GK
11DOCS_MAN = tig.1 tigrc.5
12DOCS_HTML = tig.1.html tigrc.5.html \
13 manual.html manual.html-chunked \
14 README.html
15DOCS = $(DOCS_MAN) $(DOCS_HTML) \
16 manual.toc manual.pdf
e2beda18
JF
17
18ifneq (,$(wildcard .git))
bb0ab19f
JF
19GITDESC = $(subst tig-,,$(shell git describe))
20WTDIRTY = $(if $(shell git-diff-index HEAD 2>/dev/null),-dirty)
21VERSION = $(GITDESC)$(WTDIRTY)
22CFLAGS += '-DVERSION="tig-$(VERSION)"'
e2beda18 23endif
800a900c 24
a7bc4b14 25all: $(PROGS)
82e78006
JF
26all-debug: $(PROGS)
27all-debug: CFLAGS += $(DFLAGS)
c92615b1 28doc: $(DOCS)
ec4b9d91
GK
29doc-man: $(DOCS_MAN)
30doc-html: $(DOCS_HTML)
800a900c 31
05f1685b 32install: all
d441a715 33 mkdir -p $(DESTDIR)$(bindir) && \
a7bc4b14 34 for prog in $(PROGS); do \
5f7b975a 35 install $$prog $(DESTDIR)$(bindir); \
4c6fabc2
JF
36 done
37
ec4b9d91 38install-doc-man: doc-man
bb8afc29 39 mkdir -p $(DESTDIR)$(mandir)/man1 \
ec4b9d91 40 $(DESTDIR)$(mandir)/man5
4c6fabc2
JF
41 for doc in $(DOCS); do \
42 case "$$doc" in \
5f7b975a
JH
43 *.1) install $$doc $(DESTDIR)$(mandir)/man1 ;; \
44 *.5) install $$doc $(DESTDIR)$(mandir)/man5 ;; \
ec4b9d91
GK
45 esac \
46 done
47
48install-doc-html: doc-html
49 mkdir -p $(DESTDIR)$(docdir)/tig
50 for doc in $(DOCS); do \
51 case "$$doc" in \
bb8afc29 52 *.html) install $$doc $(DESTDIR)$(docdir)/tig ;; \
4c6fabc2 53 esac \
a7bc4b14 54 done
05f1685b 55
ec4b9d91
GK
56install-doc: install-doc-man install-doc-html
57
05f1685b 58clean:
d839253b 59 rm -rf manual.html-chunked
de8f9b2b 60 rm -f $(PROGS) $(DOCS) core *.xml
05f1685b 61
57bdf034 62spell-check:
8eb62770 63 aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
57bdf034 64
0e92d312
JF
65strip: all
66 strip $(PROGS)
67
ec4b9d91 68.PHONY: all all-debug doc doc-man doc-html install install-doc install-doc-man install-doc-html clean spell-check
a7bc4b14 69
ec4b9d91 70manual.html: manual.toc
9783cb12
JF
71manual.toc: manual.txt
72 sed -n '/^\[\[/,/\(---\|~~~\)/p' < $< | while read line; do \
73 case "$$line" in \
74 "-----"*) echo ". <<$$ref>>"; ref= ;; \
75 "~~~~~"*) echo "- <<$$ref>>"; ref= ;; \
76 "[["*"]]") ref="$$line" ;; \
77 *) ref="$$ref, $$line" ;; \
78 esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@
79
b801d8b2
JF
80tig: tig.c
81
b8ae9346 82README.html: README
511147de 83 asciidoc -b xhtml11 -d article -a readme $<
b8ae9346 84
de8f9b2b
JF
85%.pdf : %.xml
86 docbook2pdf $<
87
a7bc4b14 88%.1.html : %.1.txt
4c6fabc2 89 asciidoc -b xhtml11 -d manpage $<
a7bc4b14
JF
90
91%.1.xml : %.1.txt
bb0ab19f 92 asciidoc -b docbook -d manpage -aversion=$(VERSION) $<
a7bc4b14
JF
93
94%.1 : %.1.xml
738cb15a 95 xmlto -m manpage.xsl man $<
cb7f42cd
JF
96
97%.5.html : %.5.txt
98 asciidoc -b xhtml11 -d manpage $<
99
100%.5.xml : %.5.txt
bb0ab19f 101 asciidoc -b docbook -d manpage -aversion=$(VERSION) $<
cb7f42cd
JF
102
103%.5 : %.5.xml
738cb15a 104 xmlto -m manpage.xsl man $<
d839253b
JF
105
106%.html : %.txt
9783cb12 107 asciidoc -b xhtml11 -d article -n $<
d839253b
JF
108
109%.xml : %.txt
110 asciidoc -b docbook -d article $<
111
112%.html-chunked : %.xml
113 xmlto html -o $@ $<
604da3b7
JF
114
115# Maintainer stuff
116sync-docs:
117 cg switch release
118 -cg merge -n master
119 cg commit -m "Merge with master"
120 make doc
121 cg commit -m "Sync docs"
122 cg switch master