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