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