1# Makefile for Sphinx documentation
2
3# You can set these variables from the command line.
4SPHINXOPTS    = -W
5SPHINXBUILD   = DOC_NAME=$* sphinx-build
6PAPER         =
7BUILDDIR      = build
8SOURCEDIR     = .
9
10# Internal variables.
11PAPEROPT_a4     = -D latex_paper_size=a4
12PAPEROPT_letter = -D latex_paper_size=letter
13ALLSPHINXOPTS   = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) \
14		  -c $(SOURCEDIR)/share \
15		  -d $(BUILDDIR)/$*/doctrees \
16		  $(SOURCEDIR)
17DOC_LIST=gnat_rm gnat_ugn gnat-style
18FMT_LIST=html pdf txt info
19
20.PHONY: help clean
21
22help:
23	@echo "Please use \`make <target>' where <target> is one of"
24	@echo "  DOC_NAME.html       to make standalone HTML files"
25	@echo "  DOC_NAME.pdf        to make LaTeX files and run them through pdflatex"
26	@echo "  DOC_NAME.txt        to make text files"
27	@echo "  DOC_NAME.info       to make info files"
28	@echo "  DOC_NAME.texinfo    to make Texinfo files"
29	@echo "  DOC_NAME.all        to build DOC_NAME for all previous formats"
30	@echo "  all                 to build all documentations in all formats"
31	@echo "  html-all            same as previous rule but only for HTML format"
32	@echo "  pdf-all             same as previous rule but only for PDF format"
33	@echo "  txt-all             same as previous rule but only for text format"
34	@echo "  info-all            same as previous rule but only for info format"
35	@echo "  texinfo-all         same as previous rule but only for texinfo format"
36	@echo ""
37	@echo "DOC_NAME should be a documentation name in the following list:"
38	@echo "  $(DOC_LIST)"
39	@echo ""
40	@echo "source and location can be overridden using SOURCEDIR and BUILDDIR variables"
41
42clean:
43	-rm -rf $(BUILDDIR)
44
45.PHONY: mk_empty_dirs
46mk_empty_dirs:
47	mkdir -p share/_static
48
49%.html: mk_empty_dirs
50	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/$*/html
51
52%.pdf: mk_empty_dirs
53	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/$*/pdf
54	$(MAKE) -C $(BUILDDIR)/$*/pdf all-pdf LATEXOPTS="-interaction=nonstopmode"
55
56%.txt: mk_empty_dirs
57	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/$*/txt
58	$(MAKE) -C $(BUILDDIR)/$*/txt plaintext
59
60%.info: mk_empty_dirs
61	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/$*/info
62	$(MAKE) -C $(BUILDDIR)/$*/info info
63
64%.texinfo: mk_empty_dirs
65	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/$*/texinfo
66	sed -e 's/^@dircategory/@dircategory GNU Ada Tools/g' < $(BUILDDIR)/$*/texinfo/$*.texi > $(BUILDDIR)/../../$*.texi
67
68.PHONY: html-all
69html-all: $(foreach doc, $(DOC_LIST), $(doc).html)
70
71.PHONY: pdf-all
72pdf-all: $(foreach doc, $(DOC_LIST), $(doc).pdf)
73
74.PHONY: txt-all
75txt-all: $(foreach doc, $(DOC_LIST), $(doc).txt)
76
77.PHONY: info-all
78info-all: $(foreach doc, $(DOC_LIST), $(doc).info)
79
80.PHONY: texinfo-all
81texinfo-all: $(foreach doc, $(DOC_LIST), $(doc).texinfo)
82
83%.all:
84	$(MAKE) $(foreach fmt, $(FMT_LIST), $*.$(fmt))
85
86.PHONY: all
87all: $(foreach fmt, $(FMT_LIST), $(fmt)-all)
88