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