package/nodejs: security bump for 0.10.x to version 0.10.42
[buildroot-gz.git] / package / doc-asciidoc.mk
blob6ab5ad27e423fd88de3956457c39f846c1a2c634
1 # we can't use suitable-host-package here because that's not available in
2 # the context of 'make release'
3 asciidoc-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"; \
7 exit 1; \
8 fi
9 $(Q)if [ -z "`which w3m 2>/dev/null`" ]; then \
10 echo "You need w3m on your host to generate documents"; \
11 exit 1; \
14 asciidoc-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"; \
17 exit 1; \
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
26 # xsltproc program.
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 # Apply this configuration to all documents
35 BR_ASCIIDOC_CONF = docs/conf/asciidoc.conf
37 ################################################################################
38 # ASCIIDOC_INNER -- generates the make targets needed to build a specific type of
39 # asciidoc documentation.
41 # argument 1 is the name of the document and the top-level asciidoc file must
42 # have the same name
43 # argument 2 is the uppercase name of the document
44 # argument 3 is the directory containing the document
45 # argument 4 is the type of document to generate (-f argument of a2x)
46 # argument 5 is the document type as used in the make target
47 # argument 6 is the output file extension for the document type
48 # argument 7 is the human text for the document type
49 # argument 8 (optional) are extra arguments for a2x
51 # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
53 # Since this function will be called from within an $(eval ...)
54 # all variable references except the arguments must be $$-quoted.
55 ################################################################################
56 define ASCIIDOC_INNER
57 $(1): $(1)-$(5)
58 .PHONY: $(1)-$(5)
59 $(1)-$(5): $$(O)/docs/$(1)/$(1).$(6)
61 # Single line, because splitting a foreach is not easy...
62 asciidoc-check-dependencies-$(5):
63 $(1)-check-dependencies-$(5): asciidoc-check-dependencies-$(5)
64 $$(Q)$$(foreach hook,$$($(2)_CHECK_DEPENDENCIES_$$(call UPPERCASE,$(5))_HOOKS),$$(call $$(hook))$$(sep))
66 # Include Buildroot's AsciiDoc configuration first:
67 # - generic configuration,
68 # - then output-specific configuration
69 ifneq ($$(wildcard $$(BR_ASCIIDOC_CONF)),)
70 $(2)_$(4)_ASCIIDOC_OPTS += -f $$(BR_ASCIIDOC_CONF)
71 endif
72 BR_$(4)_ASCIIDOC_CONF = docs/conf/asciidoc-$(4).conf
73 ifneq ($$(wildcard $$(BR_$(4)_ASCIIDOC_CONF)),)
74 $(2)_$(4)_ASCIIDOC_OPTS += -f $$(BR_$(4)_ASCIIDOC_CONF)
75 endif
77 # Then include the document's AsciiDoc configuration:
78 # - generic configuration,
79 # - then output-specific configuration
80 ifneq ($$(wildcard $$($(2)_ASCIIDOC_CONF)),)
81 $(2)_$(4)_ASCIIDOC_OPTS += -f $$($(2)_ASCIIDOC_CONF)
82 endif
83 $(2)_$(4)_ASCIIDOC_CONF = $(3)/asciidoc-$(4).conf
84 ifneq ($$(wildcard $$($(2)_$(4)_ASCIIDOC_CONF)),)
85 $(2)_$(4)_ASCIIDOC_OPTS += -f $$($(2)_$(4)_ASCIIDOC_CONF)
86 endif
88 # Handle a2x warning about --destination-dir option only applicable to HTML
89 # based outputs. So:
90 # - use the --destination-dir option if possible (html and split-html),
91 # - otherwise copy the generated document to the output directory
92 $(2)_$(4)_A2X_OPTS =
93 ifneq ($$(filter $(5),html split-html),)
94 $(2)_$(4)_A2X_OPTS += --destination-dir="$$(@D)"
95 else
96 define $(2)_$(4)_INSTALL_CMDS
97 $$(Q)cp -f $$(BUILD_DIR)/docs/$(1)/$(1).$(6) $$(@D)
98 endef
99 endif
101 $$(O)/docs/$(1)/$(1).$(6): export TZ=UTC
103 ifeq ($(6)-$$(GENDOC_XSLTPROC_IS_BROKEN),pdf-y)
104 $$(O)/docs/$(1)/$(1).$(6):
105 $$(warning PDF generation is disabled because of a bug in \
106 xsltproc. To be able to generate a PDF, you should \
107 build xsltproc from the libxslt sources >=1.1.29 and pass it \
108 to make through the command line: \
109 'PATH=/path/to/custom-xsltproc/bin:$$$${PATH} make $(1)-pdf')
110 else
111 # -r $(@D) is there for documents that use external filters; those filters
112 # generate code at the same location it finds the document's source files.
113 $$(O)/docs/$(1)/$(1).$(6): $$($(2)_SOURCES) \
114 $(1)-check-dependencies \
115 $(1)-check-dependencies-$(5) \
116 $(1)-prepare-sources
117 $$(Q)$$(call MESSAGE,"Generating $(7) $(1)...")
118 $$(Q)mkdir -p $$(@D)
119 $$(Q)a2x $(8) -f $(4) -d book -L \
120 $$(foreach r,$$($(2)_RESOURCES),-r $$(r)) -r $$(@D) \
121 $$($(2)_$(4)_A2X_OPTS) \
122 --asciidoc-opts="$$($(2)_$(4)_ASCIIDOC_OPTS)" \
123 $$(BUILD_DIR)/docs/$(1)/$(1).txt
124 # install the generated document
125 $$($(2)_$(4)_INSTALL_CMDS)
126 endif
127 endef
129 ################################################################################
130 # ASCIIDOC -- generates the make targets needed to build asciidoc documentation.
132 # argument 1 is the lowercase name of the document; the document's main file
133 # must have the same name, with the .txt extension
134 # argument 2 is the uppercase name of the document
135 # argument 3 is the directory containing the document's sources
137 # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
138 # The variable <DOCUMENT_NAME>_RESOURCES defines where the document's
139 # resources, such as images, are located; must be an absolute path.
140 ################################################################################
141 define ASCIIDOC
142 # Single line, because splitting a foreach is not easy...
143 $(1)-check-dependencies: asciidoc-check-dependencies
144 $$(Q)$$(foreach hook,$$($(2)_CHECK_DEPENDENCIES_HOOKS),$$(call $$(hook))$$(sep))
146 # Single line, because splitting a foreach is not easy...
147 # Do not touch the stamp file, so we get to rsync again every time we build
148 # the document.
149 $$(BUILD_DIR)/docs/$(1)/.stamp_doc_rsynced:
150 $$(Q)$$(call MESSAGE,"Preparing the $(1) sources...")
151 $$(Q)mkdir -p $$(@D)
152 $$(Q)rsync -a $(3) $$(@D)
153 $$(Q)$$(foreach hook,$$($(2)_POST_RSYNC_HOOKS),$$(call $$(hook))$$(sep))
155 $(1)-prepare-sources: $$(BUILD_DIR)/docs/$(1)/.stamp_doc_rsynced
157 $(2)_ASCIIDOC_CONF = $(3)/asciidoc.conf
159 $(call ASCIIDOC_INNER,$(1),$(2),$(3),xhtml,html,html,HTML,\
160 --xsltproc-opts "--stringparam toc.section.depth 1")
162 $(call ASCIIDOC_INNER,$(1),$(2),$(3),chunked,split-html,chunked,split HTML,\
163 --xsltproc-opts "--stringparam toc.section.depth 1")
165 # dblatex needs to pass the '--maxvars ...' option to xsltproc to prevent it
166 # from reaching the template recursion limit when processing the (long) target
167 # package table and bailing out.
168 $(call ASCIIDOC_INNER,$(1),$(2),$(3),pdf,pdf,pdf,PDF,\
169 --dblatex-opts "-P latex.output.revhistory=0 -x '--maxvars 100000'")
171 $(call ASCIIDOC_INNER,$(1),$(2),$(3),text,text,text,text)
173 $(call ASCIIDOC_INNER,$(1),$(2),$(3),epub,epub,epub,ePUB)
175 clean: $(1)-clean
176 $(1)-clean:
177 $$(Q)$$(RM) -rf $$(BUILD_DIR)/docs/$(1)
178 .PHONY: $(1) $(1)-clean
179 endef
181 ################################################################################
182 # asciidoc-document -- the target generator macro for asciidoc documents
183 ################################################################################
185 asciidoc-document = $(call ASCIIDOC,$(pkgname),$(call UPPERCASE,$(pkgname)),$(pkgdir))