Documentation: make AsciiDoc links always point to HTML files
[alt-git.git] / Documentation / Makefile
blob0cfdc36b44ee51d827136c2bdd75c3d977f03742
1 # Guard against environment variables
2 MAN1_TXT =
3 MAN5_TXT =
4 MAN7_TXT =
6 MAN1_TXT += $(filter-out \
7 $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
8 $(wildcard git-*.txt))
9 MAN1_TXT += git.txt
10 MAN1_TXT += gitk.txt
11 MAN1_TXT += gitremote-helpers.txt
12 MAN1_TXT += gitweb.txt
14 MAN5_TXT += gitattributes.txt
15 MAN5_TXT += githooks.txt
16 MAN5_TXT += gitignore.txt
17 MAN5_TXT += gitmodules.txt
18 MAN5_TXT += gitrepository-layout.txt
19 MAN5_TXT += gitweb.conf.txt
21 MAN7_TXT += gitcli.txt
22 MAN7_TXT += gitcore-tutorial.txt
23 MAN7_TXT += gitcredentials.txt
24 MAN7_TXT += gitcvs-migration.txt
25 MAN7_TXT += gitdiffcore.txt
26 MAN7_TXT += gitglossary.txt
27 MAN7_TXT += gitnamespaces.txt
28 MAN7_TXT += gitrevisions.txt
29 MAN7_TXT += gittutorial-2.txt
30 MAN7_TXT += gittutorial.txt
31 MAN7_TXT += gitworkflows.txt
33 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
34 MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
35 MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
37 OBSOLETE_HTML = git-remote-helpers.html
38 DOC_HTML = $(MAN_HTML) $(OBSOLETE_HTML)
40 ARTICLES = howto-index
41 ARTICLES += everyday
42 ARTICLES += git-tools
43 ARTICLES += git-bisect-lk2009
44 # with their own formatting rules.
45 SP_ARTICLES = user-manual
46 SP_ARTICLES += howto/new-command
47 SP_ARTICLES += howto/revert-branch-rebase
48 SP_ARTICLES += howto/using-merge-subtree
49 SP_ARTICLES += howto/using-signed-tag-in-pull-request
50 SP_ARTICLES += howto/use-git-daemon
51 SP_ARTICLES += howto/update-hook-example
52 SP_ARTICLES += howto/setup-git-server-over-http
53 SP_ARTICLES += howto/separating-topic-branches
54 SP_ARTICLES += howto/revert-a-faulty-merge
55 SP_ARTICLES += howto/recover-corrupted-blob-object
56 SP_ARTICLES += howto/rebuild-from-update-hook
57 SP_ARTICLES += howto/rebase-from-internal-branch
58 SP_ARTICLES += howto/maintain-git
59 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
60 SP_ARTICLES += $(API_DOCS)
62 TECH_DOCS = technical/index-format
63 TECH_DOCS += technical/pack-format
64 TECH_DOCS += technical/pack-heuristics
65 TECH_DOCS += technical/pack-protocol
66 TECH_DOCS += technical/protocol-capabilities
67 TECH_DOCS += technical/protocol-common
68 TECH_DOCS += technical/racy-git
69 TECH_DOCS += technical/send-pack-pipeline
70 TECH_DOCS += technical/shallow
71 TECH_DOCS += technical/trivial-merge
72 SP_ARTICLES += $(TECH_DOCS)
73 SP_ARTICLES += technical/api-index
75 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
77 DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
78 DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
79 DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
81 prefix ?= $(HOME)
82 bindir ?= $(prefix)/bin
83 htmldir ?= $(prefix)/share/doc/git-doc
84 infodir ?= $(prefix)/share/info
85 pdfdir ?= $(prefix)/share/doc/git-doc
86 mandir ?= $(prefix)/share/man
87 man1dir = $(mandir)/man1
88 man5dir = $(mandir)/man5
89 man7dir = $(mandir)/man7
90 # DESTDIR =
92 ASCIIDOC = asciidoc
93 ASCIIDOC_EXTRA =
94 MANPAGE_XSL = manpage-normal.xsl
95 XMLTO = xmlto
96 XMLTO_EXTRA =
97 INSTALL ?= install
98 RM ?= rm -f
99 MAN_REPO = ../../git-manpages
100 HTML_REPO = ../../git-htmldocs
102 MAKEINFO = makeinfo
103 INSTALL_INFO = install-info
104 DOCBOOK2X_TEXI = docbook2x-texi
105 DBLATEX = dblatex
106 ifndef PERL_PATH
107 PERL_PATH = /usr/bin/perl
108 endif
110 -include ../config.mak.autogen
111 -include ../config.mak
114 # For docbook-xsl ...
115 # -1.68.1, no extra settings are needed?
116 # 1.69.0, set ASCIIDOC_ROFF?
117 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
118 # 1.71.1, set ASCIIDOC_ROFF?
119 # 1.72.0, set DOCBOOK_XSL_172.
120 # 1.73.0-, no extra settings are needed
123 ifdef DOCBOOK_XSL_172
124 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
125 MANPAGE_XSL = manpage-1.72.xsl
126 else
127 ifndef ASCIIDOC_ROFF
128 # docbook-xsl after 1.72 needs the regular XSL, but will not
129 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
130 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
131 endif
132 endif
133 ifdef MAN_BOLD_LITERAL
134 XMLTO_EXTRA += -m manpage-bold-literal.xsl
135 endif
136 ifdef DOCBOOK_SUPPRESS_SP
137 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
138 endif
140 # Newer DocBook stylesheet emits warning cruft in the output when
141 # this is not set, and if set it shows an absolute link. Older
142 # stylesheets simply ignore this parameter.
144 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
145 # or similar.
146 ifndef MAN_BASE_URL
147 MAN_BASE_URL = file://$(htmldir)/
148 endif
149 XMLTO_EXTRA += -m manpage-base-url.xsl
151 # If your target system uses GNU groff, it may try to render
152 # apostrophes as a "pretty" apostrophe using unicode. This breaks
153 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
154 # apostrophes. Unfortunately does not work with non-GNU roff.
155 ifdef GNU_ROFF
156 XMLTO_EXTRA += -m manpage-quote-apos.xsl
157 endif
159 SHELL_PATH ?= $(SHELL)
160 # Shell quote;
161 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
163 ifdef DEFAULT_PAGER
164 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
165 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
166 endif
168 ifdef DEFAULT_EDITOR
169 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
170 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
171 endif
173 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
174 QUIET_SUBDIR1 =
176 ifneq ($(findstring $(MAKEFLAGS),w),w)
177 PRINT_DIR = --no-print-directory
178 else # "make -w"
179 NO_SUBDIR = :
180 endif
182 ifneq ($(findstring $(MAKEFLAGS),s),s)
183 ifndef V
184 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
185 QUIET_XMLTO = @echo ' ' XMLTO $@;
186 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
187 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
188 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
189 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
190 QUIET_GEN = @echo ' ' GEN $@;
191 QUIET_STDERR = 2> /dev/null
192 QUIET_SUBDIR0 = +@subdir=
193 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
194 $(MAKE) $(PRINT_DIR) -C $$subdir
195 export V
196 endif
197 endif
199 all: html man
201 html: $(DOC_HTML)
203 man: man1 man5 man7
204 man1: $(DOC_MAN1)
205 man5: $(DOC_MAN5)
206 man7: $(DOC_MAN7)
208 info: git.info gitman.info
210 pdf: user-manual.pdf
212 install: install-man
214 install-man: man
215 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
216 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
217 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
218 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
219 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
220 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
222 install-info: info
223 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
224 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
225 if test -r $(DESTDIR)$(infodir)/dir; then \
226 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
227 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
228 else \
229 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
232 install-pdf: pdf
233 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
234 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
236 install-html: html
237 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
239 ../GIT-VERSION-FILE: FORCE
240 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
242 -include ../GIT-VERSION-FILE
245 # Determine "include::" file references in asciidoc files.
247 docdep_prereqs = \
248 mergetools-list.made $(mergetools_txt) \
249 cmd-list.made $(cmds_txt)
251 doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl
252 $(QUIET_GEN)$(RM) $@+ $@ && \
253 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
254 mv $@+ $@
256 -include doc.dep
258 cmds_txt = cmds-ancillaryinterrogators.txt \
259 cmds-ancillarymanipulators.txt \
260 cmds-mainporcelain.txt \
261 cmds-plumbinginterrogators.txt \
262 cmds-plumbingmanipulators.txt \
263 cmds-synchingrepositories.txt \
264 cmds-synchelpers.txt \
265 cmds-purehelpers.txt \
266 cmds-foreignscminterface.txt
268 $(cmds_txt): cmd-list.made
270 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
271 $(QUIET_GEN)$(RM) $@ && \
272 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
273 date >$@
275 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
277 $(mergetools_txt): mergetools-list.made
279 mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
280 $(QUIET_GEN)$(RM) $@ && \
281 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
282 . ../git-mergetool--lib.sh && \
283 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
284 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
285 . ../git-mergetool--lib.sh && \
286 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
287 date >$@
289 clean:
290 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
291 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
292 $(RM) *.pdf
293 $(RM) howto-index.txt howto/*.html doc.dep
294 $(RM) technical/*.html technical/api-index.txt
295 $(RM) $(cmds_txt) $(mergetools_txt) *.made
296 $(RM) manpage-base-url.xsl
298 $(MAN_HTML): %.html : %.txt asciidoc.conf
299 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
300 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
301 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
302 mv $@+ $@
304 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
305 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
306 $(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
307 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
308 mv $@+ $@
310 manpage-base-url.xsl: manpage-base-url.xsl.in
311 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
313 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
314 $(QUIET_XMLTO)$(RM) $@ && \
315 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
317 %.xml : %.txt asciidoc.conf
318 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
319 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
320 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
321 mv $@+ $@
323 user-manual.xml: user-manual.txt user-manual.conf
324 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
325 $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book -o $@+ $< && \
326 mv $@+ $@
328 technical/api-index.txt: technical/api-index-skel.txt \
329 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
330 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
332 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
333 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
334 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
335 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
337 XSLT = docbook.xsl
338 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
340 user-manual.html: user-manual.xml $(XSLT)
341 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
342 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
343 mv $@+ $@
345 git.info: user-manual.texi
346 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
348 user-manual.texi: user-manual.xml
349 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
350 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
351 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
352 rm $@++ && \
353 mv $@+ $@
355 user-manual.pdf: user-manual.xml
356 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
357 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
358 mv $@+ $@
360 gitman.texi: $(MAN_XML) cat-texi.perl
361 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
362 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
363 --to-stdout $(xml) &&) true) > $@++ && \
364 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
365 rm $@++ && \
366 mv $@+ $@
368 gitman.info: gitman.texi
369 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
371 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
372 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
373 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
374 mv $@+ $@
376 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
377 $(QUIET_GEN)$(RM) $@+ $@ && \
378 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
379 mv $@+ $@
381 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
382 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt
384 WEBDOC_DEST = /pub/software/scm/git/docs
386 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
387 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
388 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
389 sed -e '1,/^$$/d' $< | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - >$@+ && \
390 mv $@+ $@
392 install-webdoc : html
393 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
395 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
396 # next to the 'git' repository itself for the following to work.
398 quick-install: quick-install-man
400 require-manrepo::
401 @if test ! -d $(MAN_REPO); \
402 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
404 quick-install-man: require-manrepo
405 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
407 require-htmlrepo::
408 @if test ! -d $(HTML_REPO); \
409 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
411 quick-install-html: require-htmlrepo
412 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
414 print-man1:
415 @for i in $(MAN1_TXT); do echo $$i; done
417 .PHONY: FORCE