1 # we can't use suitable-host-package here because that's not available in
2 # the context of 'make release'
3 .PHONY: asciidoc-check-dependencies
4 asciidoc-check-dependencies:
5 $(Q)if [ -z "$(shell support/dependencies/check-host-asciidoc.sh)" ]; then \
6 echo "You need a sufficiently recent asciidoc on your host" \
7 "to generate documents"; \
10 $(Q)if [ -z "`which w3m 2>/dev/null`" ]; then \
11 echo "You need w3m on your host to generate documents"; \
15 asciidoc-check-dependencies-pdf:
16 $(Q)if [ -z "`which dblatex 2>/dev/null`" ]; then \
17 echo "You need dblatex on your host to generate PDF documents"; \
21 # PDF generation is broken because of a bug in xsltproc program provided
22 # by libxslt <=1.1.28, which does not honor an option we need to set.
23 # Fortunately, this bug is already fixed upstream:
24 # https://gitorious.org/libxslt/libxslt/commit/5af7ad745323004984287e48b42712e7305de35c
26 # So, bail out when trying to build a PDF using a buggy version of the
29 # So, to overcome this issue and being able to build a PDF, you can
30 # build xsltproc from its source repository, then run:
31 # $ PATH=/path/to/custom-xsltproc/bin:${PATH} make manual
32 GENDOC_XSLTPROC_IS_BROKEN = \
33 $(shell xsltproc --maxvars 0 >/dev/null 2>/dev/null || echo y)
35 # Apply this configuration to all documents
36 BR_ASCIIDOC_CONF = docs/conf/asciidoc.conf
38 ################################################################################
39 # ASCIIDOC_INNER -- generates the make targets needed to build a specific type of
40 # asciidoc documentation.
42 # argument 1 is the name of the document and the top-level asciidoc file must
44 # argument 2 is the uppercase name of the document
45 # argument 3 is the directory containing the document
46 # argument 4 is the type of document to generate (-f argument of a2x)
47 # argument 5 is the document type as used in the make target
48 # argument 6 is the output file extension for the document type
49 # argument 7 is the human text for the document type
50 # argument 8 (optional) are extra arguments for a2x
52 # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
54 # Since this function will be called from within an $(eval ...)
55 # all variable references except the arguments must be $$-quoted.
56 ################################################################################
60 $(1)-$(5): $$(O)/docs/$(1)/$(1).$(6)
62 asciidoc-check-dependencies-$(5):
63 .PHONY: $(1)-check-dependencies-$(5)
64 # Single line, because splitting a foreach is not easy...
65 $(1)-check-dependencies-$(5): asciidoc-check-dependencies-$(5)
66 $$(Q)$$(foreach hook,$$($(2)_CHECK_DEPENDENCIES_$$(call UPPERCASE,$(5))_HOOKS),$$(call $$(hook))$$(sep))
68 # Include Buildroot's AsciiDoc configuration first:
69 # - generic configuration,
70 # - then output-specific configuration
71 ifneq ($$(wildcard $$(BR_ASCIIDOC_CONF)),)
72 $(2)_$(4)_ASCIIDOC_OPTS += -f $$(BR_ASCIIDOC_CONF)
74 BR_$(4)_ASCIIDOC_CONF = docs/conf/asciidoc-$(4).conf
75 ifneq ($$(wildcard $$(BR_$(4)_ASCIIDOC_CONF)),)
76 $(2)_$(4)_ASCIIDOC_OPTS += -f $$(BR_$(4)_ASCIIDOC_CONF)
79 # Then include the document's AsciiDoc configuration:
80 # - generic configuration,
81 # - then output-specific configuration
82 ifneq ($$(wildcard $$($(2)_ASCIIDOC_CONF)),)
83 $(2)_$(4)_ASCIIDOC_OPTS += -f $$($(2)_ASCIIDOC_CONF)
85 $(2)_$(4)_ASCIIDOC_CONF = $(3)/asciidoc-$(4).conf
86 ifneq ($$(wildcard $$($(2)_$(4)_ASCIIDOC_CONF)),)
87 $(2)_$(4)_ASCIIDOC_OPTS += -f $$($(2)_$(4)_ASCIIDOC_CONF)
90 # Handle a2x warning about --destination-dir option only applicable to HTML
92 # - use the --destination-dir option if possible (html and split-html),
93 # - otherwise copy the generated document to the output directory
95 ifneq ($$(filter $(5),html split-html),)
96 $(2)_$(4)_A2X_OPTS += --destination-dir="$$(@D)"
98 define $(2)_$(4)_INSTALL_CMDS
99 $$(Q)cp -f $$(BUILD_DIR)/docs/$(1)/$(1).$(6) $$(@D)
103 $$(O)/docs/$(1)/$(1).$(6): export TZ=UTC
105 ifeq ($(6)-$$(GENDOC_XSLTPROC_IS_BROKEN),pdf-y)
106 $$(O)/docs/$(1)/$(1).$(6):
107 $$(warning PDF generation is disabled because of a bug in \
108 xsltproc. To be able to generate a PDF, you should \
109 build xsltproc from the libxslt sources >=1.1.29 and pass it \
110 to make through the command line: \
111 'PATH=/path/to/custom-xsltproc/bin:$$$${PATH} make $(1)-pdf')
113 # -r $(@D) is there for documents that use external filters; those filters
114 # generate code at the same location it finds the document's source files.
115 $$(O)/docs/$(1)/$(1).$(6): $$($(2)_SOURCES) \
116 $(1)-check-dependencies \
117 $(1)-check-dependencies-$(5) \
119 $$(Q)$$(call MESSAGE,"Generating $(7) $(1)...")
121 $$(Q)a2x $(8) -f $(4) -d book -L \
122 $$(foreach r,$$($(2)_RESOURCES) $$(@D), \
123 --resource="$$(abspath $$(r))") \
124 $$($(2)_$(4)_A2X_OPTS) \
125 --asciidoc-opts="$$($(2)_$(4)_ASCIIDOC_OPTS)" \
126 $$(BUILD_DIR)/docs/$(1)/$(1).txt
127 # install the generated document
128 $$($(2)_$(4)_INSTALL_CMDS)
132 ################################################################################
133 # ASCIIDOC -- generates the make targets needed to build asciidoc documentation.
135 # argument 1 is the lowercase name of the document; the document's main file
136 # must have the same name, with the .txt extension
137 # argument 2 is the uppercase name of the document
138 # argument 3 is the directory containing the document's sources
140 # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
141 # The variable <DOCUMENT_NAME>_RESOURCES defines where the document's
142 # resources, such as images, are located; must be an absolute path.
143 ################################################################################
145 # Single line, because splitting a foreach is not easy...
146 .PHONY: $(1)-check-dependencies
147 $(1)-check-dependencies: asciidoc-check-dependencies $$($(2)_DEPENDENCIES)
148 $$(Q)$$(foreach hook,$$($(2)_CHECK_DEPENDENCIES_HOOKS),$$(call $$(hook))$$(sep))
150 # Single line, because splitting a foreach is not easy...
151 # Do not touch the stamp file, so we get to rsync again every time we build
153 $$(BUILD_DIR)/docs/$(1)/.stamp_doc_rsynced:
154 $$(Q)$$(call MESSAGE,"Preparing the $(1) sources...")
156 $$(Q)rsync -a $(3) $$(@D)
157 $$(Q)$$(foreach hook,$$($(2)_POST_RSYNC_HOOKS),$$(call $$(hook))$$(sep))
159 .PHONY: $(1)-prepare-sources
160 $(1)-prepare-sources: $$(BUILD_DIR)/docs/$(1)/.stamp_doc_rsynced
162 $(2)_ASCIIDOC_CONF = $(3)/asciidoc.conf
164 $(call ASCIIDOC_INNER,$(1),$(2),$(3),xhtml,html,html,HTML,\
165 --xsltproc-opts "--stringparam toc.section.depth 1")
167 $(call ASCIIDOC_INNER,$(1),$(2),$(3),chunked,split-html,chunked,split HTML,\
168 --xsltproc-opts "--stringparam toc.section.depth 1")
170 # dblatex needs to pass the '--maxvars ...' option to xsltproc to prevent it
171 # from reaching the template recursion limit when processing the (long) target
172 # package table and bailing out.
173 $(call ASCIIDOC_INNER,$(1),$(2),$(3),pdf,pdf,pdf,PDF,\
174 --dblatex-opts "-P latex.output.revhistory=0 -x '--maxvars 100000'")
176 $(call ASCIIDOC_INNER,$(1),$(2),$(3),text,text,text,text)
178 $(call ASCIIDOC_INNER,$(1),$(2),$(3),epub,epub,epub,ePUB)
182 $$(Q)$$(RM) -rf $$(BUILD_DIR)/docs/$(1)
183 .PHONY: $(1) $(1)-clean
186 ################################################################################
187 # asciidoc-document -- the target generator macro for asciidoc documents
188 ################################################################################
190 asciidoc-document = $(call ASCIIDOC,$(pkgname),$(call UPPERCASE,$(pkgname)),$(pkgdir))