Merge branch 'es/restore-staged-from-head-by-default'
[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/send-pack-pipeline
97 TECH_DOCS += technical/shallow
98 TECH_DOCS += technical/signature-format
99 TECH_DOCS += technical/trivial-merge
100 SP_ARTICLES += $(TECH_DOCS)
101 SP_ARTICLES += technical/api-index
102
103 ARTICLES_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
104 HTML_FILTER ?= $(ARTICLES_HTML) $(OBSOLETE_HTML)
105 DOC_HTML = $(MAN_HTML) $(filter $(HTML_FILTER),$(ARTICLES_HTML) $(OBSOLETE_HTML))
106
107 DOC_MAN1 = $(patsubst %.txt,%.1,$(filter $(MAN_FILTER),$(MAN1_TXT)))
108 DOC_MAN5 = $(patsubst %.txt,%.5,$(filter $(MAN_FILTER),$(MAN5_TXT)))
109 DOC_MAN7 = $(patsubst %.txt,%.7,$(filter $(MAN_FILTER),$(MAN7_TXT)))
110
111 prefix ?= $(HOME)
112 bindir ?= $(prefix)/bin
113 htmldir ?= $(prefix)/share/doc/git-doc
114 infodir ?= $(prefix)/share/info
115 pdfdir ?= $(prefix)/share/doc/git-doc
116 mandir ?= $(prefix)/share/man
117 man1dir = $(mandir)/man1
118 man5dir = $(mandir)/man5
119 man7dir = $(mandir)/man7
120 # DESTDIR =
121
122 ASCIIDOC = asciidoc
123 ASCIIDOC_EXTRA =
124 ASCIIDOC_HTML = xhtml11
125 ASCIIDOC_DOCBOOK = docbook
126 ASCIIDOC_CONF = -f asciidoc.conf
127 ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
128                 -amanversion=$(GIT_VERSION) \
129                 -amanmanual='Git Manual' -amansource='Git'
130 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
131 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
132 MANPAGE_XSL = manpage-normal.xsl
133 XMLTO = xmlto
134 XMLTO_EXTRA =
135 INSTALL ?= install
136 RM ?= rm -f
137 MAN_REPO = ../../git-manpages
138 HTML_REPO = ../../git-htmldocs
139
140 MAKEINFO = makeinfo
141 INSTALL_INFO = install-info
142 DOCBOOK2X_TEXI = docbook2x-texi
143 DBLATEX = dblatex
144 ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
145 DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
146 ifndef PERL_PATH
147         PERL_PATH = /usr/bin/perl
148 endif
149
150 -include ../config.mak.autogen
151 -include ../config.mak
152
153 ifndef NO_MAN_BOLD_LITERAL
154 XMLTO_EXTRA += -m manpage-bold-literal.xsl
155 endif
156
157 # Newer DocBook stylesheet emits warning cruft in the output when
158 # this is not set, and if set it shows an absolute link.  Older
159 # stylesheets simply ignore this parameter.
160 #
161 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
162 # or similar.
163 ifndef MAN_BASE_URL
164 MAN_BASE_URL = file://$(htmldir)/
165 endif
166 XMLTO_EXTRA += -m manpage-base-url.xsl
167
168 # If your target system uses GNU groff, it may try to render
169 # apostrophes as a "pretty" apostrophe using unicode.  This breaks
170 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
171 # apostrophes.  Unfortunately does not work with non-GNU roff.
172 ifdef GNU_ROFF
173 XMLTO_EXTRA += -m manpage-quote-apos.xsl
174 endif
175
176 ifdef USE_ASCIIDOCTOR
177 ASCIIDOC = asciidoctor
178 ASCIIDOC_CONF =
179 ASCIIDOC_HTML = xhtml5
180 ASCIIDOC_DOCBOOK = docbook5
181 ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
182 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
183 ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
184 DBLATEX_COMMON =
185 XMLTO_EXTRA += --skip-validation
186 XMLTO_EXTRA += -x manpage.xsl
187 endif
188
189 SHELL_PATH ?= $(SHELL)
190 # Shell quote;
191 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
192
193 ifdef DEFAULT_PAGER
194 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
195 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
196 endif
197
198 ifdef DEFAULT_EDITOR
199 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
200 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
201 endif
202
203 QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
204 QUIET_SUBDIR1  =
205
206 ifneq ($(findstring $(MAKEFLAGS),w),w)
207 PRINT_DIR = --no-print-directory
208 else # "make -w"
209 NO_SUBDIR = :
210 endif
211
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
229
230 all: html man
231
232 html: $(DOC_HTML)
233
234 man: man1 man5 man7
235 man1: $(DOC_MAN1)
236 man5: $(DOC_MAN5)
237 man7: $(DOC_MAN7)
238
239 info: git.info gitman.info
240
241 pdf: user-manual.pdf
242
243 install: install-man
244
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)
252
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 ; \
261         fi
262
263 install-pdf: pdf
264         $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
265         $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
266
267 install-html: html
268         '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
269
270 ../GIT-VERSION-FILE: FORCE
271         $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
272
273 -include ../GIT-VERSION-FILE
274
275 #
276 # Determine "include::" file references in asciidoc files.
277 #
278 docdep_prereqs = \
279         mergetools-list.made $(mergetools_txt) \
280         cmd-list.made $(cmds_txt)
281
282 doc.dep : $(docdep_prereqs) $(wildcard *.txt) $(wildcard config/*.txt) build-docdep.perl
283         $(QUIET_GEN)$(RM) $@+ $@ && \
284         $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
285         mv $@+ $@
286
287 -include doc.dep
288
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
298
299 $(cmds_txt): cmd-list.made
300
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 >$@
305
306 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
307
308 $(mergetools_txt): mergetools-list.made
309
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 >$@
319
320 TRACK_ASCIIDOCFLAGS = $(subst ','\'',$(ASCIIDOC_COMMON):$(ASCIIDOC_HTML):$(ASCIIDOC_DOCBOOK))
321
322 GIT-ASCIIDOCFLAGS: FORCE
323         @FLAGS='$(TRACK_ASCIIDOCFLAGS)'; \
324             if test x"$$FLAGS" != x"`cat GIT-ASCIIDOCFLAGS 2>/dev/null`" ; then \
325                 echo >&2 "    * new asciidoc flags"; \
326                 echo "$$FLAGS" >GIT-ASCIIDOCFLAGS; \
327             fi
328
329 clean:
330         $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
331         $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
332         $(RM) *.pdf
333         $(RM) howto-index.txt howto/*.html doc.dep
334         $(RM) technical/*.html technical/api-index.txt
335         $(RM) SubmittingPatches.txt
336         $(RM) $(cmds_txt) $(mergetools_txt) *.made
337         $(RM) manpage-base-url.xsl
338         $(RM) GIT-ASCIIDOCFLAGS
339
340 $(MAN_HTML): %.html : %.txt asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
341         $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
342         $(TXT_TO_HTML) -d manpage -o $@+ $< && \
343         mv $@+ $@
344
345 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
346         $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
347         $(TXT_TO_HTML) -o $@+ $< && \
348         mv $@+ $@
349
350 manpage-base-url.xsl: manpage-base-url.xsl.in
351         $(QUIET_GEN)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
352
353 %.1 %.5 %.7 : %.xml manpage-base-url.xsl $(wildcard manpage*.xsl)
354         $(QUIET_XMLTO)$(RM) $@ && \
355         $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
356
357 %.xml : %.txt asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
358         $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
359         $(TXT_TO_XML) -d manpage -o $@+ $< && \
360         mv $@+ $@
361
362 user-manual.xml: user-manual.txt user-manual.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
363         $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
364         $(TXT_TO_XML) -d book -o $@+ $< && \
365         mv $@+ $@
366
367 technical/api-index.txt: technical/api-index-skel.txt \
368         technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
369         $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
370
371 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
372 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt \
373         asciidoc.conf GIT-ASCIIDOCFLAGS
374         $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
375
376 SubmittingPatches.txt: SubmittingPatches
377         $(QUIET_GEN) cp $< $@
378
379 XSLT = docbook.xsl
380 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
381
382 user-manual.html: user-manual.xml $(XSLT)
383         $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
384         xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
385         mv $@+ $@
386
387 git.info: user-manual.texi
388         $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
389
390 user-manual.texi: user-manual.xml
391         $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
392         $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
393         $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
394         rm $@++ && \
395         mv $@+ $@
396
397 user-manual.pdf: user-manual.xml
398         $(QUIET_DBLATEX)$(RM) $@+ $@ && \
399         $(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
400         mv $@+ $@
401
402 gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
403         $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
404         ($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
405                 $(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
406                 rm $(xml)+ &&) true) > $@++ && \
407         $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
408         rm $@++ && \
409         mv $@+ $@
410
411 gitman.info: gitman.texi
412         $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
413
414 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
415         $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
416         $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
417         mv $@+ $@
418
419 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
420         $(QUIET_GEN)$(RM) $@+ $@ && \
421         '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
422         mv $@+ $@
423
424 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
425         $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
426
427 WEBDOC_DEST = /pub/software/scm/git/docs
428
429 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
430 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt GIT-ASCIIDOCFLAGS
431         $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
432         sed -e '1,/^$$/d' $< | \
433         $(TXT_TO_HTML) - >$@+ && \
434         mv $@+ $@
435
436 install-webdoc : html
437         '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
438
439 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
440 # next to the 'git' repository itself for the following to work.
441
442 quick-install: quick-install-man
443
444 require-manrepo::
445         @if test ! -d $(MAN_REPO); \
446         then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
447
448 quick-install-man: require-manrepo
449         '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir) $(GIT_MAN_REF)
450
451 require-htmlrepo::
452         @if test ! -d $(HTML_REPO); \
453         then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
454
455 quick-install-html: require-htmlrepo
456         '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir) $(GIT_MAN_REF)
457
458 print-man1:
459         @for i in $(MAN1_TXT); do echo $$i; done
460
461 lint-docs::
462         $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl
463
464 ifeq ($(wildcard po/Makefile),po/Makefile)
465 doc-l10n install-l10n::
466         $(MAKE) -C po $@
467 endif
468
469 .PHONY: FORCE