Makefile: make customization of installation locations easier
[tig] / Makefile
1 prefix = $(HOME)
2 bindir= $(prefix)/bin
3 mandir = $(prefix)/man
4 # DESTDIR=
5
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.html manual.html-chunked README.html
12
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
18
19 all: $(PROGS)
20 all-debug: $(PROGS)
21 all-debug: CFLAGS += $(DFLAGS)
22 doc: $(DOCS)
23
24 install: all
25 for prog in $(PROGS); do \
26 install $$prog $(DESTDIR)$(bindir); \
27 done
28
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
37
38 clean:
39 rm -rf manual.html-chunked
40 rm -f $(PROGS) $(DOCS) core
41
42 spell-check:
43 aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
44
45 strip: all
46 strip $(PROGS)
47
48 .PHONY: all all-debug doc install install-doc clean spell-check
49
50 tig: tig.c
51
52 README.html: README
53 asciidoc -b xhtml11 -d article -f web.conf $<
54
55 %.1.html : %.1.txt
56 asciidoc -b xhtml11 -d manpage $<
57
58 %.1.xml : %.1.txt
59 asciidoc -b docbook -d manpage $<
60
61 %.1 : %.1.xml
62 xmlto man $<
63
64 %.5.html : %.5.txt
65 asciidoc -b xhtml11 -d manpage $<
66
67 %.5.xml : %.5.txt
68 asciidoc -b docbook -d manpage $<
69
70 %.5 : %.5.xml
71 xmlto man $<
72
73 %.html : %.txt
74 asciidoc -b xhtml11 -d article $<
75
76 %.xml : %.txt
77 asciidoc -b docbook -d article $<
78
79 %.html-chunked : %.xml
80 xmlto html -o $@ $<