| 1 | prefix = $(HOME) |
| 2 | bindir= $(prefix)/bin |
| 3 | mandir = $(prefix)/man |
| 4 | docdir = $(prefix)/share/doc |
| 5 | # DESTDIR= |
| 6 | |
| 7 | LDLIBS = -lcurses |
| 8 | CFLAGS = -Wall -O2 |
| 9 | DFLAGS = -g -DDEBUG -Werror |
| 10 | PROGS = tig |
| 11 | DOCS = tig.1.html tig.1 tigrc.5.html tigrc.5 \ |
| 12 | manual.toc manual.html manual.html-chunked manual.pdf \ |
| 13 | README.html |
| 14 | |
| 15 | ifneq (,$(wildcard .git)) |
| 16 | VERSION = $(shell git-describe) |
| 17 | WTDIRTY = $(shell git-diff-index --name-only HEAD 2>/dev/null) |
| 18 | CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"' |
| 19 | endif |
| 20 | |
| 21 | all: $(PROGS) |
| 22 | all-debug: $(PROGS) |
| 23 | all-debug: CFLAGS += $(DFLAGS) |
| 24 | doc: $(DOCS) |
| 25 | |
| 26 | install: all |
| 27 | mkdir -p $(DESTDIR)$(bindir) && \ |
| 28 | for prog in $(PROGS); do \ |
| 29 | install $$prog $(DESTDIR)$(bindir); \ |
| 30 | done |
| 31 | |
| 32 | install-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 | |
| 44 | clean: |
| 45 | rm -rf manual.html-chunked |
| 46 | rm -f $(PROGS) $(DOCS) core *.xml |
| 47 | |
| 48 | spell-check: |
| 49 | aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt |
| 50 | |
| 51 | strip: all |
| 52 | strip $(PROGS) |
| 53 | |
| 54 | .PHONY: all all-debug doc install install-doc clean spell-check |
| 55 | |
| 56 | manual.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 | |
| 65 | tig: tig.c |
| 66 | |
| 67 | README.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 |
| 101 | sync-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 |