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