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