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