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