CodingGuidelines: spell Arithmetic Expansion with $(($var))
[git/kirr.git] / Documentation / Makefile
blobe117bc4315f6e288e89cf83fb80e876bee7a7dc2
1 MAN1_TXT= \
2 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
3 $(wildcard git-*.txt)) \
4 gitk.txt git.txt
5 MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \
6 gitrepository-layout.txt
7 MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \
8 gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \
9 gitdiffcore.txt gitrevisions.txt gitworkflows.txt
11 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
12 MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
13 MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
15 DOC_HTML=$(MAN_HTML)
17 ARTICLES = howto-index
18 ARTICLES += everyday
19 ARTICLES += git-tools
20 ARTICLES += git-bisect-lk2009
21 # with their own formatting rules.
22 SP_ARTICLES = howto/revert-branch-rebase howto/using-merge-subtree user-manual
23 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
24 SP_ARTICLES += $(API_DOCS)
25 SP_ARTICLES += technical/api-index
27 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
29 DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
30 DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
31 DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
33 prefix?=$(HOME)
34 bindir?=$(prefix)/bin
35 htmldir?=$(prefix)/share/doc/git-doc
36 pdfdir?=$(prefix)/share/doc/git-doc
37 mandir?=$(prefix)/share/man
38 man1dir=$(mandir)/man1
39 man5dir=$(mandir)/man5
40 man7dir=$(mandir)/man7
41 # DESTDIR=
43 ASCIIDOC=asciidoc
44 ASCIIDOC_EXTRA =
45 MANPAGE_XSL = manpage-normal.xsl
46 XMLTO_EXTRA =
47 INSTALL?=install
48 RM ?= rm -f
49 DOC_REF = origin/man
50 HTML_REF = origin/html
52 infodir?=$(prefix)/share/info
53 MAKEINFO=makeinfo
54 INSTALL_INFO=install-info
55 DOCBOOK2X_TEXI=docbook2x-texi
56 DBLATEX=dblatex
57 ifndef PERL_PATH
58 PERL_PATH = /usr/bin/perl
59 endif
61 -include ../config.mak.autogen
62 -include ../config.mak
65 # For asciidoc ...
66 # -7.1.2, no extra settings are needed.
67 # 8.0-, set ASCIIDOC8.
71 # For docbook-xsl ...
72 # -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
73 # 1.69.0, no extra settings are needed?
74 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
75 # 1.71.1, no extra settings are needed?
76 # 1.72.0, set DOCBOOK_XSL_172.
77 # 1.73.0-, set ASCIIDOC_NO_ROFF
81 # If you had been using DOCBOOK_XSL_172 in an attempt to get rid
82 # of 'the ".ft C" problem' in your generated manpages, and you
83 # instead ended up with weird characters around callouts, try
84 # using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
87 ifdef ASCIIDOC8
88 ASCIIDOC_EXTRA += -a asciidoc7compatible -a no-inline-literal
89 endif
90 ifdef DOCBOOK_XSL_172
91 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
92 MANPAGE_XSL = manpage-1.72.xsl
93 else
94 ifdef ASCIIDOC_NO_ROFF
95 # docbook-xsl after 1.72 needs the regular XSL, but will not
96 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
97 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
98 endif
99 endif
100 ifdef MAN_BOLD_LITERAL
101 XMLTO_EXTRA += -m manpage-bold-literal.xsl
102 endif
103 ifdef DOCBOOK_SUPPRESS_SP
104 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
105 endif
107 # Newer DocBook stylesheet emits warning cruft in the output when
108 # this is not set, and if set it shows an absolute link. Older
109 # stylesheets simply ignore this parameter.
111 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
112 # or similar.
113 ifndef MAN_BASE_URL
114 MAN_BASE_URL = file://$(htmldir)/
115 endif
116 XMLTO_EXTRA += -m manpage-base-url.xsl
118 # If your target system uses GNU groff, it may try to render
119 # apostrophes as a "pretty" apostrophe using unicode. This breaks
120 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
121 # apostrophes. Unfortunately does not work with non-GNU roff.
122 ifdef GNU_ROFF
123 XMLTO_EXTRA += -m manpage-quote-apos.xsl
124 endif
126 SHELL_PATH ?= $(SHELL)
127 # Shell quote;
128 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
131 # Please note that there is a minor bug in asciidoc.
132 # The version after 6.0.3 _will_ include the patch found here:
133 # http://marc.theaimsgroup.com/?l=git&m=111558757202243&w=2
135 # Until that version is released you may have to apply the patch
136 # yourself - yes, all 6 characters of it!
139 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
140 QUIET_SUBDIR1 =
142 ifneq ($(findstring $(MAKEFLAGS),w),w)
143 PRINT_DIR = --no-print-directory
144 else # "make -w"
145 NO_SUBDIR = :
146 endif
148 ifneq ($(findstring $(MAKEFLAGS),s),s)
149 ifndef V
150 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
151 QUIET_XMLTO = @echo ' ' XMLTO $@;
152 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
153 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
154 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
155 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
156 QUIET_GEN = @echo ' ' GEN $@;
157 QUIET_STDERR = 2> /dev/null
158 QUIET_SUBDIR0 = +@subdir=
159 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
160 $(MAKE) $(PRINT_DIR) -C $$subdir
161 export V
162 endif
163 endif
165 all: html man
167 html: $(DOC_HTML)
169 $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
171 man: man1 man5 man7
172 man1: $(DOC_MAN1)
173 man5: $(DOC_MAN5)
174 man7: $(DOC_MAN7)
176 info: git.info gitman.info
178 pdf: user-manual.pdf
180 install: install-man
182 install-man: man
183 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
184 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
185 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
186 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
187 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
188 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
190 install-info: info
191 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
192 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
193 if test -r $(DESTDIR)$(infodir)/dir; then \
194 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
195 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
196 else \
197 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
200 install-pdf: pdf
201 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
202 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
204 install-html: html
205 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
207 ../GIT-VERSION-FILE: FORCE
208 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
210 -include ../GIT-VERSION-FILE
213 # Determine "include::" file references in asciidoc files.
215 doc.dep : $(wildcard *.txt) build-docdep.perl
216 $(QUIET_GEN)$(RM) $@+ $@ && \
217 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
218 mv $@+ $@
220 -include doc.dep
222 cmds_txt = cmds-ancillaryinterrogators.txt \
223 cmds-ancillarymanipulators.txt \
224 cmds-mainporcelain.txt \
225 cmds-plumbinginterrogators.txt \
226 cmds-plumbingmanipulators.txt \
227 cmds-synchingrepositories.txt \
228 cmds-synchelpers.txt \
229 cmds-purehelpers.txt \
230 cmds-foreignscminterface.txt
232 $(cmds_txt): cmd-list.made
234 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
235 $(QUIET_GEN)$(RM) $@ && \
236 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
237 date >$@
239 clean:
240 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
241 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
242 $(RM) howto-index.txt howto/*.html doc.dep
243 $(RM) technical/api-*.html technical/api-index.txt
244 $(RM) $(cmds_txt) *.made
245 $(RM) manpage-base-url.xsl
247 $(MAN_HTML): %.html : %.txt
248 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
249 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
250 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
251 mv $@+ $@
253 manpage-base-url.xsl: manpage-base-url.xsl.in
254 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
256 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
257 $(QUIET_XMLTO)$(RM) $@ && \
258 xmlto -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
260 %.xml : %.txt
261 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
262 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
263 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
264 mv $@+ $@
266 user-manual.xml: user-manual.txt user-manual.conf
267 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
268 $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book -o $@+ $< && \
269 mv $@+ $@
271 technical/api-index.txt: technical/api-index-skel.txt \
272 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
273 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
275 $(patsubst %,%.html,$(API_DOCS) technical/api-index): %.html : %.txt
276 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
277 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
279 XSLT = docbook.xsl
280 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
282 user-manual.html: user-manual.xml $(XSLT)
283 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
284 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
285 mv $@+ $@
287 git.info: user-manual.texi
288 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
290 user-manual.texi: user-manual.xml
291 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
292 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
293 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
294 rm $@++ && \
295 mv $@+ $@
297 user-manual.pdf: user-manual.xml
298 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
299 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
300 mv $@+ $@
302 gitman.texi: $(MAN_XML) cat-texi.perl
303 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
304 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
305 --to-stdout $(xml) &&) true) > $@++ && \
306 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
307 rm $@++ && \
308 mv $@+ $@
310 gitman.info: gitman.texi
311 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
313 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
314 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
315 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
316 mv $@+ $@
318 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
319 $(QUIET_GEN)$(RM) $@+ $@ && \
320 '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
321 mv $@+ $@
323 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
324 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt
326 WEBDOC_DEST = /pub/software/scm/git/docs
328 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
329 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
330 sed -e '1,/^$$/d' $< | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - >$@+ && \
331 mv $@+ $@
333 install-webdoc : html
334 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
336 quick-install: quick-install-man
338 quick-install-man:
339 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
341 quick-install-html:
342 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
344 .PHONY: FORCE