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