| 1 | COMMANDS = $(shell ../stg-build --commands) |
| 2 | COMMANDS_TXT = $(patsubst %,stg-%.txt,$(COMMANDS)) |
| 3 | |
| 4 | MAN1_TXT=$(wildcard stg*.txt) $(COMMANDS_TXT) |
| 5 | |
| 6 | DOC_HTML=$(patsubst %.txt,%.html,$(MAN1_TXT)) |
| 7 | |
| 8 | ARTICLES = |
| 9 | # with their own formatting rules. |
| 10 | SP_ARTICLES = tutorial |
| 11 | |
| 12 | DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES)) |
| 13 | DOC_PDF += $(patsubst %,%.pdf,$(ARTICLES) $(SP_ARTICLES)) |
| 14 | |
| 15 | DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT)) |
| 16 | |
| 17 | prefix?=$(HOME) |
| 18 | htmldir?=$(prefix)/share/doc/stgit |
| 19 | mandir?=$(prefix)/share/man |
| 20 | man1dir=$(mandir)/man1 |
| 21 | # DESTDIR= |
| 22 | |
| 23 | ASCIIDOC=asciidoc --unsafe |
| 24 | ASCIIDOC_EXTRA = |
| 25 | INSTALL?=install |
| 26 | |
| 27 | # |
| 28 | # Please note that there is a minor bug in asciidoc. |
| 29 | # The version after 6.0.3 _will_ include the patch found here: |
| 30 | # http://marc.theaimsgroup.com/?l=git&m=111558757202243&w=2 |
| 31 | # |
| 32 | # Until that version is released you may have to apply the patch |
| 33 | # yourself - yes, all 6 characters of it! |
| 34 | # |
| 35 | |
| 36 | all: html man |
| 37 | |
| 38 | html: $(DOC_HTML) |
| 39 | pdf: $(DOC_PDF) |
| 40 | |
| 41 | $(DOC_HTML) $(DOC_MAN1): asciidoc.conf |
| 42 | |
| 43 | man: man1 |
| 44 | man1: $(DOC_MAN1) |
| 45 | install: man |
| 46 | $(INSTALL) -d -m755 $(DESTDIR)$(man1dir) |
| 47 | $(INSTALL) -m644 $(DOC_MAN1) $(DESTDIR)$(man1dir) |
| 48 | |
| 49 | install-html: html |
| 50 | $(INSTALL) -d -m755 $(DESTDIR)$(htmldir) |
| 51 | $(INSTALL) -m644 $(DOC_HTML) $(DESTDIR)$(htmldir) |
| 52 | # |
| 53 | # Determine "include::" file references in asciidoc files. |
| 54 | # |
| 55 | doc.dep : $(wildcard *.txt) build-docdep.perl |
| 56 | rm -f $@+ $@ |
| 57 | perl ./build-docdep.perl >$@+ |
| 58 | mv $@+ $@ |
| 59 | |
| 60 | -include doc.dep |
| 61 | |
| 62 | clean: |
| 63 | rm -f *.xml *.html *.pdf *.1 doc.dep $(COMMANDS_TXT) |
| 64 | |
| 65 | $(COMMANDS_TXT): $(shell find .. -name '*.py') |
| 66 | ../stg-build --asciidoc $(basename $(subst stg-,,$@)) > $@ |
| 67 | |
| 68 | %.html : %.txt |
| 69 | $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf $(ASCIIDOC_EXTRA) $< |
| 70 | |
| 71 | %.1 : %.xml |
| 72 | xmlto -m callouts.xsl man $< |
| 73 | |
| 74 | %.xml : %.txt |
| 75 | $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf $< |
| 76 | |
| 77 | %.pdf: %.xml |
| 78 | xmlto pdf $< |
| 79 | |
| 80 | # special formatting rules |
| 81 | tutorial.html : %.html : %.txt |
| 82 | $(ASCIIDOC) -b xhtml11 -d article -f tutorial.conf $(ASCIIDOC_EXTRA) $< |
| 83 | tutorial.xml : %.xml : %.txt |
| 84 | $(ASCIIDOC) -b docbook -d article -f tutorial.conf $< |