Merge branch 'bs/maint-rename-populate-filespec' into maint
[git] / Documentation / Makefile
1 MAN1_TXT= \
2         $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
3                 $(wildcard git-*.txt)) \
4         gitk.txt git.txt
5 MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \
6         gitrepository-layout.txt
7 MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \
8         gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \
9         gitdiffcore.txt gitworkflows.txt
10
11 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
12 MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
13 MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
14
15 DOC_HTML=$(MAN_HTML)
16
17 ARTICLES = howto-index
18 ARTICLES += everyday
19 ARTICLES += git-tools
20 # with their own formatting rules.
21 SP_ARTICLES = howto/revert-branch-rebase howto/using-merge-subtree user-manual
22 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
23 SP_ARTICLES += $(API_DOCS)
24 SP_ARTICLES += technical/api-index
25
26 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
27
28 DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
29 DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
30 DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
31
32 prefix?=$(HOME)
33 bindir?=$(prefix)/bin
34 htmldir?=$(prefix)/share/doc/git-doc
35 mandir?=$(prefix)/share/man
36 man1dir=$(mandir)/man1
37 man5dir=$(mandir)/man5
38 man7dir=$(mandir)/man7
39 # DESTDIR=
40
41 ASCIIDOC=asciidoc
42 ASCIIDOC_EXTRA =
43 MANPAGE_XSL = callouts.xsl
44 INSTALL?=install
45 RM ?= rm -f
46 DOC_REF = origin/man
47 HTML_REF = origin/html
48
49 infodir?=$(prefix)/share/info
50 MAKEINFO=makeinfo
51 INSTALL_INFO=install-info
52 DOCBOOK2X_TEXI=docbook2x-texi
53 ifndef PERL_PATH
54         PERL_PATH = /usr/bin/perl
55 endif
56
57 -include ../config.mak.autogen
58 -include ../config.mak
59
60 ifdef ASCIIDOC8
61 ASCIIDOC_EXTRA += -a asciidoc7compatible
62 endif
63 ifdef DOCBOOK_XSL_172
64 ASCIIDOC_EXTRA += -a docbook-xsl-172
65 MANPAGE_XSL = manpage-1.72.xsl
66 endif
67
68 #
69 # Please note that there is a minor bug in asciidoc.
70 # The version after 6.0.3 _will_ include the patch found here:
71 #   http://marc.theaimsgroup.com/?l=git&m=111558757202243&w=2
72 #
73 # Until that version is released you may have to apply the patch
74 # yourself - yes, all 6 characters of it!
75 #
76
77 all: html man
78
79 html: $(DOC_HTML)
80
81 $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
82
83 man: man1 man5 man7
84 man1: $(DOC_MAN1)
85 man5: $(DOC_MAN5)
86 man7: $(DOC_MAN7)
87
88 info: git.info gitman.info
89
90 install: install-man
91
92 install-man: man
93         $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
94         $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
95         $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
96         $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
97         $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
98         $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
99
100 install-info: info
101         $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
102         $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
103         if test -r $(DESTDIR)$(infodir)/dir; then \
104           $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
105           $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
106         else \
107           echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
108         fi
109
110 install-html: html
111         sh ./install-webdoc.sh $(DESTDIR)$(htmldir)
112
113 ../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
114         $(MAKE) -C ../ GIT-VERSION-FILE
115
116 -include ../GIT-VERSION-FILE
117
118 #
119 # Determine "include::" file references in asciidoc files.
120 #
121 doc.dep : $(wildcard *.txt) build-docdep.perl
122         $(RM) $@+ $@
123         $(PERL_PATH) ./build-docdep.perl >$@+
124         mv $@+ $@
125
126 -include doc.dep
127
128 cmds_txt = cmds-ancillaryinterrogators.txt \
129         cmds-ancillarymanipulators.txt \
130         cmds-mainporcelain.txt \
131         cmds-plumbinginterrogators.txt \
132         cmds-plumbingmanipulators.txt \
133         cmds-synchingrepositories.txt \
134         cmds-synchelpers.txt \
135         cmds-purehelpers.txt \
136         cmds-foreignscminterface.txt
137
138 $(cmds_txt): cmd-list.made
139
140 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
141         $(RM) $@
142         $(PERL_PATH) ./cmd-list.perl ../command-list.txt
143         date >$@
144
145 clean:
146         $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
147         $(RM) *.texi *.texi+ git.info gitman.info
148         $(RM) howto-index.txt howto/*.html doc.dep
149         $(RM) technical/api-*.html technical/api-index.txt
150         $(RM) $(cmds_txt) *.made
151
152 $(MAN_HTML): %.html : %.txt
153         $(RM) $@+ $@
154         $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
155                 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $<
156         mv $@+ $@
157
158 %.1 %.5 %.7 : %.xml
159         $(RM) $@
160         xmlto -m $(MANPAGE_XSL) man $<
161
162 %.xml : %.txt
163         $(RM) $@+ $@
164         $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
165                 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $<
166         mv $@+ $@
167
168 user-manual.xml: user-manual.txt user-manual.conf
169         $(ASCIIDOC) -b docbook -d book $<
170
171 technical/api-index.txt: technical/api-index-skel.txt \
172         technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
173         cd technical && sh ./api-index.sh
174
175 $(patsubst %,%.html,$(API_DOCS) technical/api-index): %.html : %.txt
176         $(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
177                 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
178
179 XSLT = docbook.xsl
180 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
181
182 user-manual.html: user-manual.xml
183         xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
184
185 git.info: user-manual.texi
186         $(MAKEINFO) --no-split -o $@ user-manual.texi
187
188 user-manual.texi: user-manual.xml
189         $(RM) $@+ $@
190         $(DOCBOOK2X_TEXI) user-manual.xml --to-stdout | $(PERL_PATH) fix-texi.perl >$@+
191         mv $@+ $@
192
193 gitman.texi: $(MAN_XML) cat-texi.perl
194         $(RM) $@+ $@
195         ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --to-stdout $(xml);)) | \
196         $(PERL_PATH) cat-texi.perl $@ >$@+
197         mv $@+ $@
198
199 gitman.info: gitman.texi
200         $(MAKEINFO) --no-split $*.texi
201
202 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
203         $(RM) $@+ $@
204         $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+
205         mv $@+ $@
206
207 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
208         $(RM) $@+ $@
209         sh ./howto-index.sh $(wildcard howto/*.txt) >$@+
210         mv $@+ $@
211
212 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
213         $(ASCIIDOC) -b xhtml11 $*.txt
214
215 WEBDOC_DEST = /pub/software/scm/git/docs
216
217 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
218         $(RM) $@+ $@
219         sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+
220         mv $@+ $@
221
222 install-webdoc : html
223         sh ./install-webdoc.sh $(WEBDOC_DEST)
224
225 quick-install: quick-install-man
226
227 quick-install-man:
228         sh ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
229
230 quick-install-html:
231         sh ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
232
233 .PHONY: .FORCE-GIT-VERSION-FILE