PageRenderTime 32ms CodeModel.GetById 18ms app.highlight 10ms RepoModel.GetById 2ms app.codeStats 0ms

/mk/docs.mk

http://github.com/jruderman/rust
Makefile | 158 lines | 106 code | 32 blank | 20 comment | 0 complexity | d3b731620499cc303bbf84a5b7037d8e MD5 | raw file
  1######################################################################
  2# Doc variables and rules
  3######################################################################
  4
  5DOCS :=
  6
  7
  8######################################################################
  9# Pandoc (reference-manual related)
 10######################################################################
 11ifeq ($(CFG_PANDOC),)
 12  $(info cfg: no pandoc found, omitting doc/rust.pdf)
 13else
 14
 15  ifeq ($(CFG_NODE),)
 16    $(info cfg: no node found, omitting doc/tutorial.html)
 17  else
 18
 19doc/rust.css: rust.css
 20	@$(call E, cp: $@)
 21	$(Q)cp -a $< $@ 2> /dev/null
 22
 23DOCS += doc/rust.html
 24doc/rust.html: rust.md doc/version_info.html doc/rust.css
 25	@$(call E, pandoc: $@)
 26	$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
 27	"$(CFG_PANDOC)" \
 28         --standalone --toc \
 29         --section-divs \
 30         --number-sections \
 31         --from=markdown --to=html \
 32         --css=rust.css \
 33	 --include-before-body=doc/version_info.html \
 34         --output=$@
 35  endif
 36
 37  ifeq ($(CFG_PDFLATEX),)
 38    $(info cfg: no pdflatex found, omitting doc/rust.pdf)
 39  else
 40    ifeq ($(CFG_XETEX),)
 41      $(info cfg: no xetex found, disabling doc/rust.pdf)
 42    else
 43      ifeq ($(CFG_LUATEX),)
 44        $(info cfg: lacking luatex, disabling pdflatex)
 45      else
 46
 47DOCS += doc/rust.pdf
 48doc/rust.tex: rust.md doc/version.md
 49	@$(call E, pandoc: $@)
 50	$(Q)$(CFG_NODE) $(S)doc/prep.js $< | \
 51	"$(CFG_PANDOC)" \
 52         --standalone --toc \
 53         --number-sections \
 54         --from=markdown --to=latex \
 55         --output=$@
 56
 57doc/rust.pdf: doc/rust.tex
 58	@$(call E, pdflatex: $@)
 59	$(Q)$(CFG_PDFLATEX) \
 60        -interaction=batchmode \
 61        -output-directory=doc \
 62        $<
 63
 64      endif
 65    endif
 66  endif
 67
 68######################################################################
 69# Node (tutorial related)
 70######################################################################
 71  ifeq ($(CFG_NODE),)
 72    $(info cfg: no node found, omitting doc/tutorial.html)
 73  else
 74
 75DOCS += doc/tutorial.html
 76doc/tutorial.html: tutorial.md doc/version_info.html doc/rust.css
 77	@$(call E, pandoc: $@)
 78	$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
 79          $(CFG_PANDOC) --standalone --toc \
 80           --section-divs --number-sections \
 81           --from=markdown --to=html --css=rust.css \
 82	   --include-before-body=doc/version_info.html \
 83           --output=$@
 84
 85  endif
 86endif
 87
 88
 89######################################################################
 90# LLnextgen (grammar analysis from refman)
 91######################################################################
 92ifeq ($(CFG_LLNEXTGEN),)
 93  $(info cfg: no llnextgen found, omitting grammar-verification)
 94else
 95.PHONY: verify-grammar
 96
 97doc/rust.g: rust.md $(S)src/etc/extract_grammar.py
 98	@$(call E, extract_grammar: $@)
 99	$(Q)$(S)src/etc/extract_grammar.py $< >$@
100
101verify-grammar: doc/rust.g
102	@$(call E, LLnextgen: $<)
103	$(Q)$(CFG_LLNEXTGEN) --generate-lexer-wrapper=no $< >$@
104	$(Q)rm -f doc/rust.c doc/rust.h
105endif
106
107
108######################################################################
109# Rustdoc (libcore/std)
110######################################################################
111
112ifeq ($(CFG_PANDOC),)
113  $(info cfg: no pandoc found, omitting library doc build)
114else
115
116# The rustdoc executable
117RUSTDOC = $(HBIN2_H_$(CFG_HOST_TRIPLE))/rustdoc$(X)
118
119# The library documenting macro
120# $(1) - The output directory
121# $(2) - The crate file
122# $(3) - The crate soruce files
123define libdoc
124doc/$(1)/index.html: $(2) $(3) $$(RUSTDOC) doc/$(1)/rust.css
125	@$$(call E, rustdoc: $$@)
126	$(Q)$(RUSTDOC) $(2) --output-dir=doc/$(1)
127
128doc/$(1)/rust.css: rust.css
129	@$$(call E, cp: $$@)
130	$(Q)cp $$< $$@
131
132DOCS += doc/$(1)/index.html
133endef
134
135$(eval $(call libdoc,core,$(CORELIB_CRATE),$(CORELIB_INPUTS)))
136$(eval $(call libdoc,std,$(STDLIB_CRATE),$(STDLIB_INPUTS)))
137endif
138
139
140ifdef CFG_DISABLE_DOCS
141  $(info cfg: disabling doc build (CFG_DISABLE_DOCS))
142  DOCS :=
143endif
144
145
146doc/version.md: $(MKFILE_DEPS) rust.md
147	@$(call E, version-stamp: $@)
148	$(Q)echo "$(CFG_VERSION)" >$@
149
150doc/version_info.html: version_info_template.html
151	@$(call E, version-info: $@)
152	sed -e "s/VERSION/$(CFG_RELEASE)/; s/SHORT_HASH/$(shell echo \
153                    $(CFG_VER_HASH) | head -c 8)/;\
154	            s/STAMP/$(CFG_VER_HASH)/;" $< >$@
155
156GENERATED += doc/version.md
157
158docs: $(DOCS)