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