Merge branch 'ab/gitweb-link-html-escape'
[git.git] / Documentation / Makefile
blobb43d66eae6e154b229aa1477b8454ce2918ba8b9
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 MAN1_TXT += $(filter-out \
11 $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
12 $(wildcard git-*.txt))
13 MAN1_TXT += git.txt
14 MAN1_TXT += gitk.txt
15 MAN1_TXT += gitremote-helpers.txt
16 MAN1_TXT += gitweb.txt
18 MAN5_TXT += gitattributes.txt
19 MAN5_TXT += githooks.txt
20 MAN5_TXT += gitignore.txt
21 MAN5_TXT += gitmodules.txt
22 MAN5_TXT += gitrepository-layout.txt
23 MAN5_TXT += gitweb.conf.txt
25 MAN7_TXT += gitcli.txt
26 MAN7_TXT += gitcore-tutorial.txt
27 MAN7_TXT += gitcredentials.txt
28 MAN7_TXT += gitcvs-migration.txt
29 MAN7_TXT += gitdiffcore.txt
30 MAN7_TXT += giteveryday.txt
31 MAN7_TXT += gitglossary.txt
32 MAN7_TXT += gitnamespaces.txt
33 MAN7_TXT += gitrevisions.txt
34 MAN7_TXT += gittutorial-2.txt
35 MAN7_TXT += gittutorial.txt
36 MAN7_TXT += gitworkflows.txt
38 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
39 MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
40 MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
42 OBSOLETE_HTML += everyday.html
43 OBSOLETE_HTML += git-remote-helpers.html
44 DOC_HTML = $(MAN_HTML) $(OBSOLETE_HTML)
46 ARTICLES += howto-index
47 ARTICLES += git-tools
48 ARTICLES += git-bisect-lk2009
49 # with their own formatting rules.
50 SP_ARTICLES += user-manual
51 SP_ARTICLES += howto/new-command
52 SP_ARTICLES += howto/revert-branch-rebase
53 SP_ARTICLES += howto/using-merge-subtree
54 SP_ARTICLES += howto/using-signed-tag-in-pull-request
55 SP_ARTICLES += howto/use-git-daemon
56 SP_ARTICLES += howto/update-hook-example
57 SP_ARTICLES += howto/setup-git-server-over-http
58 SP_ARTICLES += howto/separating-topic-branches
59 SP_ARTICLES += howto/revert-a-faulty-merge
60 SP_ARTICLES += howto/recover-corrupted-blob-object
61 SP_ARTICLES += howto/recover-corrupted-object-harder
62 SP_ARTICLES += howto/rebuild-from-update-hook
63 SP_ARTICLES += howto/rebase-from-internal-branch
64 SP_ARTICLES += howto/keep-canonical-history-correct
65 SP_ARTICLES += howto/maintain-git
66 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
67 SP_ARTICLES += $(API_DOCS)
69 TECH_DOCS += technical/http-protocol
70 TECH_DOCS += technical/index-format
71 TECH_DOCS += technical/pack-format
72 TECH_DOCS += technical/pack-heuristics
73 TECH_DOCS += technical/pack-protocol
74 TECH_DOCS += technical/protocol-capabilities
75 TECH_DOCS += technical/protocol-common
76 TECH_DOCS += technical/racy-git
77 TECH_DOCS += technical/send-pack-pipeline
78 TECH_DOCS += technical/shallow
79 TECH_DOCS += technical/signature-format
80 TECH_DOCS += technical/trivial-merge
81 SP_ARTICLES += $(TECH_DOCS)
82 SP_ARTICLES += technical/api-index
84 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
86 DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
87 DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
88 DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
90 prefix ?= $(HOME)
91 bindir ?= $(prefix)/bin
92 htmldir ?= $(prefix)/share/doc/git-doc
93 infodir ?= $(prefix)/share/info
94 pdfdir ?= $(prefix)/share/doc/git-doc
95 mandir ?= $(prefix)/share/man
96 man1dir = $(mandir)/man1
97 man5dir = $(mandir)/man5
98 man7dir = $(mandir)/man7
99 # DESTDIR =
101 ASCIIDOC = asciidoc
102 ASCIIDOC_EXTRA =
103 ASCIIDOC_HTML = xhtml11
104 ASCIIDOC_DOCBOOK = docbook
105 ASCIIDOC_CONF = -f asciidoc.conf
106 ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
107 -agit_version=$(GIT_VERSION)
108 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
109 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
110 MANPAGE_XSL = manpage-normal.xsl
111 XMLTO = xmlto
112 XMLTO_EXTRA =
113 INSTALL ?= install
114 RM ?= rm -f
115 MAN_REPO = ../../git-manpages
116 HTML_REPO = ../../git-htmldocs
118 MAKEINFO = makeinfo
119 INSTALL_INFO = install-info
120 DOCBOOK2X_TEXI = docbook2x-texi
121 DBLATEX = dblatex
122 ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
123 ifndef PERL_PATH
124 PERL_PATH = /usr/bin/perl
125 endif
127 -include ../config.mak.autogen
128 -include ../config.mak
131 # For docbook-xsl ...
132 # -1.68.1, no extra settings are needed?
133 # 1.69.0, set ASCIIDOC_ROFF?
134 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
135 # 1.71.1, set ASCIIDOC_ROFF?
136 # 1.72.0, set DOCBOOK_XSL_172.
137 # 1.73.0-, no extra settings are needed
140 ifdef DOCBOOK_XSL_172
141 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
142 MANPAGE_XSL = manpage-1.72.xsl
143 else
144 ifndef ASCIIDOC_ROFF
145 # docbook-xsl after 1.72 needs the regular XSL, but will not
146 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
147 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
148 endif
149 endif
150 ifndef NO_MAN_BOLD_LITERAL
151 XMLTO_EXTRA += -m manpage-bold-literal.xsl
152 endif
153 ifdef DOCBOOK_SUPPRESS_SP
154 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
155 endif
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.
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
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
176 SHELL_PATH ?= $(SHELL)
177 # Shell quote;
178 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
180 ifdef DEFAULT_PAGER
181 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
182 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
183 endif
185 ifdef DEFAULT_EDITOR
186 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
187 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
188 endif
190 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
191 QUIET_SUBDIR1 =
193 ifneq ($(findstring $(MAKEFLAGS),w),w)
194 PRINT_DIR = --no-print-directory
195 else # "make -w"
196 NO_SUBDIR = :
197 endif
199 ifneq ($(findstring $(MAKEFLAGS),s),s)
200 ifndef V
201 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
202 QUIET_XMLTO = @echo ' ' XMLTO $@;
203 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
204 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
205 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
206 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
207 QUIET_GEN = @echo ' ' GEN $@;
208 QUIET_LINT = @echo ' ' LINT $@;
209 QUIET_STDERR = 2> /dev/null
210 QUIET_SUBDIR0 = +@subdir=
211 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
212 $(MAKE) $(PRINT_DIR) -C $$subdir
213 export V
214 endif
215 endif
217 all: html man
219 html: $(DOC_HTML)
221 man: man1 man5 man7
222 man1: $(DOC_MAN1)
223 man5: $(DOC_MAN5)
224 man7: $(DOC_MAN7)
226 info: git.info gitman.info
228 pdf: user-manual.pdf
230 install: install-man
232 install-man: man
233 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
234 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
235 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
236 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
237 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
238 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
240 install-info: info
241 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
242 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
243 if test -r $(DESTDIR)$(infodir)/dir; then \
244 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
245 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
246 else \
247 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
250 install-pdf: pdf
251 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
252 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
254 install-html: html
255 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
257 ../GIT-VERSION-FILE: FORCE
258 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
260 -include ../GIT-VERSION-FILE
263 # Determine "include::" file references in asciidoc files.
265 docdep_prereqs = \
266 mergetools-list.made $(mergetools_txt) \
267 cmd-list.made $(cmds_txt)
269 doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl
270 $(QUIET_GEN)$(RM) $@+ $@ && \
271 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
272 mv $@+ $@
274 -include doc.dep
276 cmds_txt = cmds-ancillaryinterrogators.txt \
277 cmds-ancillarymanipulators.txt \
278 cmds-mainporcelain.txt \
279 cmds-plumbinginterrogators.txt \
280 cmds-plumbingmanipulators.txt \
281 cmds-synchingrepositories.txt \
282 cmds-synchelpers.txt \
283 cmds-purehelpers.txt \
284 cmds-foreignscminterface.txt
286 $(cmds_txt): cmd-list.made
288 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
289 $(QUIET_GEN)$(RM) $@ && \
290 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
291 date >$@
293 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
295 $(mergetools_txt): mergetools-list.made
297 mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
298 $(QUIET_GEN)$(RM) $@ && \
299 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
300 . ../git-mergetool--lib.sh && \
301 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
302 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
303 . ../git-mergetool--lib.sh && \
304 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
305 date >$@
307 clean:
308 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
309 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
310 $(RM) *.pdf
311 $(RM) howto-index.txt howto/*.html doc.dep
312 $(RM) technical/*.html technical/api-index.txt
313 $(RM) $(cmds_txt) $(mergetools_txt) *.made
314 $(RM) manpage-base-url.xsl
316 $(MAN_HTML): %.html : %.txt asciidoc.conf
317 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
318 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
319 mv $@+ $@
321 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
322 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
323 $(TXT_TO_HTML) -o $@+ $< && \
324 mv $@+ $@
326 manpage-base-url.xsl: manpage-base-url.xsl.in
327 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
329 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
330 $(QUIET_XMLTO)$(RM) $@ && \
331 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
333 %.xml : %.txt asciidoc.conf
334 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
335 $(TXT_TO_XML) -d manpage -o $@+ $< && \
336 mv $@+ $@
338 user-manual.xml: user-manual.txt user-manual.conf
339 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
340 $(TXT_TO_XML) -d article -o $@+ $< && \
341 mv $@+ $@
343 technical/api-index.txt: technical/api-index-skel.txt \
344 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
345 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
347 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
348 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
349 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
351 XSLT = docbook.xsl
352 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
354 user-manual.html: user-manual.xml $(XSLT)
355 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
356 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
357 mv $@+ $@
359 git.info: user-manual.texi
360 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
362 user-manual.texi: user-manual.xml
363 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
364 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
365 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
366 rm $@++ && \
367 mv $@+ $@
369 user-manual.pdf: user-manual.xml
370 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
371 $(DBLATEX) -o $@+ -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty $< && \
372 mv $@+ $@
374 gitman.texi: $(MAN_XML) cat-texi.perl
375 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
376 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
377 --to-stdout $(xml) &&) true) > $@++ && \
378 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
379 rm $@++ && \
380 mv $@+ $@
382 gitman.info: gitman.texi
383 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
385 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
386 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
387 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
388 mv $@+ $@
390 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
391 $(QUIET_GEN)$(RM) $@+ $@ && \
392 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
393 mv $@+ $@
395 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
396 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
398 WEBDOC_DEST = /pub/software/scm/git/docs
400 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
401 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
402 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
403 sed -e '1,/^$$/d' $< | \
404 $(TXT_TO_HTML) - >$@+ && \
405 mv $@+ $@
407 install-webdoc : html
408 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
410 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
411 # next to the 'git' repository itself for the following to work.
413 quick-install: quick-install-man
415 require-manrepo::
416 @if test ! -d $(MAN_REPO); \
417 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
419 quick-install-man: require-manrepo
420 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
422 require-htmlrepo::
423 @if test ! -d $(HTML_REPO); \
424 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
426 quick-install-html: require-htmlrepo
427 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
429 print-man1:
430 @for i in $(MAN1_TXT); do echo $$i; done
432 lint-docs::
433 $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl
435 .PHONY: FORCE