Almost ready for 2.15.1
[git.git] / Documentation / Makefile
blob471bb29725cdc47b4e56bc85e2af635f7b836776
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))
43 OBSOLETE_HTML += everyday.html
44 OBSOLETE_HTML += git-remote-helpers.html
45 DOC_HTML = $(MAN_HTML) $(OBSOLETE_HTML)
47 ARTICLES += howto-index
48 ARTICLES += git-tools
49 ARTICLES += git-bisect-lk2009
50 # with their own formatting rules.
51 SP_ARTICLES += user-manual
52 SP_ARTICLES += howto/new-command
53 SP_ARTICLES += howto/revert-branch-rebase
54 SP_ARTICLES += howto/using-merge-subtree
55 SP_ARTICLES += howto/using-signed-tag-in-pull-request
56 SP_ARTICLES += howto/use-git-daemon
57 SP_ARTICLES += howto/update-hook-example
58 SP_ARTICLES += howto/setup-git-server-over-http
59 SP_ARTICLES += howto/separating-topic-branches
60 SP_ARTICLES += howto/revert-a-faulty-merge
61 SP_ARTICLES += howto/recover-corrupted-blob-object
62 SP_ARTICLES += howto/recover-corrupted-object-harder
63 SP_ARTICLES += howto/rebuild-from-update-hook
64 SP_ARTICLES += howto/rebase-from-internal-branch
65 SP_ARTICLES += howto/keep-canonical-history-correct
66 SP_ARTICLES += howto/maintain-git
67 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
68 SP_ARTICLES += $(API_DOCS)
70 TECH_DOCS += technical/hash-function-transition
71 TECH_DOCS += technical/http-protocol
72 TECH_DOCS += technical/index-format
73 TECH_DOCS += technical/pack-format
74 TECH_DOCS += technical/pack-heuristics
75 TECH_DOCS += technical/pack-protocol
76 TECH_DOCS += technical/protocol-capabilities
77 TECH_DOCS += technical/protocol-common
78 TECH_DOCS += technical/racy-git
79 TECH_DOCS += technical/send-pack-pipeline
80 TECH_DOCS += technical/shallow
81 TECH_DOCS += technical/signature-format
82 TECH_DOCS += technical/trivial-merge
83 SP_ARTICLES += $(TECH_DOCS)
84 SP_ARTICLES += technical/api-index
86 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
88 DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
89 DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
90 DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
92 prefix ?= $(HOME)
93 bindir ?= $(prefix)/bin
94 htmldir ?= $(prefix)/share/doc/git-doc
95 infodir ?= $(prefix)/share/info
96 pdfdir ?= $(prefix)/share/doc/git-doc
97 mandir ?= $(prefix)/share/man
98 man1dir = $(mandir)/man1
99 man5dir = $(mandir)/man5
100 man7dir = $(mandir)/man7
101 # DESTDIR =
103 ASCIIDOC = asciidoc
104 ASCIIDOC_EXTRA =
105 ASCIIDOC_HTML = xhtml11
106 ASCIIDOC_DOCBOOK = docbook
107 ASCIIDOC_CONF = -f asciidoc.conf
108 ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
109 -agit_version=$(GIT_VERSION)
110 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
111 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
112 MANPAGE_XSL = manpage-normal.xsl
113 XMLTO = xmlto
114 XMLTO_EXTRA =
115 INSTALL ?= install
116 RM ?= rm -f
117 MAN_REPO = ../../git-manpages
118 HTML_REPO = ../../git-htmldocs
120 MAKEINFO = makeinfo
121 INSTALL_INFO = install-info
122 DOCBOOK2X_TEXI = docbook2x-texi
123 DBLATEX = dblatex
124 ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
125 DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
126 ifndef PERL_PATH
127 PERL_PATH = /usr/bin/perl
128 endif
130 -include ../config.mak.autogen
131 -include ../config.mak
134 # For docbook-xsl ...
135 # -1.68.1, no extra settings are needed?
136 # 1.69.0, set ASCIIDOC_ROFF?
137 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
138 # 1.71.1, set ASCIIDOC_ROFF?
139 # 1.72.0, set DOCBOOK_XSL_172.
140 # 1.73.0-, no extra settings are needed
143 ifdef DOCBOOK_XSL_172
144 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
145 MANPAGE_XSL = manpage-1.72.xsl
146 else
147 ifndef ASCIIDOC_ROFF
148 # docbook-xsl after 1.72 needs the regular XSL, but will not
149 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
150 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
151 endif
152 endif
153 ifndef NO_MAN_BOLD_LITERAL
154 XMLTO_EXTRA += -m manpage-bold-literal.xsl
155 endif
156 ifdef DOCBOOK_SUPPRESS_SP
157 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
158 endif
160 # Newer DocBook stylesheet emits warning cruft in the output when
161 # this is not set, and if set it shows an absolute link. Older
162 # stylesheets simply ignore this parameter.
164 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
165 # or similar.
166 ifndef MAN_BASE_URL
167 MAN_BASE_URL = file://$(htmldir)/
168 endif
169 XMLTO_EXTRA += -m manpage-base-url.xsl
171 # If your target system uses GNU groff, it may try to render
172 # apostrophes as a "pretty" apostrophe using unicode. This breaks
173 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
174 # apostrophes. Unfortunately does not work with non-GNU roff.
175 ifdef GNU_ROFF
176 XMLTO_EXTRA += -m manpage-quote-apos.xsl
177 endif
179 ifdef USE_ASCIIDOCTOR
180 ASCIIDOC = asciidoctor
181 ASCIIDOC_CONF =
182 ASCIIDOC_HTML = xhtml5
183 ASCIIDOC_DOCBOOK = docbook45
184 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
185 ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
186 DBLATEX_COMMON =
187 endif
189 SHELL_PATH ?= $(SHELL)
190 # Shell quote;
191 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
193 ifdef DEFAULT_PAGER
194 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
195 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
196 endif
198 ifdef DEFAULT_EDITOR
199 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
200 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
201 endif
203 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
204 QUIET_SUBDIR1 =
206 ifneq ($(findstring $(MAKEFLAGS),w),w)
207 PRINT_DIR = --no-print-directory
208 else # "make -w"
209 NO_SUBDIR = :
210 endif
212 ifneq ($(findstring $(MAKEFLAGS),s),s)
213 ifndef V
214 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
215 QUIET_XMLTO = @echo ' ' XMLTO $@;
216 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
217 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
218 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
219 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
220 QUIET_GEN = @echo ' ' GEN $@;
221 QUIET_LINT = @echo ' ' LINT $@;
222 QUIET_STDERR = 2> /dev/null
223 QUIET_SUBDIR0 = +@subdir=
224 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
225 $(MAKE) $(PRINT_DIR) -C $$subdir
226 export V
227 endif
228 endif
230 all: html man
232 html: $(DOC_HTML)
234 man: man1 man5 man7
235 man1: $(DOC_MAN1)
236 man5: $(DOC_MAN5)
237 man7: $(DOC_MAN7)
239 info: git.info gitman.info
241 pdf: user-manual.pdf
243 install: install-man
245 install-man: man
246 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
247 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
248 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
249 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
250 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
251 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
253 install-info: info
254 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
255 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
256 if test -r $(DESTDIR)$(infodir)/dir; then \
257 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
258 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
259 else \
260 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
263 install-pdf: pdf
264 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
265 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
267 install-html: html
268 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
270 ../GIT-VERSION-FILE: FORCE
271 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
273 -include ../GIT-VERSION-FILE
276 # Determine "include::" file references in asciidoc files.
278 docdep_prereqs = \
279 mergetools-list.made $(mergetools_txt) \
280 cmd-list.made $(cmds_txt)
282 doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl
283 $(QUIET_GEN)$(RM) $@+ $@ && \
284 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
285 mv $@+ $@
287 -include doc.dep
289 cmds_txt = cmds-ancillaryinterrogators.txt \
290 cmds-ancillarymanipulators.txt \
291 cmds-mainporcelain.txt \
292 cmds-plumbinginterrogators.txt \
293 cmds-plumbingmanipulators.txt \
294 cmds-synchingrepositories.txt \
295 cmds-synchelpers.txt \
296 cmds-purehelpers.txt \
297 cmds-foreignscminterface.txt
299 $(cmds_txt): cmd-list.made
301 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
302 $(QUIET_GEN)$(RM) $@ && \
303 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
304 date >$@
306 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
308 $(mergetools_txt): mergetools-list.made
310 mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
311 $(QUIET_GEN)$(RM) $@ && \
312 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
313 . ../git-mergetool--lib.sh && \
314 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
315 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
316 . ../git-mergetool--lib.sh && \
317 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
318 date >$@
320 clean:
321 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
322 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
323 $(RM) *.pdf
324 $(RM) howto-index.txt howto/*.html doc.dep
325 $(RM) technical/*.html technical/api-index.txt
326 $(RM) $(cmds_txt) $(mergetools_txt) *.made
327 $(RM) manpage-base-url.xsl
329 $(MAN_HTML): %.html : %.txt asciidoc.conf
330 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
331 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
332 mv $@+ $@
334 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
335 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
336 $(TXT_TO_HTML) -o $@+ $< && \
337 mv $@+ $@
339 manpage-base-url.xsl: manpage-base-url.xsl.in
340 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
342 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
343 $(QUIET_XMLTO)$(RM) $@ && \
344 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
346 %.xml : %.txt asciidoc.conf
347 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
348 $(TXT_TO_XML) -d manpage -o $@+ $< && \
349 mv $@+ $@
351 user-manual.xml: user-manual.txt user-manual.conf
352 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
353 $(TXT_TO_XML) -d book -o $@+ $< && \
354 mv $@+ $@
356 technical/api-index.txt: technical/api-index-skel.txt \
357 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
358 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
360 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
361 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
362 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
364 XSLT = docbook.xsl
365 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
367 user-manual.html: user-manual.xml $(XSLT)
368 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
369 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
370 mv $@+ $@
372 git.info: user-manual.texi
373 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
375 user-manual.texi: user-manual.xml
376 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
377 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
378 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
379 rm $@++ && \
380 mv $@+ $@
382 user-manual.pdf: user-manual.xml
383 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
384 $(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
385 mv $@+ $@
387 gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
388 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
389 ($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
390 $(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
391 rm $(xml)+ &&) true) > $@++ && \
392 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
393 rm $@++ && \
394 mv $@+ $@
396 gitman.info: gitman.texi
397 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
399 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
400 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
401 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
402 mv $@+ $@
404 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
405 $(QUIET_GEN)$(RM) $@+ $@ && \
406 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
407 mv $@+ $@
409 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
410 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
412 WEBDOC_DEST = /pub/software/scm/git/docs
414 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
415 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
416 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
417 sed -e '1,/^$$/d' $< | \
418 $(TXT_TO_HTML) - >$@+ && \
419 mv $@+ $@
421 install-webdoc : html
422 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
424 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
425 # next to the 'git' repository itself for the following to work.
427 quick-install: quick-install-man
429 require-manrepo::
430 @if test ! -d $(MAN_REPO); \
431 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
433 quick-install-man: require-manrepo
434 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
436 require-htmlrepo::
437 @if test ! -d $(HTML_REPO); \
438 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
440 quick-install-html: require-htmlrepo
441 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
443 print-man1:
444 @for i in $(MAN1_TXT); do echo $$i; done
446 lint-docs::
447 $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl
449 .PHONY: FORCE