| 1 | PREFIX = $(HOME) |
| 2 | LDLIBS = -lcurses |
| 3 | CFLAGS = -Wall -O2 |
| 4 | DFLAGS = -g -DDEBUG -Werror |
| 5 | PROGS = tig |
| 6 | DOCS = tig.1.txt tig.1.html tig.1 README.html |
| 7 | |
| 8 | ifneq (,$(wildcard .git)) |
| 9 | VERSION = $(shell git-describe) |
| 10 | WTDIRTY = $(shell git-diff-index --name-only HEAD 2>/dev/null) |
| 11 | CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"' |
| 12 | endif |
| 13 | |
| 14 | all: $(PROGS) |
| 15 | all-debug: $(PROGS) |
| 16 | all-debug: CFLAGS += $(DFLAGS) |
| 17 | docs: $(DOCS) |
| 18 | |
| 19 | install: all |
| 20 | for prog in $(PROGS); do \ |
| 21 | install $$prog $(PREFIX)/bin; \ |
| 22 | done |
| 23 | |
| 24 | install-docs: docs |
| 25 | for doc in $(DOCS); do \ |
| 26 | case "$$doc" in \ |
| 27 | *.1) install $$doc $(PREFIX)/man/man1 ;; \ |
| 28 | esac \ |
| 29 | done |
| 30 | |
| 31 | clean: |
| 32 | rm -f $(PROGS) $(DOCS) core |
| 33 | |
| 34 | spell-check: |
| 35 | aspell --lang=en --check tig.1.txt |
| 36 | |
| 37 | .PHONY: all docs install clean |
| 38 | |
| 39 | tig: tig.c |
| 40 | |
| 41 | tig.1.txt: tig.c |
| 42 | sed -n '/\/\*\*/,/\*\*\//p' < $< | \ |
| 43 | sed 's/.*\*\*\///' | \ |
| 44 | sed '/^[^*]*\*\*/d' | \ |
| 45 | sed 's/\*\///;s/^[^*]*\* *//' > $@ |
| 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 $< |