Add ToC to the tig manual
[tig] / Makefile
... / ...
CommitLineData
1prefix = $(HOME)
2bindir= $(prefix)/bin
3mandir = $(prefix)/man
4# DESTDIR=
5
6LDLIBS = -lcurses
7CFLAGS = -Wall -O2
8DFLAGS = -g -DDEBUG -Werror
9PROGS = tig
10DOCS = tig.1.html tig.1 tigrc.5.html tigrc.5 \
11 manual.toc manual.html manual.html-chunked README.html \
12
13ifneq (,$(wildcard .git))
14VERSION = $(shell git-describe)
15WTDIRTY = $(shell git-diff-index --name-only HEAD 2>/dev/null)
16CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"'
17endif
18
19all: $(PROGS)
20all-debug: $(PROGS)
21all-debug: CFLAGS += $(DFLAGS)
22doc: $(DOCS)
23
24install: all
25 for prog in $(PROGS); do \
26 install $$prog $(DESTDIR)$(bindir); \
27 done
28
29install-doc: doc
30 mkdir -p $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(mandir)/man5
31 for doc in $(DOCS); do \
32 case "$$doc" in \
33 *.1) install $$doc $(DESTDIR)$(mandir)/man1 ;; \
34 *.5) install $$doc $(DESTDIR)$(mandir)/man5 ;; \
35 esac \
36 done
37
38clean:
39 rm -rf manual.html-chunked
40 rm -f $(PROGS) $(DOCS) core
41
42spell-check:
43 aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
44
45strip: all
46 strip $(PROGS)
47
48.PHONY: all all-debug doc install install-doc clean spell-check
49
50manual.toc: manual.txt
51 sed -n '/^\[\[/,/\(---\|~~~\)/p' < $< | while read line; do \
52 case "$$line" in \
53 "-----"*) echo ". <<$$ref>>"; ref= ;; \
54 "~~~~~"*) echo "- <<$$ref>>"; ref= ;; \
55 "[["*"]]") ref="$$line" ;; \
56 *) ref="$$ref, $$line" ;; \
57 esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@
58
59tig: tig.c
60
61README.html: README
62 asciidoc -b xhtml11 -d article -a readme $<
63
64%.1.html : %.1.txt
65 asciidoc -b xhtml11 -d manpage $<
66
67%.1.xml : %.1.txt
68 asciidoc -b docbook -d manpage $<
69
70%.1 : %.1.xml
71 xmlto man $<
72
73%.5.html : %.5.txt
74 asciidoc -b xhtml11 -d manpage $<
75
76%.5.xml : %.5.txt
77 asciidoc -b docbook -d manpage $<
78
79%.5 : %.5.xml
80 xmlto man $<
81
82%.html : %.txt
83 asciidoc -b xhtml11 -d article -n $<
84
85%.xml : %.txt
86 asciidoc -b docbook -d article $<
87
88%.html-chunked : %.xml
89 xmlto html -o $@ $<