Documentation/howto: convert plain text files to asciidoc
[git/git.git] / Documentation / Makefile
CommitLineData
4a5d6939
MW
1MAN1_TXT= \
2 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
3 $(wildcard git-*.txt)) \
07ea4df2 4 gitk.txt gitweb.txt git.txt
30eba7bf 5MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \
6d3902b0 6 gitrepository-layout.txt gitweb.conf.txt
9e1f0a85 7MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \
30eba7bf 8 gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \
d49483f0 9 gitdiffcore.txt gitnamespaces.txt gitrevisions.txt gitworkflows.txt
a6fc9fd3 10MAN7_TXT += gitcredentials.txt
b790abb8 11
5cefc33b
JH
12MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
13MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
14MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
15
16DOC_HTML=$(MAN_HTML)
8db9307c 17
30eba7bf 18ARTICLES = howto-index
db9536c8 19ARTICLES += everyday
4a5d6939 20ARTICLES += git-tools
69a9cd31 21ARTICLES += git-bisect-lk2009
8db9307c 22# with their own formatting rules.
11b17afc
JH
23SP_ARTICLES = user-manual
24SP_ARTICLES += howto/revert-branch-rebase
25SP_ARTICLES += howto/using-merge-subtree
26SP_ARTICLES += howto/using-signed-tag-in-pull-request
530e741c
JH
27API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
28SP_ARTICLES += $(API_DOCS)
29SP_ARTICLES += technical/api-index
8db9307c
JH
30
31DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
789d5774 32
b2bf34d6 33DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
2d76548b 34DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
b2bf34d6
DG
35DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
36
d2b8593f 37prefix?=$(HOME)
e14421b9 38bindir?=$(prefix)/bin
5d6491c7 39htmldir?=$(prefix)/share/doc/git-doc
a325a1a7 40pdfdir?=$(prefix)/share/doc/git-doc
45fd8bd3 41mandir?=$(prefix)/share/man
7b8cf0cf 42man1dir=$(mandir)/man1
4392da4d 43man5dir=$(mandir)/man5
7b8cf0cf 44man7dir=$(mandir)/man7
a682ef9f 45# DESTDIR=
87a81c83 46
dd4f3075 47ASCIIDOC = asciidoc
26cfcfbf 48ASCIIDOC_EXTRA =
c30e9485 49MANPAGE_XSL = manpage-normal.xsl
dd4f3075 50XMLTO = xmlto
5121a6d9 51XMLTO_EXTRA =
d2b8593f 52INSTALL?=install
4cb08df5 53RM ?= rm -f
fcbebfdd
JH
54MAN_REPO = ../../git-manpages
55HTML_REPO = ../../git-htmldocs
87a81c83 56
4739809c
DK
57infodir?=$(prefix)/share/info
58MAKEINFO=makeinfo
59INSTALL_INFO=install-info
60DOCBOOK2X_TEXI=docbook2x-texi
a325a1a7 61DBLATEX=dblatex
c680dd83
JH
62ifndef PERL_PATH
63 PERL_PATH = /usr/bin/perl
64endif
4739809c 65
95676853 66-include ../config.mak.autogen
4fa96e15 67-include ../config.mak
95676853 68
8fa2b45f
CJ
69#
70# For docbook-xsl ...
79c461d5
JK
71# -1.68.1, no extra settings are needed?
72# 1.69.0, set ASCIIDOC_ROFF?
2346431e 73# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
79c461d5 74# 1.71.1, set ASCIIDOC_ROFF?
8fa2b45f 75# 1.72.0, set DOCBOOK_XSL_172.
79c461d5 76# 1.73.0-, no extra settings are needed
8fa2b45f
CJ
77#
78
7f55cf45 79ifdef DOCBOOK_XSL_172
8fa2b45f 80ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
7a2078b4 81MANPAGE_XSL = manpage-1.72.xsl
8fa2b45f 82else
79c461d5 83 ifndef ASCIIDOC_ROFF
8fa2b45f
CJ
84 # docbook-xsl after 1.72 needs the regular XSL, but will not
85 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
86 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
87 endif
7f55cf45 88endif
5121a6d9
CJ
89ifdef MAN_BOLD_LITERAL
90XMLTO_EXTRA += -m manpage-bold-literal.xsl
91endif
2346431e
CJ
92ifdef DOCBOOK_SUPPRESS_SP
93XMLTO_EXTRA += -m manpage-suppress-sp.xsl
94endif
7f55cf45 95
8dd35c71 96# Newer DocBook stylesheet emits warning cruft in the output when
50d9bbba
TZ
97# this is not set, and if set it shows an absolute link. Older
98# stylesheets simply ignore this parameter.
59a0a0bd 99#
50d9bbba
TZ
100# Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
101# or similar.
102ifndef MAN_BASE_URL
103MAN_BASE_URL = file://$(htmldir)/
59a0a0bd 104endif
50d9bbba 105XMLTO_EXTRA += -m manpage-base-url.xsl
a479a564 106
204d363f
TR
107# If your target system uses GNU groff, it may try to render
108# apostrophes as a "pretty" apostrophe using unicode. This breaks
109# cut&paste, so you should set GNU_ROFF to force them to be ASCII
110# apostrophes. Unfortunately does not work with non-GNU roff.
111ifdef GNU_ROFF
112XMLTO_EXTRA += -m manpage-quote-apos.xsl
113endif
114
ee7ec2f9
BW
115SHELL_PATH ?= $(SHELL)
116# Shell quote;
117SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
118
5b58619a
JN
119ifdef DEFAULT_PAGER
120DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
121ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
122endif
123
124ifdef DEFAULT_EDITOR
125DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
126ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
127endif
128
bb230097
CJ
129QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
130QUIET_SUBDIR1 =
131
132ifneq ($(findstring $(MAKEFLAGS),w),w)
133PRINT_DIR = --no-print-directory
134else # "make -w"
135NO_SUBDIR = :
136endif
137
138ifneq ($(findstring $(MAKEFLAGS),s),s)
139ifndef V
140 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
141 QUIET_XMLTO = @echo ' ' XMLTO $@;
142 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
143 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
144 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
145 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
146 QUIET_GEN = @echo ' ' GEN $@;
147 QUIET_STDERR = 2> /dev/null
148 QUIET_SUBDIR0 = +@subdir=
149 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
150 $(MAKE) $(PRINT_DIR) -C $$subdir
151 export V
152endif
153endif
154
b2bf34d6 155all: html man
b790abb8
DG
156
157html: $(DOC_HTML)
158
4392da4d 159$(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
b2bf34d6 160
4392da4d 161man: man1 man5 man7
b2bf34d6 162man1: $(DOC_MAN1)
4392da4d 163man5: $(DOC_MAN5)
b2bf34d6 164man7: $(DOC_MAN7)
b790abb8 165
5cefc33b 166info: git.info gitman.info
4739809c 167
a325a1a7
MV
168pdf: user-manual.pdf
169
b1a46b70
MH
170install: install-man
171
172install-man: man
41650765
RS
173 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
174 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
175 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
176 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
177 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
178 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
87a81c83 179
4739809c 180install-info: info
41650765 181 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
5cefc33b 182 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
4739809c
DK
183 if test -r $(DESTDIR)$(infodir)/dir; then \
184 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
5cefc33b 185 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
4739809c
DK
186 else \
187 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
188 fi
37465016 189
a325a1a7
MV
190install-pdf: pdf
191 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
192 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
193
5d6491c7 194install-html: html
ee7ec2f9 195 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
5d6491c7 196
13fca9f3 197../GIT-VERSION-FILE: FORCE
bb230097 198 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
7b8a74f3
FL
199
200-include ../GIT-VERSION-FILE
201
93d69d86
JL
202#
203# Determine "include::" file references in asciidoc files.
204#
fb612d54 205doc.dep : $(wildcard *.txt) build-docdep.perl
bb230097
CJ
206 $(QUIET_GEN)$(RM) $@+ $@ && \
207 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
a5ae8e64 208 mv $@+ $@
93d69d86 209
a5ae8e64 210-include doc.dep
37465016 211
72fe6a59
JH
212cmds_txt = cmds-ancillaryinterrogators.txt \
213 cmds-ancillarymanipulators.txt \
214 cmds-mainporcelain.txt \
215 cmds-plumbinginterrogators.txt \
216 cmds-plumbingmanipulators.txt \
89bf2077
JH
217 cmds-synchingrepositories.txt \
218 cmds-synchelpers.txt \
219 cmds-purehelpers.txt \
220 cmds-foreignscminterface.txt
72fe6a59 221
d7907392
JH
222$(cmds_txt): cmd-list.made
223
79d30668 224cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
bb230097
CJ
225 $(QUIET_GEN)$(RM) $@ && \
226 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
d7907392 227 date >$@
b790abb8
DG
228
229clean:
4c785e50 230 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
c6a5ad21 231 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
ae8044a2 232 $(RM) *.pdf
530e741c
JH
233 $(RM) howto-index.txt howto/*.html doc.dep
234 $(RM) technical/api-*.html technical/api-index.txt
4cb08df5 235 $(RM) $(cmds_txt) *.made
50d9bbba 236 $(RM) manpage-base-url.xsl
b790abb8 237
530e741c 238$(MAN_HTML): %.html : %.txt
bb230097 239 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
7b8a74f3 240 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
bb230097 241 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
7b8a74f3 242 mv $@+ $@
b790abb8 243
50d9bbba
TZ
244manpage-base-url.xsl: manpage-base-url.xsl.in
245 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
246
247%.1 %.5 %.7 : %.xml manpage-base-url.xsl
bb230097 248 $(QUIET_XMLTO)$(RM) $@ && \
dd4f3075 249 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
b790abb8
DG
250
251%.xml : %.txt
bb230097 252 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
7b8a74f3 253 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
bb230097 254 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
7b8a74f3 255 mv $@+ $@
3f971fc4 256
d19fbc3c 257user-manual.xml: user-manual.txt user-manual.conf
f9dae0d3
JN
258 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
259 $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book -o $@+ $< && \
260 mv $@+ $@
d19fbc3c 261
530e741c
JH
262technical/api-index.txt: technical/api-index-skel.txt \
263 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
ee7ec2f9 264 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
530e741c 265
fe77b416 266technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
530e741c 267$(patsubst %,%.html,$(API_DOCS) technical/api-index): %.html : %.txt
bb230097 268 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
530e741c
JH
269 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
270
1cffddd6 271XSLT = docbook.xsl
0a3985dc 272XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
1c95c565 273
f2aff316 274user-manual.html: user-manual.xml $(XSLT)
f9dae0d3
JN
275 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
276 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
277 mv $@+ $@
d19fbc3c 278
50b3555c 279git.info: user-manual.texi
bb230097 280 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
5cefc33b 281
50b3555c 282user-manual.texi: user-manual.xml
bb230097 283 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
c6a5ad21
CJ
284 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
285 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
286 rm $@++ && \
5cefc33b
JH
287 mv $@+ $@
288
a325a1a7 289user-manual.pdf: user-manual.xml
bb230097
CJ
290 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
291 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
a325a1a7
MV
292 mv $@+ $@
293
5cefc33b 294gitman.texi: $(MAN_XML) cat-texi.perl
bb230097 295 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
8b30ad01 296 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
c6a5ad21
CJ
297 --to-stdout $(xml) &&) true) > $@++ && \
298 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
299 rm $@++ && \
5cefc33b
JH
300 mv $@+ $@
301
302gitman.info: gitman.texi
bb230097 303 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
5cefc33b
JH
304
305$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
bb230097
CJ
306 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
307 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
5cefc33b 308 mv $@+ $@
4739809c 309
e6fc2346 310howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
bb230097 311 $(QUIET_GEN)$(RM) $@+ $@ && \
ee7ec2f9 312 '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
e6fc2346
JH
313 mv $@+ $@
314
8db9307c 315$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
26e47f25 316 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt
e6fc2346
JH
317
318WEBDOC_DEST = /pub/software/scm/git/docs
319
fe77b416 320howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
8d0991d7 321$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
bb230097 322 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
26e47f25 323 sed -e '1,/^$$/d' $< | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - >$@+ && \
8d0991d7
JH
324 mv $@+ $@
325
e6fc2346 326install-webdoc : html
ee7ec2f9 327 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
6538d1ef 328
fcbebfdd
JH
329# You must have a clone of git-htmldocs and git-manpages repositories
330# next to the git repository itself for the following to work.
331
b1a46b70
MH
332quick-install: quick-install-man
333
fcbebfdd
JH
334require-manrepo::
335 @if test ! -d $(MAN_REPO); \
336 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
337
338quick-install-man: require-manrepo
339 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
340
341require-htmlrepo::
342 @if test ! -d $(HTML_REPO); \
343 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
7b8a74f3 344
fcbebfdd
JH
345quick-install-html: require-htmlrepo
346 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
6fe570de 347
5fafce0b
JK
348print-man1:
349 @for i in $(MAN1_TXT); do echo $$i; done
350
13fca9f3 351.PHONY: FORCE