manual.mk 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. manual-update-lists: manual-check-dependencies-lists
  2. $(Q)$(call MESSAGE,"Updating the manual lists...")
  3. $(Q)BR2_DEFCONFIG="" TOPDIR=$(TOPDIR) O=$(O)/docs/manual/.build \
  4. $(TOPDIR)/support/scripts/gen-manual-lists.py
  5. # we can't use suitable-host-package here because that's not available in
  6. # the context of 'make release'
  7. manual-check-dependencies:
  8. $(Q)if [ -z "$(shell support/dependencies/check-host-asciidoc.sh)" ]; then \
  9. echo "You need a sufficiently recent asciidoc on your host" \
  10. "to generate the manual"; \
  11. exit 1; \
  12. fi
  13. $(Q)if [ -z "`which w3m 2>/dev/null`" ]; then \
  14. echo "You need w3m on your host to generate the manual"; \
  15. exit 1; \
  16. fi
  17. manual-check-dependencies-pdf:
  18. $(Q)if [ -z "`which dblatex 2>/dev/null`" ]; then \
  19. echo "You need dblatex on your host to generate the pdf manual"; \
  20. exit 1; \
  21. fi
  22. manual-check-dependencies-lists:
  23. $(Q)if ! python -c "import argparse" >/dev/null 2>&1 ; then \
  24. echo "You need python with argparse on your host to generate" \
  25. "the list of packages in the manual"; \
  26. exit 1; \
  27. fi
  28. ################################################################################
  29. # GENDOC -- generates the make targets needed to build a specific type of
  30. # asciidoc documentation.
  31. #
  32. # argument 1 is the name of the document and must be a subdirectory of docs/;
  33. # the top-level asciidoc file must have the same name
  34. # argument 2 is the type of document to generate (-f argument of a2x)
  35. # argument 3 is the document type as used in the make target
  36. # argument 4 is the output file extension for the document type
  37. # argument 5 is the human text for the document type
  38. # argument 6 (optional) are extra arguments for a2x
  39. #
  40. # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
  41. ################################################################################
  42. define GENDOC_INNER
  43. $(1): $(1)-$(3)
  44. .PHONY: $(1)-$(3)
  45. $(1)-$(3): $$(O)/docs/$(1)/$(1).$(4)
  46. manual-check-dependencies-$(3):
  47. $$(O)/docs/$(1)/$(1).$(4): docs/$(1)/$(1).txt \
  48. $$($(call UPPERCASE,$(1))_SOURCES) \
  49. manual-check-dependencies \
  50. manual-check-dependencies-$(3) \
  51. manual-update-lists
  52. $(Q)$(call MESSAGE,"Generating $(5) $(1)...")
  53. $(Q)mkdir -p $$(@D)/.build
  54. $(Q)rsync -au docs/$(1)/*.txt $$(@D)/.build
  55. $(Q)a2x $(6) -f $(2) -d book -L -r $(TOPDIR)/docs/images \
  56. -D $$(@D) $$(@D)/.build/$(1).txt
  57. -$(Q)rm -rf $$(@D)/.build
  58. endef
  59. ################################################################################
  60. # GENDOC -- generates the make targets needed to build asciidoc documentation.
  61. #
  62. # argument 1 is the name of the document and must be a subdirectory of docs/;
  63. # the top-level asciidoc file must have the same name
  64. #
  65. # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
  66. ################################################################################
  67. define GENDOC
  68. $(call GENDOC_INNER,$(1),xhtml,html,html,HTML,--xsltproc-opts "--stringparam toc.section.depth 4")
  69. $(call GENDOC_INNER,$(1),chunked,split-html,chunked,split HTML,--xsltproc-opts "--stringparam toc.section.depth 4")
  70. $(call GENDOC_INNER,$(1),pdf,pdf,pdf,PDF,--dblatex-opts "-P latex.output.revhistory=0")
  71. $(call GENDOC_INNER,$(1),text,txt,text,text)
  72. $(call GENDOC_INNER,$(1),epub,epub,epub,ePUB)
  73. clean: $(1)-clean
  74. $(1)-clean:
  75. $(Q)$(RM) -rf $(O)/docs/$(1)
  76. .PHONY: $(1) $(1)-clean manual-update-lists
  77. endef
  78. MANUAL_SOURCES = $(sort $(wildcard docs/manual/*.txt) $(wildcard docs/images/*))
  79. $(eval $(call GENDOC,manual))