Merge branch 'ep/avoid-test-a-o'
[git/git-svn.git] / Documentation / Makefile
blobcea0e7ae3db37dcd366e094abdd2a2f32514a247
1 # Guard against environment variables
2 MAN1_TXT =
3 MAN5_TXT =
4 MAN7_TXT =
5 TECH_DOCS =
6 ARTICLES =
7 SP_ARTICLES =
9 MAN1_TXT += $(filter-out \
10 $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
11 $(wildcard git-*.txt))
12 MAN1_TXT += git.txt
13 MAN1_TXT += gitk.txt
14 MAN1_TXT += gitremote-helpers.txt
15 MAN1_TXT += gitweb.txt
17 MAN5_TXT += gitattributes.txt
18 MAN5_TXT += githooks.txt
19 MAN5_TXT += gitignore.txt
20 MAN5_TXT += gitmodules.txt
21 MAN5_TXT += gitrepository-layout.txt
22 MAN5_TXT += gitweb.conf.txt
24 MAN7_TXT += gitcli.txt
25 MAN7_TXT += gitcore-tutorial.txt
26 MAN7_TXT += gitcredentials.txt
27 MAN7_TXT += gitcvs-migration.txt
28 MAN7_TXT += gitdiffcore.txt
29 MAN7_TXT += gitglossary.txt
30 MAN7_TXT += gitnamespaces.txt
31 MAN7_TXT += gitrevisions.txt
32 MAN7_TXT += gittutorial-2.txt
33 MAN7_TXT += gittutorial.txt
34 MAN7_TXT += gitworkflows.txt
36 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
37 MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
38 MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
40 OBSOLETE_HTML = git-remote-helpers.html
41 DOC_HTML = $(MAN_HTML) $(OBSOLETE_HTML)
43 ARTICLES += howto-index
44 ARTICLES += everyday
45 ARTICLES += git-tools
46 ARTICLES += git-bisect-lk2009
47 # with their own formatting rules.
48 SP_ARTICLES += user-manual
49 SP_ARTICLES += howto/new-command
50 SP_ARTICLES += howto/revert-branch-rebase
51 SP_ARTICLES += howto/using-merge-subtree
52 SP_ARTICLES += howto/using-signed-tag-in-pull-request
53 SP_ARTICLES += howto/use-git-daemon
54 SP_ARTICLES += howto/update-hook-example
55 SP_ARTICLES += howto/setup-git-server-over-http
56 SP_ARTICLES += howto/separating-topic-branches
57 SP_ARTICLES += howto/revert-a-faulty-merge
58 SP_ARTICLES += howto/recover-corrupted-blob-object
59 SP_ARTICLES += howto/recover-corrupted-object-harder
60 SP_ARTICLES += howto/rebuild-from-update-hook
61 SP_ARTICLES += howto/rebase-from-internal-branch
62 SP_ARTICLES += howto/keep-canonical-history-correct
63 SP_ARTICLES += howto/maintain-git
64 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
65 SP_ARTICLES += $(API_DOCS)
67 TECH_DOCS += technical/http-protocol
68 TECH_DOCS += technical/index-format
69 TECH_DOCS += technical/pack-format
70 TECH_DOCS += technical/pack-heuristics
71 TECH_DOCS += technical/pack-protocol
72 TECH_DOCS += technical/protocol-capabilities
73 TECH_DOCS += technical/protocol-common
74 TECH_DOCS += technical/racy-git
75 TECH_DOCS += technical/send-pack-pipeline
76 TECH_DOCS += technical/shallow
77 TECH_DOCS += technical/trivial-merge
78 SP_ARTICLES += $(TECH_DOCS)
79 SP_ARTICLES += technical/api-index
81 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
83 DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
84 DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
85 DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
87 prefix ?= $(HOME)
88 bindir ?= $(prefix)/bin
89 htmldir ?= $(prefix)/share/doc/git-doc
90 infodir ?= $(prefix)/share/info
91 pdfdir ?= $(prefix)/share/doc/git-doc
92 mandir ?= $(prefix)/share/man
93 man1dir = $(mandir)/man1
94 man5dir = $(mandir)/man5
95 man7dir = $(mandir)/man7
96 # DESTDIR =
98 ASCIIDOC = asciidoc
99 ASCIIDOC_EXTRA =
100 MANPAGE_XSL = manpage-normal.xsl
101 XMLTO = xmlto
102 XMLTO_EXTRA =
103 INSTALL ?= install
104 RM ?= rm -f
105 MAN_REPO = ../../git-manpages
106 HTML_REPO = ../../git-htmldocs
108 MAKEINFO = makeinfo
109 INSTALL_INFO = install-info
110 DOCBOOK2X_TEXI = docbook2x-texi
111 DBLATEX = dblatex
112 ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
113 ifndef PERL_PATH
114 PERL_PATH = /usr/bin/perl
115 endif
117 -include ../config.mak.autogen
118 -include ../config.mak
121 # For docbook-xsl ...
122 # -1.68.1, no extra settings are needed?
123 # 1.69.0, set ASCIIDOC_ROFF?
124 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
125 # 1.71.1, set ASCIIDOC_ROFF?
126 # 1.72.0, set DOCBOOK_XSL_172.
127 # 1.73.0-, no extra settings are needed
130 ifdef DOCBOOK_XSL_172
131 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
132 MANPAGE_XSL = manpage-1.72.xsl
133 else
134 ifndef ASCIIDOC_ROFF
135 # docbook-xsl after 1.72 needs the regular XSL, but will not
136 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
137 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
138 endif
139 endif
140 ifdef MAN_BOLD_LITERAL
141 XMLTO_EXTRA += -m manpage-bold-literal.xsl
142 endif
143 ifdef DOCBOOK_SUPPRESS_SP
144 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
145 endif
147 # Newer DocBook stylesheet emits warning cruft in the output when
148 # this is not set, and if set it shows an absolute link. Older
149 # stylesheets simply ignore this parameter.
151 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
152 # or similar.
153 ifndef MAN_BASE_URL
154 MAN_BASE_URL = file://$(htmldir)/
155 endif
156 XMLTO_EXTRA += -m manpage-base-url.xsl
158 # If your target system uses GNU groff, it may try to render
159 # apostrophes as a "pretty" apostrophe using unicode. This breaks
160 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
161 # apostrophes. Unfortunately does not work with non-GNU roff.
162 ifdef GNU_ROFF
163 XMLTO_EXTRA += -m manpage-quote-apos.xsl
164 endif
166 SHELL_PATH ?= $(SHELL)
167 # Shell quote;
168 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
170 ifdef DEFAULT_PAGER
171 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
172 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
173 endif
175 ifdef DEFAULT_EDITOR
176 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
177 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
178 endif
180 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
181 QUIET_SUBDIR1 =
183 ifneq ($(findstring $(MAKEFLAGS),w),w)
184 PRINT_DIR = --no-print-directory
185 else # "make -w"
186 NO_SUBDIR = :
187 endif
189 ifneq ($(findstring $(MAKEFLAGS),s),s)
190 ifndef V
191 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
192 QUIET_XMLTO = @echo ' ' XMLTO $@;
193 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
194 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
195 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
196 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
197 QUIET_GEN = @echo ' ' GEN $@;
198 QUIET_STDERR = 2> /dev/null
199 QUIET_SUBDIR0 = +@subdir=
200 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
201 $(MAKE) $(PRINT_DIR) -C $$subdir
202 export V
203 endif
204 endif
206 all: html man
208 html: $(DOC_HTML)
210 man: man1 man5 man7
211 man1: $(DOC_MAN1)
212 man5: $(DOC_MAN5)
213 man7: $(DOC_MAN7)
215 info: git.info gitman.info
217 pdf: user-manual.pdf
219 install: install-man
221 install-man: man
222 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
223 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
224 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
225 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
226 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
227 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
229 install-info: info
230 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
231 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
232 if test -r $(DESTDIR)$(infodir)/dir; then \
233 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
234 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
235 else \
236 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
239 install-pdf: pdf
240 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
241 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
243 install-html: html
244 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
246 ../GIT-VERSION-FILE: FORCE
247 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
249 -include ../GIT-VERSION-FILE
252 # Determine "include::" file references in asciidoc files.
254 docdep_prereqs = \
255 mergetools-list.made $(mergetools_txt) \
256 cmd-list.made $(cmds_txt)
258 doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl
259 $(QUIET_GEN)$(RM) $@+ $@ && \
260 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
261 mv $@+ $@
263 -include doc.dep
265 cmds_txt = cmds-ancillaryinterrogators.txt \
266 cmds-ancillarymanipulators.txt \
267 cmds-mainporcelain.txt \
268 cmds-plumbinginterrogators.txt \
269 cmds-plumbingmanipulators.txt \
270 cmds-synchingrepositories.txt \
271 cmds-synchelpers.txt \
272 cmds-purehelpers.txt \
273 cmds-foreignscminterface.txt
275 $(cmds_txt): cmd-list.made
277 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
278 $(QUIET_GEN)$(RM) $@ && \
279 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
280 date >$@
282 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
284 $(mergetools_txt): mergetools-list.made
286 mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
287 $(QUIET_GEN)$(RM) $@ && \
288 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
289 . ../git-mergetool--lib.sh && \
290 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
291 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
292 . ../git-mergetool--lib.sh && \
293 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
294 date >$@
296 clean:
297 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
298 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
299 $(RM) *.pdf
300 $(RM) howto-index.txt howto/*.html doc.dep
301 $(RM) technical/*.html technical/api-index.txt
302 $(RM) $(cmds_txt) $(mergetools_txt) *.made
303 $(RM) manpage-base-url.xsl
305 $(MAN_HTML): %.html : %.txt asciidoc.conf
306 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
307 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
308 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
309 mv $@+ $@
311 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
312 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
313 $(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
314 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
315 mv $@+ $@
317 manpage-base-url.xsl: manpage-base-url.xsl.in
318 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
320 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
321 $(QUIET_XMLTO)$(RM) $@ && \
322 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
324 %.xml : %.txt asciidoc.conf
325 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
326 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
327 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
328 mv $@+ $@
330 user-manual.xml: user-manual.txt user-manual.conf
331 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
332 $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d article -o $@+ $< && \
333 mv $@+ $@
335 technical/api-index.txt: technical/api-index-skel.txt \
336 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
337 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
339 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
340 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
341 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
342 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
344 XSLT = docbook.xsl
345 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
347 user-manual.html: user-manual.xml $(XSLT)
348 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
349 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
350 mv $@+ $@
352 git.info: user-manual.texi
353 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
355 user-manual.texi: user-manual.xml
356 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
357 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
358 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
359 rm $@++ && \
360 mv $@+ $@
362 user-manual.pdf: user-manual.xml
363 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
364 $(DBLATEX) -o $@+ -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty $< && \
365 mv $@+ $@
367 gitman.texi: $(MAN_XML) cat-texi.perl
368 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
369 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
370 --to-stdout $(xml) &&) true) > $@++ && \
371 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
372 rm $@++ && \
373 mv $@+ $@
375 gitman.info: gitman.texi
376 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
378 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
379 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
380 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
381 mv $@+ $@
383 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
384 $(QUIET_GEN)$(RM) $@+ $@ && \
385 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
386 mv $@+ $@
388 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
389 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt
391 WEBDOC_DEST = /pub/software/scm/git/docs
393 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
394 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
395 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
396 sed -e '1,/^$$/d' $< | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - >$@+ && \
397 mv $@+ $@
399 install-webdoc : html
400 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
402 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
403 # next to the 'git' repository itself for the following to work.
405 quick-install: quick-install-man
407 require-manrepo::
408 @if test ! -d $(MAN_REPO); \
409 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
411 quick-install-man: require-manrepo
412 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
414 require-htmlrepo::
415 @if test ! -d $(HTML_REPO); \
416 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
418 quick-install-html: require-htmlrepo
419 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
421 print-man1:
422 @for i in $(MAN1_TXT); do echo $$i; done
424 .PHONY: FORCE