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