1############################################################################
2#                              Ada Web Server                              #
3#                                                                          #
4#                     Copyright (C) 2003-2016, AdaCore                     #
5#                                                                          #
6#  This is free software;  you can redistribute it  and/or modify it       #
7#  under terms of the  GNU General Public License as published  by the     #
8#  Free Software  Foundation;  either version 3,  or (at your option) any  #
9#  later version.  This software is distributed in the hope  that it will  #
10#  be useful, but WITHOUT ANY WARRANTY;  without even the implied warranty #
11#  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU     #
12#  General Public License for  more details.                               #
13#                                                                          #
14#  You should have  received  a copy of the GNU General  Public  License   #
15#  distributed  with  this  software;   see  file COPYING3.  If not, go    #
16#  to http://www.gnu.org/licenses for a complete copy of the license.      #
17############################################################################
18
19# Makefile for Sphinx documentation
20#
21
22# default value if this Makefile is called directly on not from above
23# Makefile.
24
25GPRBUILD  := gprbuild
26PRJ_BUILD := Release
27
28-include ../makefile.setup
29
30TMPLDIR  := src
31ADBDIR   := src
32EXEDIR   := build/bin/$(SDIR)/static
33RESDIR   := build/samples
34ADBFILES := $(wildcard $(ADBDIR)/*.adb)
35EXEFILES := $(patsubst $(ADBDIR)/%.adb,%,$(ADBFILES))
36RESFILES := $(foreach e,$(EXEFILES),$(RESDIR)/$(e).adb.res)
37
38# You can set these variables from the command line.
39SPHINXOPTS    =
40SPHINXBUILD   = sphinx-build
41PAPER         =
42BUILDDIR      = build
43
44# Internal variables.
45PAPEROPT_a4     = -D latex_paper_size=a4
46PAPEROPT_letter = -D latex_paper_size=letter
47ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
48# the i18n builder cannot share the environment and doctrees with the others
49I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
50
51.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
52
53help:
54	@echo "Please use \`make <target>' where <target> is one of"
55	@echo "  html       to make standalone HTML files"
56	@echo "  dirhtml    to make HTML files named index.html in directories"
57	@echo "  singlehtml to make a single large HTML file"
58	@echo "  pickle     to make pickle files"
59	@echo "  json       to make JSON files"
60	@echo "  htmlhelp   to make HTML files and a HTML help project"
61	@echo "  qthelp     to make HTML files and a qthelp project"
62	@echo "  devhelp    to make HTML files and a Devhelp project"
63	@echo "  epub       to make an epub"
64	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
65	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
66	@echo "  text       to make text files"
67	@echo "  man        to make manual pages"
68	@echo "  texinfo    to make Texinfo files"
69	@echo "  info       to make Texinfo files and run them through makeinfo"
70	@echo "  gettext    to make PO message catalogs"
71	@echo "  changes    to make an overview of all changed/added/deprecated items"
72	@echo "  linkcheck  to check all external links for integrity"
73	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
74
75clean:
76	-rm -rf $(BUILDDIR)
77	rm -f *.pyc
78
79# All documentations require the generated examples.
80html dirhtml singlehtml pickle json htmlhelp qthelp latex latexpdf text man texinfo info: $(RESFILES)
81
82$(RESFILES): $(RESDIR)/%.adb.res: build-sample | $(RESDIR)
83	( cd $(TMPLDIR) && ../$(EXEDIR)/$* ) > $@
84
85$(RESDIR):
86	mkdir $@
87
88.PHONY: build-sample
89build-sample:
90	$(GPRBUILD) -p -m -Pdocs $(EXEFILES) \
91	  --subdirs=$(SDIR)/static \
92	  $(foreach v,PRJ_BUILD TARGET VERSION,"-X$(v)=$($(v))")
93
94# Executable and result will be removed with BUILDDIR.
95
96html:
97	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
98	@echo
99	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
100
101dirhtml:
102	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
103	@echo
104	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
105
106singlehtml:
107	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
108	@echo
109	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
110
111pickle:
112	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
113	@echo
114	@echo "Build finished; now you can process the pickle files."
115
116json:
117	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
118	@echo
119	@echo "Build finished; now you can process the JSON files."
120
121htmlhelp:
122	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
123	@echo
124	@echo "Build finished; now you can run HTML Help Workshop with the" \
125	      ".hhp project file in $(BUILDDIR)/htmlhelp."
126
127qthelp:
128	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
129	@echo
130	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
131	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
132	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Templates_Parser.qhcp"
133	@echo "To view the help file:"
134	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Templates_Parser.qhc"
135
136devhelp:
137	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
138	@echo
139	@echo "Build finished."
140	@echo "To view the help file:"
141	@echo "# mkdir -p $$HOME/.local/share/devhelp/Templates_Parser"
142	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Templates_Parser"
143	@echo "# devhelp"
144
145epub:
146	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
147	@echo
148	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
149
150latex:
151	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
152	@echo
153	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
154	@echo "Run \`make' in that directory to run these through (pdf)latex" \
155	      "(use \`make latexpdf' here to do that automatically)."
156
157latexpdf:
158	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
159	@echo "Running LaTeX files through pdflatex..."
160	$(MAKE) -C $(BUILDDIR)/latex all-pdf \
161		LATEXOPTS="-interaction=nonstopmode"
162	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
163
164text:
165	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
166	@echo
167	@echo "Build finished. The text files are in $(BUILDDIR)/text."
168
169man:
170	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
171	@echo
172	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
173
174texinfo:
175	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
176	@echo
177	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
178	@echo "Run \`make' in that directory to run these through makeinfo" \
179	      "(use \`make info' here to do that automatically)."
180
181info:
182	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
183	@echo "Running Texinfo files through makeinfo..."
184	make -C $(BUILDDIR)/texinfo info
185	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
186
187gettext:
188	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
189	@echo
190	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
191
192changes:
193	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
194	@echo
195	@echo "The overview file is in $(BUILDDIR)/changes."
196
197linkcheck:
198	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
199	@echo
200	@echo "Link check complete; look for any errors in the above output " \
201	      "or in $(BUILDDIR)/linkcheck/output.txt."
202
203doctest:
204	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
205	@echo "Testing of doctests in the sources finished, look at the " \
206	      "results in $(BUILDDIR)/doctest/output.txt."
207