Make tig handle GIT_DIR better
[tig] / Makefile
CommitLineData
5f7b975a
JH
1prefix = $(HOME)
2bindir= $(prefix)/bin
3mandir = $(prefix)/man
bb8afc29 4docdir = $(prefix)/share/doc
5f7b975a
JH
5# DESTDIR=
6
c9a2f784 7LDLIBS = -lcurses
900666fc 8CFLAGS = -Wall -O2
19f862bd 9DFLAGS = -g -DDEBUG -Werror
b801d8b2 10PROGS = tig
8eb62770 11DOCS = tig.1.html tig.1 tigrc.5.html tigrc.5 \
de8f9b2b
JF
12 manual.toc manual.html manual.html-chunked manual.pdf \
13 README.html
e2beda18
JF
14
15ifneq (,$(wildcard .git))
9074d9b6
JF
16VERSION = $(shell git-describe)
17WTDIRTY = $(shell git-diff-index --name-only HEAD 2>/dev/null)
18CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"'
e2beda18 19endif
800a900c 20
a7bc4b14 21all: $(PROGS)
82e78006
JF
22all-debug: $(PROGS)
23all-debug: CFLAGS += $(DFLAGS)
c92615b1 24doc: $(DOCS)
800a900c 25
05f1685b 26install: all
d441a715 27 mkdir -p $(DESTDIR)$(bindir) && \
a7bc4b14 28 for prog in $(PROGS); do \
5f7b975a 29 install $$prog $(DESTDIR)$(bindir); \
4c6fabc2
JF
30 done
31
c92615b1 32install-doc: doc
bb8afc29
JF
33 mkdir -p $(DESTDIR)$(mandir)/man1 \
34 $(DESTDIR)$(mandir)/man5 \
35 $(DESTDIR)$(docdir)/tig
4c6fabc2
JF
36 for doc in $(DOCS); do \
37 case "$$doc" in \
5f7b975a
JH
38 *.1) install $$doc $(DESTDIR)$(mandir)/man1 ;; \
39 *.5) install $$doc $(DESTDIR)$(mandir)/man5 ;; \
bb8afc29 40 *.html) install $$doc $(DESTDIR)$(docdir)/tig ;; \
4c6fabc2 41 esac \
a7bc4b14 42 done
05f1685b
JF
43
44clean:
d839253b 45 rm -rf manual.html-chunked
de8f9b2b 46 rm -f $(PROGS) $(DOCS) core *.xml
05f1685b 47
57bdf034 48spell-check:
8eb62770 49 aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
57bdf034 50
0e92d312
JF
51strip: all
52 strip $(PROGS)
53
c92615b1 54.PHONY: all all-debug doc install install-doc clean spell-check
a7bc4b14 55
9783cb12
JF
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
b801d8b2
JF
65tig: tig.c
66
b8ae9346 67README.html: README
511147de 68 asciidoc -b xhtml11 -d article -a readme $<
b8ae9346 69
de8f9b2b
JF
70%.pdf : %.xml
71 docbook2pdf $<
72
a7bc4b14 73%.1.html : %.1.txt
4c6fabc2 74 asciidoc -b xhtml11 -d manpage $<
a7bc4b14
JF
75
76%.1.xml : %.1.txt
4c6fabc2 77 asciidoc -b docbook -d manpage $<
a7bc4b14
JF
78
79%.1 : %.1.xml
80 xmlto man $<
cb7f42cd
JF
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 $<
d839253b
JF
90
91%.html : %.txt
9783cb12 92 asciidoc -b xhtml11 -d article -n $<
d839253b
JF
93
94%.xml : %.txt
95 asciidoc -b docbook -d article $<
96
97%.html-chunked : %.xml
98 xmlto html -o $@ $<
604da3b7
JF
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