1 # we can't use suitable-host-package here because that's not available in
2 # the context of 'make release'
3 gendoc-check-dependencies:
4 $(Q)if [ -z "$(shell support/dependencies/check-host-asciidoc.sh)" ]; then \
5 echo "You need a sufficiently recent asciidoc on your host" \
6 "to generate documents"; \
9 $(Q)if [ -z "`which w3m 2>/dev/null`" ]; then \
10 echo "You need w3m on your host to generate documents"; \
14 gendoc-check-dependencies-pdf:
15 $(Q)if [ -z "`which dblatex 2>/dev/null`" ]; then \
16 echo "You need dblatex on your host to generate PDF documents"; \
20 # PDF generation is broken because of a bug in xsltproc program provided
21 # by libxslt <=1.1.28, which does not honor an option we need to set.
22 # Fortunately, this bug is already fixed upstream:
23 # https://gitorious.org/libxslt/libxslt/commit/5af7ad745323004984287e48b42712e7305de35c
25 # So, bail out when trying to build a PDF using a buggy version of the
28 # So, to overcome this issue and being able to build a PDF, you can
29 # build xsltproc from its source repository, then run:
30 # $ PATH=/path/to/custom-xsltproc/bin:${PATH} make manual
31 GENDOC_XSLTPROC_IS_BROKEN = \
32 $(shell xsltproc --maxvars 0 >/dev/null 2>/dev/null || echo y)
34 ################################################################################
35 # GENDOC_INNER -- generates the make targets needed to build a specific type of
36 # asciidoc documentation.
38 # argument 1 is the name of the document and the top-level asciidoc file must
40 # argument 2 is the uppercase name of the document
41 # argument 3 is the directory containing the document
42 # argument 4 is the type of document to generate (-f argument of a2x)
43 # argument 5 is the document type as used in the make target
44 # argument 6 is the output file extension for the document type
45 # argument 7 is the human text for the document type
46 # argument 8 (optional) are extra arguments for a2x
48 # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
50 # Since this function will be called from within an $(eval ...)
51 # all variable references except the arguments must be $$-quoted.
52 ################################################################################
56 $(1)-$(5): $$(O)/docs/$(1)/$(1).$(6)
58 # Single line, because splitting a foreach is not easy...
59 gendoc-check-dependencies-$(5):
60 $(1)-check-dependencies-$(5): gendoc-check-dependencies-$(5)
61 $$(Q)$$(foreach hook,$$($(2)_CHECK_DEPENDENCIES_$$(call UPPERCASE,$(5))_HOOKS),$$(call $$(hook))$$(sep))
63 $(2)_$(4)_ASCIIDOC_CONF = $(3)/asciidoc-$(4).conf
64 ifneq ($$(wildcard $$($(2)_$(4)_ASCIIDOC_CONF)),)
65 $(2)_$(4)_ASCIIDOC_OPTS += -f $$($(2)_$(4)_ASCIIDOC_CONF)
68 # Handle a2x warning about --destination-dir option only applicable to HTML
70 # - use the --destination-dir option if possible (html and split-html),
71 # - otherwise copy the generated document to the output directory
73 ifneq ($$(filter $(5),html split-html),)
74 $(2)_$(4)_A2X_OPTS += --destination-dir="$$(@D)"
76 define $(2)_$(4)_INSTALL_CMDS
77 $$(Q)cp -f $$(BUILD_DIR)/docs/$(1)/$(1).$(6) $$(@D)
81 ifeq ($(6)-$$(GENDOC_XSLTPROC_IS_BROKEN),pdf-y)
82 $$(O)/docs/$(1)/$(1).$(6):
83 $$(warning PDF generation is disabled because of a bug in \
84 xsltproc. To be able to generate a PDF, you should \
85 build xsltproc from the libxslt sources >=1.1.29 and pass it \
86 to make through the command line: \
87 'PATH=/path/to/custom-xsltproc/bin:$$$${PATH} make $(1)-pdf')
89 $$(O)/docs/$(1)/$(1).$(6): $$($(2)_SOURCES) \
90 $(1)-check-dependencies \
91 $(1)-check-dependencies-$(5) \
93 $$(Q)$$(call MESSAGE,"Generating $(7) $(1)...")
95 $$(Q)a2x $(8) -f $(4) -d book -L \
96 $$(foreach r,$$($(2)_RESOURCES),-r $$(r)) \
97 $$($(2)_$(4)_A2X_OPTS) \
98 --asciidoc-opts="$$($(2)_$(4)_ASCIIDOC_OPTS)" \
99 $$(BUILD_DIR)/docs/$(1)/$(1).txt
100 # install the generated document
101 $$($(2)_$(4)_INSTALL_CMDS)
105 ################################################################################
106 # GENDOC -- generates the make targets needed to build asciidoc documentation.
108 # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
109 # The variable <DOCUMENT_NAME>_RESOURCES defines where the document's
110 # resources, such as images, are located; must be an absolute path.
111 ################################################################################
113 # Single line, because splitting a foreach is not easy...
114 $(pkgname)-check-dependencies: gendoc-check-dependencies
115 $$(Q)$$(foreach hook,$$($$(call UPPERCASE,$(pkgname))_CHECK_DEPENDENCIES_HOOKS),$$(call $$(hook))$$(sep))
117 $$(BUILD_DIR)/docs/$(pkgname):
120 # Single line, because splitting a foreach is not easy...
121 $(pkgname)-rsync: $$(BUILD_DIR)/docs/$(pkgname)
122 $$(Q)$$(call MESSAGE,"Preparing the $(pkgname) sources...")
123 $$(Q)rsync -a $(pkgdir) $$^
124 $$(Q)$$(foreach hook,$$($$(call UPPERCASE,$(pkgname))_POST_RSYNC_HOOKS),$$(call $$(hook))$$(sep))
126 $(pkgname)-prepare-sources: $(pkgname)-rsync
128 $(call GENDOC_INNER,$(pkgname),$$(call UPPERCASE,$(pkgname)),$(pkgdir),xhtml,html,html,HTML,\
129 --xsltproc-opts "--stringparam toc.section.depth 1")
131 $(call GENDOC_INNER,$(pkgname),$$(call UPPERCASE,$(pkgname)),$(pkgdir),chunked,split-html,chunked,split HTML,\
132 --xsltproc-opts "--stringparam toc.section.depth 1")
134 # dblatex needs to pass the '--maxvars ...' option to xsltproc to prevent it
135 # from reaching the template recursion limit when processing the (long) target
136 # package table and bailing out.
137 $(call GENDOC_INNER,$(pkgname),$$(call UPPERCASE,$(pkgname)),$(pkgdir),pdf,pdf,pdf,PDF,\
138 --dblatex-opts "-P latex.output.revhistory=0 -x '--maxvars 100000'")
140 $(call GENDOC_INNER,$(pkgname),$$(call UPPERCASE,$(pkgname)),$(pkgdir),text,text,text,text)
142 $(call GENDOC_INNER,$(pkgname),$$(call UPPERCASE,$(pkgname)),$(pkgdir),epub,epub,epub,ePUB)
144 clean: $(pkgname)-clean
146 $$(Q)$$(RM) -rf $$(BUILD_DIR)/docs/$(pkgname)
147 .PHONY: $(pkgname) $(pkgname)-clean
150 ################################################################################
151 # The Buildroot manual
152 ################################################################################
154 # Our manual needs to generate lists
155 manual-prepare-sources: manual-update-lists
157 # Packages included in BR2_EXTERNAL are not part of buildroot, so they
158 # should not be included in the manual.
159 .PHONY: manual-update-lists
160 manual-update-lists: manual-check-dependencies-lists $(BUILD_DIR)/docs/$(pkgname)
161 $(Q)$(call MESSAGE,"Updating the manual lists...")
162 $(Q)BR2_DEFCONFIG="" TOPDIR=$(TOPDIR) O=$(BUILD_DIR)/docs/$(pkgname) \
163 BR2_EXTERNAL=$(TOPDIR)/support/dummy-external \
164 python -B $(TOPDIR)/support/scripts/gen-manual-lists.py
166 manual-check-dependencies-lists:
167 $(Q)if ! python -c "import argparse" >/dev/null 2>&1 ; then \
168 echo "You need python with argparse on your host to generate" \
169 "the list of packages in the manual"; \
173 MANUAL_SOURCES = $(sort $(wildcard docs/manual/*.txt) $(wildcard docs/images/*))
174 MANUAL_RESOURCES = $(TOPDIR)/docs/images
175 $(eval $(call GENDOC))