Merge branch 'ew/svn-crlf'
[git/git.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 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
17
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
24
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 += gitsubmodules.txt
35 MAN7_TXT += gittutorial-2.txt
36 MAN7_TXT += gittutorial.txt
37 MAN7_TXT += gitworkflows.txt
38
39 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
40 MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
41 MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
42 GIT_MAN_REF = master
43
44 OBSOLETE_HTML += everyday.html
45 OBSOLETE_HTML += git-remote-helpers.html
46 DOC_HTML = $(MAN_HTML) $(OBSOLETE_HTML)
47
48 ARTICLES += howto-index
49 ARTICLES += git-tools
50 ARTICLES += git-bisect-lk2009
51 # with their own formatting rules.
52 SP_ARTICLES += user-manual
53 SP_ARTICLES += howto/new-command
54 SP_ARTICLES += howto/revert-branch-rebase
55 SP_ARTICLES += howto/using-merge-subtree
56 SP_ARTICLES += howto/using-signed-tag-in-pull-request
57 SP_ARTICLES += howto/use-git-daemon
58 SP_ARTICLES += howto/update-hook-example
59 SP_ARTICLES += howto/setup-git-server-over-http
60 SP_ARTICLES += howto/separating-topic-branches
61 SP_ARTICLES += howto/revert-a-faulty-merge
62 SP_ARTICLES += howto/recover-corrupted-blob-object
63 SP_ARTICLES += howto/recover-corrupted-object-harder
64 SP_ARTICLES += howto/rebuild-from-update-hook
65 SP_ARTICLES += howto/rebase-from-internal-branch
66 SP_ARTICLES += howto/keep-canonical-history-correct
67 SP_ARTICLES += howto/maintain-git
68 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
69 SP_ARTICLES += $(API_DOCS)
70
71 TECH_DOCS += SubmittingPatches
72 TECH_DOCS += technical/hash-function-transition
73 TECH_DOCS += technical/http-protocol
74 TECH_DOCS += technical/index-format
75 TECH_DOCS += technical/pack-format
76 TECH_DOCS += technical/pack-heuristics
77 TECH_DOCS += technical/pack-protocol
78 TECH_DOCS += technical/protocol-capabilities
79 TECH_DOCS += technical/protocol-common
80 TECH_DOCS += technical/racy-git
81 TECH_DOCS += technical/send-pack-pipeline
82 TECH_DOCS += technical/shallow
83 TECH_DOCS += technical/signature-format
84 TECH_DOCS += technical/trivial-merge
85 SP_ARTICLES += $(TECH_DOCS)
86 SP_ARTICLES += technical/api-index
87
88 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
89
90 DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
91 DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
92 DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
93
94 prefix ?= $(HOME)
95 bindir ?= $(prefix)/bin
96 htmldir ?= $(prefix)/share/doc/git-doc
97 infodir ?= $(prefix)/share/info
98 pdfdir ?= $(prefix)/share/doc/git-doc
99 mandir ?= $(prefix)/share/man
100 man1dir = $(mandir)/man1
101 man5dir = $(mandir)/man5
102 man7dir = $(mandir)/man7
103 # DESTDIR =
104
105 ASCIIDOC = asciidoc
106 ASCIIDOC_EXTRA =
107 ASCIIDOC_HTML = xhtml11
108 ASCIIDOC_DOCBOOK = docbook
109 ASCIIDOC_CONF = -f asciidoc.conf
110 ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
111 -agit_version=$(GIT_VERSION)
112 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
113 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
114 MANPAGE_XSL = manpage-normal.xsl
115 XMLTO = xmlto
116 XMLTO_EXTRA =
117 INSTALL ?= install
118 RM ?= rm -f
119 MAN_REPO = ../../git-manpages
120 HTML_REPO = ../../git-htmldocs
121
122 MAKEINFO = makeinfo
123 INSTALL_INFO = install-info
124 DOCBOOK2X_TEXI = docbook2x-texi
125 DBLATEX = dblatex
126 ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
127 DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
128 ifndef PERL_PATH
129 PERL_PATH = /usr/bin/perl
130 endif
131
132 -include ../config.mak.autogen
133 -include ../config.mak
134
135 #
136 # For docbook-xsl ...
137 # -1.68.1, no extra settings are needed?
138 # 1.69.0, set ASCIIDOC_ROFF?
139 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
140 # 1.71.1, set ASCIIDOC_ROFF?
141 # 1.72.0, set DOCBOOK_XSL_172.
142 # 1.73.0-, no extra settings are needed
143 #
144
145 ifdef DOCBOOK_XSL_172
146 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
147 MANPAGE_XSL = manpage-1.72.xsl
148 else
149 ifndef ASCIIDOC_ROFF
150 # docbook-xsl after 1.72 needs the regular XSL, but will not
151 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
152 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
153 endif
154 endif
155 ifndef NO_MAN_BOLD_LITERAL
156 XMLTO_EXTRA += -m manpage-bold-literal.xsl
157 endif
158 ifdef DOCBOOK_SUPPRESS_SP
159 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
160 endif
161
162 # Newer DocBook stylesheet emits warning cruft in the output when
163 # this is not set, and if set it shows an absolute link. Older
164 # stylesheets simply ignore this parameter.
165 #
166 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
167 # or similar.
168 ifndef MAN_BASE_URL
169 MAN_BASE_URL = file://$(htmldir)/
170 endif
171 XMLTO_EXTRA += -m manpage-base-url.xsl
172
173 # If your target system uses GNU groff, it may try to render
174 # apostrophes as a "pretty" apostrophe using unicode. This breaks
175 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
176 # apostrophes. Unfortunately does not work with non-GNU roff.
177 ifdef GNU_ROFF
178 XMLTO_EXTRA += -m manpage-quote-apos.xsl
179 endif
180
181 ifdef USE_ASCIIDOCTOR
182 ASCIIDOC = asciidoctor
183 ASCIIDOC_CONF =
184 ASCIIDOC_HTML = xhtml5
185 ASCIIDOC_DOCBOOK = docbook45
186 ASCIIDOC_EXTRA += -acompat-mode
187 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
188 ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
189 DBLATEX_COMMON =
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 -include ../GIT-VERSION-FILE
277
278 #
279 # Determine "include::" file references in asciidoc files.
280 #
281 docdep_prereqs = \
282 mergetools-list.made $(mergetools_txt) \
283 cmd-list.made $(cmds_txt)
284
285 doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl
286 $(QUIET_GEN)$(RM) $@+ $@ && \
287 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
288 mv $@+ $@
289
290 -include doc.dep
291
292 cmds_txt = cmds-ancillaryinterrogators.txt \
293 cmds-ancillarymanipulators.txt \
294 cmds-mainporcelain.txt \
295 cmds-plumbinginterrogators.txt \
296 cmds-plumbingmanipulators.txt \
297 cmds-synchingrepositories.txt \
298 cmds-synchelpers.txt \
299 cmds-purehelpers.txt \
300 cmds-foreignscminterface.txt
301
302 $(cmds_txt): cmd-list.made
303
304 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
305 $(QUIET_GEN)$(RM) $@ && \
306 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
307 date >$@
308
309 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
310
311 $(mergetools_txt): mergetools-list.made
312
313 mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
314 $(QUIET_GEN)$(RM) $@ && \
315 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
316 . ../git-mergetool--lib.sh && \
317 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
318 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
319 . ../git-mergetool--lib.sh && \
320 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
321 date >$@
322
323 clean:
324 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
325 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
326 $(RM) *.pdf
327 $(RM) howto-index.txt howto/*.html doc.dep
328 $(RM) technical/*.html technical/api-index.txt
329 $(RM) SubmittingPatches.txt
330 $(RM) $(cmds_txt) $(mergetools_txt) *.made
331 $(RM) manpage-base-url.xsl
332
333 $(MAN_HTML): %.html : %.txt asciidoc.conf
334 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
335 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
336 mv $@+ $@
337
338 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
339 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
340 $(TXT_TO_HTML) -o $@+ $< && \
341 mv $@+ $@
342
343 manpage-base-url.xsl: manpage-base-url.xsl.in
344 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
345
346 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
347 $(QUIET_XMLTO)$(RM) $@ && \
348 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
349
350 %.xml : %.txt asciidoc.conf
351 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
352 $(TXT_TO_XML) -d manpage -o $@+ $< && \
353 mv $@+ $@
354
355 user-manual.xml: user-manual.txt user-manual.conf
356 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
357 $(TXT_TO_XML) -d book -o $@+ $< && \
358 mv $@+ $@
359
360 technical/api-index.txt: technical/api-index-skel.txt \
361 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
362 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
363
364 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
365 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
366 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
367
368 SubmittingPatches.txt: SubmittingPatches
369 $(QUIET_GEN) cp $< $@
370
371 XSLT = docbook.xsl
372 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
373
374 user-manual.html: user-manual.xml $(XSLT)
375 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
376 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
377 mv $@+ $@
378
379 git.info: user-manual.texi
380 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
381
382 user-manual.texi: user-manual.xml
383 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
384 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
385 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
386 rm $@++ && \
387 mv $@+ $@
388
389 user-manual.pdf: user-manual.xml
390 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
391 $(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
392 mv $@+ $@
393
394 gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
395 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
396 ($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
397 $(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
398 rm $(xml)+ &&) true) > $@++ && \
399 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
400 rm $@++ && \
401 mv $@+ $@
402
403 gitman.info: gitman.texi
404 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
405
406 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
407 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
408 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
409 mv $@+ $@
410
411 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
412 $(QUIET_GEN)$(RM) $@+ $@ && \
413 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
414 mv $@+ $@
415
416 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
417 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
418
419 WEBDOC_DEST = /pub/software/scm/git/docs
420
421 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
422 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
423 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
424 sed -e '1,/^$$/d' $< | \
425 $(TXT_TO_HTML) - >$@+ && \
426 mv $@+ $@
427
428 install-webdoc : html
429 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
430
431 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
432 # next to the 'git' repository itself for the following to work.
433
434 quick-install: quick-install-man
435
436 require-manrepo::
437 @if test ! -d $(MAN_REPO); \
438 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
439
440 quick-install-man: require-manrepo
441 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir) $(GIT_MAN_REF)
442
443 require-htmlrepo::
444 @if test ! -d $(HTML_REPO); \
445 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
446
447 quick-install-html: require-htmlrepo
448 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir) $(GIT_MAN_REF)
449
450 print-man1:
451 @for i in $(MAN1_TXT); do echo $$i; done
452
453 lint-docs::
454 $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl
455
456 .PHONY: FORCE