1414#
1515# The DOCS variable is their names (with no file extension).
1616#
17+ # PDF_DOCS lists the targets for which PDF documentation should be
18+ # build.
19+ #
1720# RUSTDOC_FLAGS_xyz variables are extra arguments to pass to the
1821# rustdoc invocation for xyz.
1922#
@@ -28,6 +31,8 @@ DOCS := index tutorial guide-ffi guide-macros guide-lifetimes \
2831 complement-cheatsheet guide-runtime \
2932 rust rustdoc
3033
34+ PDF_DOCS := tutorial rust
35+
3136RUSTDOC_DEPS_rust := doc/full-toc.inc
3237RUSTDOC_FLAGS_rust := --markdown-in-header=doc/full-toc.inc
3338
@@ -45,8 +50,6 @@ PANDOC_TEX_OPTS = $(PANDOC_BASE_OPTS) --include-before-body=doc/version.md \
4550 --from=markdown --include-before-body=doc/footer.tex --to=latex
4651PANDOC_EPUB_OPTS = $(PANDOC_BASE_OPTS ) --to=epub
4752
48-
49-
5053# The rustdoc executable...
5154RUSTDOC_EXE = $(HBIN2_H_$(CFG_BUILD ) ) /rustdoc$(X_$(CFG_BUILD ) )
5255# ...with rpath included in case --disable-rpath was provided to
@@ -146,6 +149,11 @@ doc/footer.tex: $(D)/footer.tex | doc/
146149
147150# The (english) documentation for each doc item.
148151
152+ define DEF_SHOULD_BUILD_PDF_DOC
153+ SHOULD_BUILD_PDF_DOC_$(1 ) = 1
154+ endef
155+ $(foreach docname,$(PDF_DOCS),$(eval $(call DEF_SHOULD_BUILD_PDF_DOC,$(docname))))
156+
149157define DEF_DOC
150158
151159# HTML (rustdoc)
@@ -171,13 +179,15 @@ doc/$(1).tex: $$(D)/$(1).md doc/footer.tex doc/version.md | doc/
171179 $$(CFG_PANDOC ) $$(PANDOC_TEX_OPTS ) --output=$$@
172180
173181ifneq ($(NO_PDF_DOCS ) ,1)
182+ ifeq ($$(SHOULD_BUILD_PDF_DOC_$(1 ) ) ,1)
174183DOC_TARGETS += doc/$(1 ) .pdf
175184doc/$(1 ) .pdf : doc/$(1 ) .tex
176185 @$$(call E, pdflatex: $$@ )
177186 $$(Q )$$(CFG_PDFLATEX ) \
178187 -interaction=batchmode \
179188 -output-directory=doc \
180189 $$<
190+ endif # SHOULD_BUILD_PDF_DOCS_$(1)
181191endif # NO_PDF_DOCS
182192
183193endif # ONLY_HTML_DOCS
0 commit comments