Only set VERSION to git-describe if .git is available
[tig] / Makefile
1 PREFIX  = $(HOME)
2 LDFLAGS = -lcurses
3 CFLAGS  = -Wall
4 DFLAGS  = -g -DDEBUG
5 PROGS   = tig
6 DOCS    = tig.1.txt tig.1.html tig.1 README.html
7
8 ifneq (,$(wildcard .git))
9 CFLAGS += '-DVERSION="$(shell git-describe)"'
10 endif
11
12 all: $(PROGS)
13 all-debug: $(PROGS)
14 all-debug: CFLAGS += $(DFLAGS)
15 docs: $(DOCS)
16
17 install: all
18         for prog in $(PROGS); do \
19                 install $$prog $(PREFIX)/bin; \
20         done
21
22 install-docs: docs
23         for doc in $(DOCS); do \
24                 case "$$doc" in \
25                 *.1) install $$doc $(PREFIX)/man/man1 ;; \
26                 esac \
27         done
28
29 clean:
30         rm -f $(PROGS) $(DOCS) core
31
32 spell-check:
33         aspell --lang=en --check tig.1.txt
34
35 .PHONY: all docs install clean
36
37 tig: tig.c
38
39 tig.1.txt: tig.c
40         sed -n '/\/\*\*/,/\*\*\//p' < $< | \
41         sed 's/.*\*\*\///' | \
42         sed '/^[^*]*\*\*/d' | \
43         sed 's/\*\///;s/^[^*]*\* *//' > $@
44
45 README.html: README
46         asciidoc -b xhtml11 -d article -f web.conf $<
47
48 %.1.html : %.1.txt
49         asciidoc -b xhtml11 -d manpage $<
50
51 %.1.xml : %.1.txt
52         asciidoc -b docbook -d manpage $<
53
54 %.1 : %.1.xml
55         xmlto man $<