Code

Add ToC to the tig manual
[tig.git] / Makefile
1 prefix  = $(HOME)
2 bindir= $(prefix)/bin
3 mandir = $(prefix)/man
4 # DESTDIR=
6 LDLIBS  = -lcurses
7 CFLAGS  = -Wall -O2
8 DFLAGS  = -g -DDEBUG -Werror
9 PROGS   = tig
10 DOCS    = tig.1.html tig.1 tigrc.5.html tigrc.5 \
11           manual.toc manual.html manual.html-chunked README.html \
13 ifneq (,$(wildcard .git))
14 VERSION = $(shell git-describe)
15 WTDIRTY = $(shell git-diff-index --name-only HEAD 2>/dev/null)
16 CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"'
17 endif
19 all: $(PROGS)
20 all-debug: $(PROGS)
21 all-debug: CFLAGS += $(DFLAGS)
22 doc: $(DOCS)
24 install: all
25         for prog in $(PROGS); do \
26                 install $$prog $(DESTDIR)$(bindir); \
27         done
29 install-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
38 clean:
39         rm -rf manual.html-chunked
40         rm -f $(PROGS) $(DOCS) core
42 spell-check:
43         aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
45 strip: all
46         strip $(PROGS)
48 .PHONY: all all-debug doc install install-doc clean spell-check
50 manual.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/' > $@
59 tig: tig.c
61 README.html: README
62         asciidoc -b xhtml11 -d article -a readme $<
64 %.1.html : %.1.txt
65         asciidoc -b xhtml11 -d manpage $<
67 %.1.xml : %.1.txt
68         asciidoc -b docbook -d manpage $<
70 %.1 : %.1.xml
71         xmlto man $<
73 %.5.html : %.5.txt
74         asciidoc -b xhtml11 -d manpage $<
76 %.5.xml : %.5.txt
77         asciidoc -b docbook -d manpage $<
79 %.5 : %.5.xml
80         xmlto man $<
82 %.html : %.txt
83         asciidoc -b xhtml11 -d article -n $<
85 %.xml : %.txt
86         asciidoc -b docbook -d article $<
88 %.html-chunked : %.xml
89         xmlto html -o $@ $<