| 1 | PREFIX = $(HOME) |
| 2 | LDLIBS = -lcurses |
| 3 | CFLAGS = -Wall -O2 |
| 4 | DFLAGS = -g -DDEBUG -Werror |
| 5 | PROGS = tig |
| 6 | DOCS = tig.1.html tig.1 tigrc.5.html tigrc.5 \ |
| 7 | manual.html manual.html-chunked README.html |
| 8 | |
| 9 | ifneq (,$(wildcard .git)) |
| 10 | VERSION = $(shell git-describe) |
| 11 | WTDIRTY = $(shell git-diff-index --name-only HEAD 2>/dev/null) |
| 12 | CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"' |
| 13 | endif |
| 14 | |
| 15 | all: $(PROGS) |
| 16 | all-debug: $(PROGS) |
| 17 | all-debug: CFLAGS += $(DFLAGS) |
| 18 | doc: $(DOCS) |
| 19 | |
| 20 | install: all |
| 21 | for prog in $(PROGS); do \ |
| 22 | install $$prog $(PREFIX)/bin; \ |
| 23 | done |
| 24 | |
| 25 | install-doc: doc |
| 26 | for doc in $(DOCS); do \ |
| 27 | case "$$doc" in \ |
| 28 | *.1) install $$doc $(PREFIX)/man/man1 ;; \ |
| 29 | *.5) install $$doc $(PREFIX)/man/man5 ;; \ |
| 30 | esac \ |
| 31 | done |
| 32 | |
| 33 | clean: |
| 34 | rm -rf manual.html-chunked |
| 35 | rm -f $(PROGS) $(DOCS) core |
| 36 | |
| 37 | spell-check: |
| 38 | aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt |
| 39 | |
| 40 | strip: all |
| 41 | strip $(PROGS) |
| 42 | |
| 43 | .PHONY: all all-debug doc install install-doc clean spell-check |
| 44 | |
| 45 | tig: tig.c |
| 46 | |
| 47 | README.html: README |
| 48 | asciidoc -b xhtml11 -d article -f web.conf $< |
| 49 | |
| 50 | %.1.html : %.1.txt |
| 51 | asciidoc -b xhtml11 -d manpage $< |
| 52 | |
| 53 | %.1.xml : %.1.txt |
| 54 | asciidoc -b docbook -d manpage $< |
| 55 | |
| 56 | %.1 : %.1.xml |
| 57 | xmlto man $< |
| 58 | |
| 59 | %.5.html : %.5.txt |
| 60 | asciidoc -b xhtml11 -d manpage $< |
| 61 | |
| 62 | %.5.xml : %.5.txt |
| 63 | asciidoc -b docbook -d manpage $< |
| 64 | |
| 65 | %.5 : %.5.xml |
| 66 | xmlto man $< |
| 67 | |
| 68 | %.html : %.txt |
| 69 | asciidoc -b xhtml11 -d article $< |
| 70 | |
| 71 | %.xml : %.txt |
| 72 | asciidoc -b docbook -d article $< |
| 73 | |
| 74 | %.html-chunked : %.xml |
| 75 | xmlto html -o $@ $< |