1mydir=doc
2BUILDTOP=$(REL)..
3
4SPHINX_ARGS=@MAINT@-W
5SPHINX_BUILD=sphinx-build $(SPHINX_ARGS)
6DOXYGEN=doxygen
7
8docsrc=$(top_srcdir)/../doc
9localstatedir=@localstatedir@
10runstatedir=@runstatedir@
11sysconfdir=@sysconfdir@
12DEFCCNAME=@DEFCCNAME@
13DEFKTNAME=@DEFKTNAME@
14DEFCKTNAME=@DEFCKTNAME@
15
16RST_SOURCES= _static \
17	_templates \
18	conf.py \
19	index.rst \
20	admin \
21	appdev \
22	basic \
23	build \
24	formats \
25	plugindev \
26	user \
27	about.rst \
28	build_this.rst \
29	copyright.rst \
30	mitK5defaults.rst \
31	mitK5features.rst \
32	mitK5license.rst \
33	notice.rst \
34	resources.rst
35
36PDFDIR=$(docsrc)/pdf
37PDFDOCS= admin appdev basic build plugindev user
38LATEXOPTS=
39
40# Create HTML documentation in $(docsrc)/html suitable for a
41# release tarball or the web site (that is, without substitutions for
42# configured paths).  This can be done in an unconfigured source tree
43# as:
44#     make -f Makefile.in SPHINX_ARGS= htmlsrc
45html: composite
46	rm -rf $(docsrc)/html
47	$(SPHINX_BUILD) -q rst_composite $(docsrc)/html
48
49# Dummy target for use in an unconfigured source tree.
50htmlsrc:
51	$(MAKE) -f Makefile.in srcdir=. top_srcdir=.. PYTHON=python3 html clean
52
53# Create HTML documentation in html_subst suitable for
54# installation by an OS package, with substitutions for configured
55# paths.
56substhtml: composite paths.py
57	rm -rf html_subst
58	cp paths.py rst_composite
59	$(SPHINX_BUILD) -t pathsubs -q rst_composite html_subst
60
61# Create an ASCII (okay, UTF-8) version of the NOTICE file
62notice.txt: $(docsrc)/conf.py $(docsrc)/notice.rst $(docsrc)/version.py
63	$(SPHINX_BUILD) -b text -t notice -q $(docsrc) .
64
65NOTICE: notice.txt
66	cp notice.txt $(top_srcdir)/../NOTICE
67
68$(PDFDIR): composite
69	$(SPHINX_BUILD) -b latex -q rst_composite $(PDFDIR)
70	# sphinx-build generates a gmake-specific Makefile that we don't use
71	mv $(PDFDIR)/Makefile $(PDFDIR)/GMakefile
72
73# Not pretty.  Can't use a suffix rule .tex.pdf without a Makefile in
74# $(PDFDIR) because pdflatex looks for include files in the current
75# working directory.  The sphinx-build Makefile is quite conservative
76# and runs pdflatex five times; we can be slightly less conservative.
77pdf: $(PDFDIR)
78	(cd $(PDFDIR) && \
79	 for i in $(PDFDOCS); do \
80		texfile=`echo $${i}.tex` && \
81		idxfile=`echo $${i}.idx` && \
82		pdflatex $(LATEXOPTS) $$texfile && \
83		pdflatex $(LATEXOPTS) $$texfile && \
84		makeindex -s python.ist $$idxfile || true; \
85		pdflatex $(LATEXOPTS) $$texfile && \
86		pdflatex $(LATEXOPTS) $$texfile; done && \
87	 rm -f *.dvi *.log *.ind *.aux *.toc *.syn *.idx *.out *.ilg *.pla \
88	)
89
90# Use doxygen to generate API documentation, translate it into RST
91# format, and then create a composite of $(docsrc)'s RST and the
92# generated files in rst_composite.  Used by the html and substhtml targets.
93composite: Doxyfile $(docsrc)/version.py
94	rm -rf doxy rst_apiref rst_composite
95	$(DOXYGEN)
96	(cwd=`pwd`; cd $(docsrc)/tools && \
97		$(PYTHON) doxy.py -i $$cwd/doxy/xml -o $$cwd/rst_apiref)
98	mkdir -p rst_composite
99	do_subdirs="$(RST_SOURCES)" ; \
100	for i in $$do_subdirs; do \
101		cp -r $(docsrc)/$$i rst_composite; \
102	done
103	cp rst_apiref/*.rst rst_composite/appdev/refs/api
104	cp rst_apiref/types/*.rst rst_composite/appdev/refs/types
105	cp rst_apiref/macros/*.rst rst_composite/appdev/refs/macros
106	cp $(docsrc)/version.py rst_composite
107
108Doxyfile: $(srcdir)/Doxyfile.in
109	sed -e 's|@SRC@|$(top_srcdir)|g' \
110	    -e 's|@DOC@|$(top_srcdir)/../doc|g' $(srcdir)/Doxyfile.in > $@
111
112paths.py:
113	rm -f $@
114	echo 'bindir = "``$(CLIENT_BINDIR)``"' > $@
115	echo 'sbindir = "``$(SERVER_BINDIR)``"' >> $@
116	echo 'libdir = "``$(KRB5_LIBDIR)``"' >> $@
117	echo 'localstatedir = "``$(localstatedir)``"' >> $@
118	echo 'runstatedir = "``$(runstatedir)``"' >> $@
119	echo 'sysconfdir = "``$(sysconfdir)``"' >> $@
120	echo 'ccache = "``$(DEFCCNAME)``"' >> $@
121	echo 'keytab = "``$(DEFKTNAME)``"' >> $@
122	echo 'ckeytab = "``$(DEFCKTNAME)``"' >> $@
123
124# Dummy rule that man/Makefile can invoke
125version.py: $(docsrc)/version.py
126
127$(docsrc)/version.py: $(top_srcdir)/patchlevel.h $(srcdir)/version.py.in
128	rm -f $@
129	$(CC) -E -I$(top_srcdir) - < $(srcdir)/version.py.in > $@
130
131clean:
132	rm -rf doxy rst_apiref rst_composite rst_notice html_subst \
133		Doxyfile paths.py $(docsrc)/version.py notice.txt \
134		$(docsrc)/html/.doctrees $(docsrc)/pdf/.doctrees \
135		$(docsrc)/tools/*.pyc
136