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