t2101: modernize test style
[git/debian.git] / Documentation / Makefile
blob6232143cb95d105b0c33b81d16c6b7b628fadb97
1 # Guard against environment variables
2 MAN1_TXT =
3 MAN5_TXT =
4 MAN7_TXT =
5 TECH_DOCS =
6 ARTICLES =
7 SP_ARTICLES =
8 OBSOLETE_HTML =
10 MAN1_TXT += $(filter-out \
11 $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
12 $(wildcard git-*.txt))
13 MAN1_TXT += git.txt
14 MAN1_TXT += gitk.txt
15 MAN1_TXT += gitremote-helpers.txt
16 MAN1_TXT += gitweb.txt
18 MAN5_TXT += gitattributes.txt
19 MAN5_TXT += githooks.txt
20 MAN5_TXT += gitignore.txt
21 MAN5_TXT += gitmodules.txt
22 MAN5_TXT += gitrepository-layout.txt
23 MAN5_TXT += gitweb.conf.txt
25 MAN7_TXT += gitcli.txt
26 MAN7_TXT += gitcore-tutorial.txt
27 MAN7_TXT += gitcredentials.txt
28 MAN7_TXT += gitcvs-migration.txt
29 MAN7_TXT += gitdiffcore.txt
30 MAN7_TXT += giteveryday.txt
31 MAN7_TXT += gitglossary.txt
32 MAN7_TXT += gitnamespaces.txt
33 MAN7_TXT += gitrevisions.txt
34 MAN7_TXT += gitsubmodules.txt
35 MAN7_TXT += gittutorial-2.txt
36 MAN7_TXT += gittutorial.txt
37 MAN7_TXT += gitworkflows.txt
39 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
40 MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
41 MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
42 GIT_MAN_REF = master
44 OBSOLETE_HTML += everyday.html
45 OBSOLETE_HTML += git-remote-helpers.html
46 DOC_HTML = $(MAN_HTML) $(OBSOLETE_HTML)
48 ARTICLES += howto-index
49 ARTICLES += git-tools
50 ARTICLES += git-bisect-lk2009
51 # with their own formatting rules.
52 SP_ARTICLES += user-manual
53 SP_ARTICLES += howto/new-command
54 SP_ARTICLES += howto/revert-branch-rebase
55 SP_ARTICLES += howto/using-merge-subtree
56 SP_ARTICLES += howto/using-signed-tag-in-pull-request
57 SP_ARTICLES += howto/use-git-daemon
58 SP_ARTICLES += howto/update-hook-example
59 SP_ARTICLES += howto/setup-git-server-over-http
60 SP_ARTICLES += howto/separating-topic-branches
61 SP_ARTICLES += howto/revert-a-faulty-merge
62 SP_ARTICLES += howto/recover-corrupted-blob-object
63 SP_ARTICLES += howto/recover-corrupted-object-harder
64 SP_ARTICLES += howto/rebuild-from-update-hook
65 SP_ARTICLES += howto/rebase-from-internal-branch
66 SP_ARTICLES += howto/keep-canonical-history-correct
67 SP_ARTICLES += howto/maintain-git
68 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
69 SP_ARTICLES += $(API_DOCS)
71 TECH_DOCS += SubmittingPatches
72 TECH_DOCS += technical/hash-function-transition
73 TECH_DOCS += technical/http-protocol
74 TECH_DOCS += technical/index-format
75 TECH_DOCS += technical/long-running-process-protocol
76 TECH_DOCS += technical/pack-format
77 TECH_DOCS += technical/pack-heuristics
78 TECH_DOCS += technical/pack-protocol
79 TECH_DOCS += technical/protocol-capabilities
80 TECH_DOCS += technical/protocol-common
81 TECH_DOCS += technical/racy-git
82 TECH_DOCS += technical/send-pack-pipeline
83 TECH_DOCS += technical/shallow
84 TECH_DOCS += technical/signature-format
85 TECH_DOCS += technical/trivial-merge
86 SP_ARTICLES += $(TECH_DOCS)
87 SP_ARTICLES += technical/api-index
89 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
91 DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
92 DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
93 DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
95 prefix ?= $(HOME)
96 bindir ?= $(prefix)/bin
97 htmldir ?= $(prefix)/share/doc/git-doc
98 infodir ?= $(prefix)/share/info
99 pdfdir ?= $(prefix)/share/doc/git-doc
100 mandir ?= $(prefix)/share/man
101 man1dir = $(mandir)/man1
102 man5dir = $(mandir)/man5
103 man7dir = $(mandir)/man7
104 # DESTDIR =
106 ASCIIDOC = asciidoc
107 ASCIIDOC_EXTRA =
108 ASCIIDOC_HTML = xhtml11
109 ASCIIDOC_DOCBOOK = docbook
110 ASCIIDOC_CONF = -f asciidoc.conf
111 ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
112 -agit_version=$(GIT_VERSION)
113 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
114 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
115 MANPAGE_XSL = manpage-normal.xsl
116 XMLTO = xmlto
117 XMLTO_EXTRA =
118 INSTALL ?= install
119 RM ?= rm -f
120 MAN_REPO = ../../git-manpages
121 HTML_REPO = ../../git-htmldocs
123 MAKEINFO = makeinfo
124 INSTALL_INFO = install-info
125 DOCBOOK2X_TEXI = docbook2x-texi
126 DBLATEX = dblatex
127 ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
128 DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
129 ifndef PERL_PATH
130 PERL_PATH = /usr/bin/perl
131 endif
133 -include ../config.mak.autogen
134 -include ../config.mak
137 # For docbook-xsl ...
138 # -1.68.1, no extra settings are needed?
139 # 1.69.0, set ASCIIDOC_ROFF?
140 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
141 # 1.71.1, set ASCIIDOC_ROFF?
142 # 1.72.0, set DOCBOOK_XSL_172.
143 # 1.73.0-, no extra settings are needed
146 ifdef DOCBOOK_XSL_172
147 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
148 MANPAGE_XSL = manpage-1.72.xsl
149 else
150 ifndef ASCIIDOC_ROFF
151 # docbook-xsl after 1.72 needs the regular XSL, but will not
152 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
153 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
154 endif
155 endif
156 ifndef NO_MAN_BOLD_LITERAL
157 XMLTO_EXTRA += -m manpage-bold-literal.xsl
158 endif
159 ifdef DOCBOOK_SUPPRESS_SP
160 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
161 endif
163 # Newer DocBook stylesheet emits warning cruft in the output when
164 # this is not set, and if set it shows an absolute link. Older
165 # stylesheets simply ignore this parameter.
167 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
168 # or similar.
169 ifndef MAN_BASE_URL
170 MAN_BASE_URL = file://$(htmldir)/
171 endif
172 XMLTO_EXTRA += -m manpage-base-url.xsl
174 # If your target system uses GNU groff, it may try to render
175 # apostrophes as a "pretty" apostrophe using unicode. This breaks
176 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
177 # apostrophes. Unfortunately does not work with non-GNU roff.
178 ifdef GNU_ROFF
179 XMLTO_EXTRA += -m manpage-quote-apos.xsl
180 endif
182 ifdef USE_ASCIIDOCTOR
183 ASCIIDOC = asciidoctor
184 ASCIIDOC_CONF =
185 ASCIIDOC_HTML = xhtml5
186 ASCIIDOC_DOCBOOK = docbook45
187 ASCIIDOC_EXTRA += -acompat-mode
188 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
189 ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
190 DBLATEX_COMMON =
191 endif
193 SHELL_PATH ?= $(SHELL)
194 # Shell quote;
195 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
197 ifdef DEFAULT_PAGER
198 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
199 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
200 endif
202 ifdef DEFAULT_EDITOR
203 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
204 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
205 endif
207 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
208 QUIET_SUBDIR1 =
210 ifneq ($(findstring $(MAKEFLAGS),w),w)
211 PRINT_DIR = --no-print-directory
212 else # "make -w"
213 NO_SUBDIR = :
214 endif
216 ifneq ($(findstring $(MAKEFLAGS),s),s)
217 ifndef V
218 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
219 QUIET_XMLTO = @echo ' ' XMLTO $@;
220 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
221 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
222 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
223 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
224 QUIET_GEN = @echo ' ' GEN $@;
225 QUIET_LINT = @echo ' ' LINT $@;
226 QUIET_STDERR = 2> /dev/null
227 QUIET_SUBDIR0 = +@subdir=
228 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
229 $(MAKE) $(PRINT_DIR) -C $$subdir
230 export V
231 endif
232 endif
234 all: html man
236 html: $(DOC_HTML)
238 man: man1 man5 man7
239 man1: $(DOC_MAN1)
240 man5: $(DOC_MAN5)
241 man7: $(DOC_MAN7)
243 info: git.info gitman.info
245 pdf: user-manual.pdf
247 install: install-man
249 install-man: man
250 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
251 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
252 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
253 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
254 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
255 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
257 install-info: info
258 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
259 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
260 if test -r $(DESTDIR)$(infodir)/dir; then \
261 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
262 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
263 else \
264 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
267 install-pdf: pdf
268 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
269 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
271 install-html: html
272 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
274 ../GIT-VERSION-FILE: FORCE
275 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
277 -include ../GIT-VERSION-FILE
280 # Determine "include::" file references in asciidoc files.
282 docdep_prereqs = \
283 mergetools-list.made $(mergetools_txt) \
284 cmd-list.made $(cmds_txt)
286 doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl
287 $(QUIET_GEN)$(RM) $@+ $@ && \
288 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
289 mv $@+ $@
291 -include doc.dep
293 cmds_txt = cmds-ancillaryinterrogators.txt \
294 cmds-ancillarymanipulators.txt \
295 cmds-mainporcelain.txt \
296 cmds-plumbinginterrogators.txt \
297 cmds-plumbingmanipulators.txt \
298 cmds-synchingrepositories.txt \
299 cmds-synchelpers.txt \
300 cmds-purehelpers.txt \
301 cmds-foreignscminterface.txt
303 $(cmds_txt): cmd-list.made
305 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
306 $(QUIET_GEN)$(RM) $@ && \
307 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
308 date >$@
310 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
312 $(mergetools_txt): mergetools-list.made
314 mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
315 $(QUIET_GEN)$(RM) $@ && \
316 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
317 . ../git-mergetool--lib.sh && \
318 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
319 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
320 . ../git-mergetool--lib.sh && \
321 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
322 date >$@
324 clean:
325 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
326 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
327 $(RM) *.pdf
328 $(RM) howto-index.txt howto/*.html doc.dep
329 $(RM) technical/*.html technical/api-index.txt
330 $(RM) SubmittingPatches.txt
331 $(RM) $(cmds_txt) $(mergetools_txt) *.made
332 $(RM) manpage-base-url.xsl
334 $(MAN_HTML): %.html : %.txt asciidoc.conf
335 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
336 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
337 mv $@+ $@
339 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
340 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
341 $(TXT_TO_HTML) -o $@+ $< && \
342 mv $@+ $@
344 manpage-base-url.xsl: manpage-base-url.xsl.in
345 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
347 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
348 $(QUIET_XMLTO)$(RM) $@ && \
349 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
351 %.xml : %.txt asciidoc.conf
352 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
353 $(TXT_TO_XML) -d manpage -o $@+ $< && \
354 mv $@+ $@
356 user-manual.xml: user-manual.txt user-manual.conf
357 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
358 $(TXT_TO_XML) -d book -o $@+ $< && \
359 mv $@+ $@
361 technical/api-index.txt: technical/api-index-skel.txt \
362 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
363 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
365 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
366 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
367 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
369 SubmittingPatches.txt: SubmittingPatches
370 $(QUIET_GEN) cp $< $@
372 XSLT = docbook.xsl
373 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
375 user-manual.html: user-manual.xml $(XSLT)
376 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
377 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
378 mv $@+ $@
380 git.info: user-manual.texi
381 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
383 user-manual.texi: user-manual.xml
384 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
385 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
386 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
387 rm $@++ && \
388 mv $@+ $@
390 user-manual.pdf: user-manual.xml
391 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
392 $(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
393 mv $@+ $@
395 gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
396 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
397 ($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
398 $(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
399 rm $(xml)+ &&) true) > $@++ && \
400 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
401 rm $@++ && \
402 mv $@+ $@
404 gitman.info: gitman.texi
405 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
407 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
408 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
409 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
410 mv $@+ $@
412 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
413 $(QUIET_GEN)$(RM) $@+ $@ && \
414 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
415 mv $@+ $@
417 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
418 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
420 WEBDOC_DEST = /pub/software/scm/git/docs
422 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
423 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
424 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
425 sed -e '1,/^$$/d' $< | \
426 $(TXT_TO_HTML) - >$@+ && \
427 mv $@+ $@
429 install-webdoc : html
430 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
432 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
433 # next to the 'git' repository itself for the following to work.
435 quick-install: quick-install-man
437 require-manrepo::
438 @if test ! -d $(MAN_REPO); \
439 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
441 quick-install-man: require-manrepo
442 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir) $(GIT_MAN_REF)
444 require-htmlrepo::
445 @if test ! -d $(HTML_REPO); \
446 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
448 quick-install-html: require-htmlrepo
449 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir) $(GIT_MAN_REF)
451 print-man1:
452 @for i in $(MAN1_TXT); do echo $$i; done
454 lint-docs::
455 $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl
457 .PHONY: FORCE