docs: handle `git describe` failing
[guilt.git] / Documentation / Makefile
blob9fc11652be39c9ee9ae72d2f2df0c71f82b5b502
1 MAN1_TXT= $(wildcard guilt-*.txt)
2 MAN7_TXT=guilt.txt
4 DOC_HTML=$(patsubst %.txt,%.html,$(MAN1_TXT) $(MAN7_TXT))
6 DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
7 DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
9 USAGE=$(patsubst %.txt,usage-%.txt,$(MAN1_TXT))
10 VERSION=$(shell git describe 2> /dev/null || sed -n -e '/^GUILT_VERSION=/ { s/^GUILT_VERSION="/v/; s/"//; p; q; }' ../guilt)
12 prefix?=$(PREFIX)
13 bindir?=$(prefix)/bin
14 htmldir?=$(prefix)/html
15 mandir?=$(prefix)/man
16 man1dir=$(mandir)/man1
17 man7dir=$(mandir)/man7
18 # DESTDIR=
20 ASCIIDOC=asciidoc
21 ASCIIDOC_EXTRA =
22 INSTALL?=install
23 DOC_REF = origin/man
25 all: html man
27 html: $(DOC_HTML)
29 $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN7): asciidoc.conf
31 man: man1 man7
32 man1: $(DOC_MAN1)
33 man7: $(DOC_MAN7)
35 install: man
36 $(INSTALL) -d -m755 $(DESTDIR)$(man1dir) $(DESTDIR)$(man7dir)
37 $(INSTALL) -m644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
38 $(INSTALL) -m644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
40 install-html: html
41 $(INSTALL) -m644 $(DOC_HTML) $(DESTDIR)$(htmldir)
44 # Determine "include::" file references in asciidoc files.
46 doc.dep : $(wildcard *.txt) build-docdep.perl
47 rm -f $@+ $@
48 perl ./build-docdep.perl >$@+
49 mv $@+ $@
51 -include doc.dep
53 version.txt:
54 echo "(Generated for Guilt $(VERSION))" > version.txt
56 cmds.txt: cmd-list.sh $(MAN1_TXT)
57 sh ./cmd-list.sh
59 guilt.7 guilt.html: guilt.txt footer.txt version.txt
61 clean:
62 rm -f *.xml *.html *.1 *.7 doc.dep
63 rm -f cmds.txt
64 rm -f usage-*.txt
65 rm -f version.txt
67 usage-%.txt: $(MAN1_TXT) usage.sh
68 sh ./usage.sh
70 %.html : %.txt footer.txt version.txt
71 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf $(ASCIIDOC_EXTRA) $<
73 %.1 %.7 : %.xml
74 xmlto -m callouts.xsl man $<
76 %.xml : %.txt footer.txt version.txt
77 $(ASCIIDOC) -b docbook -a version=$(VERSION) -d manpage -f asciidoc.conf $<