Documentation/Makefile - honor $DESTDIR for quick-install target
[git/git.git] / Documentation / Makefile
1 MAN1_TXT= \
2 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
3 $(wildcard git-*.txt)) \
4 gitk.txt
5 MAN5_TXT=gitattributes.txt gitignore.txt gitcli.txt gitmodules.txt
6 MAN7_TXT=git.txt
7
8 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
9 MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
10 MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
11
12 DOC_HTML=$(MAN_HTML)
13
14 ARTICLES = tutorial
15 ARTICLES += tutorial-2
16 ARTICLES += core-tutorial
17 ARTICLES += cvs-migration
18 ARTICLES += diffcore
19 ARTICLES += howto-index
20 ARTICLES += repository-layout
21 ARTICLES += hooks
22 ARTICLES += everyday
23 ARTICLES += git-tools
24 ARTICLES += glossary
25 # with their own formatting rules.
26 SP_ARTICLES = howto/revert-branch-rebase user-manual
27 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
28 SP_ARTICLES += $(API_DOCS)
29 SP_ARTICLES += technical/api-index
30
31 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
32
33 DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
34 DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
35 DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
36
37 prefix?=$(HOME)
38 bindir?=$(prefix)/bin
39 htmldir?=$(prefix)/share/doc/git-doc
40 mandir?=$(prefix)/share/man
41 man1dir=$(mandir)/man1
42 man5dir=$(mandir)/man5
43 man7dir=$(mandir)/man7
44 # DESTDIR=
45
46 ASCIIDOC=asciidoc
47 ASCIIDOC_EXTRA =
48 INSTALL?=install
49 RM ?= rm -f
50 DOC_REF = origin/man
51
52 infodir?=$(prefix)/share/info
53 MAKEINFO=makeinfo
54 INSTALL_INFO=install-info
55 DOCBOOK2X_TEXI=docbook2x-texi
56 ifndef PERL_PATH
57 PERL_PATH = /usr/bin/perl
58 endif
59
60 -include ../config.mak.autogen
61 -include ../config.mak
62
63 ifdef ASCIIDOC8
64 ASCIIDOC_EXTRA += -a asciidoc7compatible
65 endif
66 ifdef DOCBOOK_XSL_172
67 ASCIIDOC_EXTRA += -a docbook-xsl-172
68 endif
69
70 #
71 # Please note that there is a minor bug in asciidoc.
72 # The version after 6.0.3 _will_ include the patch found here:
73 # http://marc.theaimsgroup.com/?l=git&m=111558757202243&w=2
74 #
75 # Until that version is released you may have to apply the patch
76 # yourself - yes, all 6 characters of it!
77 #
78
79 all: html man
80
81 html: $(DOC_HTML)
82
83 $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
84
85 man: man1 man5 man7
86 man1: $(DOC_MAN1)
87 man5: $(DOC_MAN5)
88 man7: $(DOC_MAN7)
89
90 info: git.info gitman.info
91
92 install: man
93 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
94 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
95 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
96 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
97 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
98 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
99
100 install-info: info
101 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
102 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
103 if test -r $(DESTDIR)$(infodir)/dir; then \
104 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
105 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
106 else \
107 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
108 fi
109
110 install-html: html
111 sh ./install-webdoc.sh $(DESTDIR)$(htmldir)
112
113 ../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
114 $(MAKE) -C ../ GIT-VERSION-FILE
115
116 -include ../GIT-VERSION-FILE
117
118 #
119 # Determine "include::" file references in asciidoc files.
120 #
121 doc.dep : $(wildcard *.txt) build-docdep.perl
122 $(RM) $@+ $@
123 $(PERL_PATH) ./build-docdep.perl >$@+
124 mv $@+ $@
125
126 -include doc.dep
127
128 cmds_txt = cmds-ancillaryinterrogators.txt \
129 cmds-ancillarymanipulators.txt \
130 cmds-mainporcelain.txt \
131 cmds-plumbinginterrogators.txt \
132 cmds-plumbingmanipulators.txt \
133 cmds-synchingrepositories.txt \
134 cmds-synchelpers.txt \
135 cmds-purehelpers.txt \
136 cmds-foreignscminterface.txt
137
138 $(cmds_txt): cmd-list.made
139
140 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
141 $(RM) $@
142 $(PERL_PATH) ./cmd-list.perl ../command-list.txt
143 date >$@
144
145 git.7 git.html: git.txt
146
147 clean:
148 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7 *.texi *.texi+ git.info
149 $(RM) howto-index.txt howto/*.html doc.dep
150 $(RM) technical/api-*.html technical/api-index.txt
151 $(RM) $(cmds_txt) *.made
152
153 $(MAN_HTML): %.html : %.txt
154 $(RM) $@+ $@
155 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
156 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $<
157 mv $@+ $@
158
159 %.1 %.5 %.7 : %.xml
160 $(RM) $@
161 xmlto -m callouts.xsl man $<
162
163 %.xml : %.txt
164 $(RM) $@+ $@
165 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
166 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $<
167 mv $@+ $@
168
169 user-manual.xml: user-manual.txt user-manual.conf
170 $(ASCIIDOC) -b docbook -d book $<
171
172 technical/api-index.txt: technical/api-index-skel.txt \
173 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
174 cd technical && sh ./api-index.sh
175
176 $(patsubst %,%.html,$(API_DOCS) technical/api-index): %.html : %.txt
177 $(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
178 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
179
180 XSLT = docbook.xsl
181 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
182
183 user-manual.html: user-manual.xml
184 xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
185
186 git.info: user-manual.texi
187 $(MAKEINFO) --no-split -o $@ user-manual.texi
188
189 user-manual.texi: user-manual.xml
190 $(RM) $@+ $@
191 $(DOCBOOK2X_TEXI) user-manual.xml --to-stdout | $(PERL_PATH) fix-texi.perl >$@+
192 mv $@+ $@
193
194 gitman.texi: $(MAN_XML) cat-texi.perl
195 $(RM) $@+ $@
196 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --to-stdout $(xml);)) | \
197 $(PERL_PATH) cat-texi.perl $@ >$@+
198 mv $@+ $@
199
200 gitman.info: gitman.texi
201 $(MAKEINFO) --no-split $*.texi
202
203 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
204 $(RM) $@+ $@
205 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+
206 mv $@+ $@
207
208 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
209 $(RM) $@+ $@
210 sh ./howto-index.sh $(wildcard howto/*.txt) >$@+
211 mv $@+ $@
212
213 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
214 $(ASCIIDOC) -b xhtml11 $*.txt
215
216 WEBDOC_DEST = /pub/software/scm/git/docs
217
218 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
219 $(RM) $@+ $@
220 sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+
221 mv $@+ $@
222
223 install-webdoc : html
224 sh ./install-webdoc.sh $(WEBDOC_DEST)
225
226 quick-install:
227 sh ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
228
229 .PHONY: .FORCE-GIT-VERSION-FILE