]> Git Repo - buildroot-mgba.git/blame - package/doc-asciidoc.mk
syslog-ng: Bump version to 3.7.3
[buildroot-mgba.git] / package / doc-asciidoc.mk
CommitLineData
2dfe1b83
YM
1# we can't use suitable-host-package here because that's not available in
2# the context of 'make release'
ab6a6212 3asciidoc-check-dependencies:
2dfe1b83
YM
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; \
12 fi
13
ab6a6212 14asciidoc-check-dependencies-pdf:
2dfe1b83
YM
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; \
18 fi
19
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
24#
25# So, bail out when trying to build a PDF using a buggy version of the
26# xsltproc program.
27#
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
31GENDOC_XSLTPROC_IS_BROKEN = \
32 $(shell xsltproc --maxvars 0 >/dev/null 2>/dev/null || echo y)
33
d79042bd
YM
34# Apply this configuration to all documents
35BR_ASCIIDOC_CONF = docs/conf/asciidoc.conf
36
2dfe1b83 37################################################################################
ab6a6212
YM
38# ASCIIDOC_INNER -- generates the make targets needed to build a specific type of
39# asciidoc documentation.
2dfe1b83
YM
40#
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
50#
51# The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
52#
53# Since this function will be called from within an $(eval ...)
54# all variable references except the arguments must be $$-quoted.
55################################################################################
ab6a6212 56define ASCIIDOC_INNER
2dfe1b83
YM
57$(1): $(1)-$(5)
58.PHONY: $(1)-$(5)
59$(1)-$(5): $$(O)/docs/$(1)/$(1).$(6)
60
61# Single line, because splitting a foreach is not easy...
ab6a6212
YM
62asciidoc-check-dependencies-$(5):
63$(1)-check-dependencies-$(5): asciidoc-check-dependencies-$(5)
2dfe1b83
YM
64 $$(Q)$$(foreach hook,$$($(2)_CHECK_DEPENDENCIES_$$(call UPPERCASE,$(5))_HOOKS),$$(call $$(hook))$$(sep))
65
d79042bd
YM
66# Include Buildroot's AsciiDoc configuration first:
67# - generic configuration,
68# - then output-specific configuration
69ifneq ($$(wildcard $$(BR_ASCIIDOC_CONF)),)
70$(2)_$(4)_ASCIIDOC_OPTS += -f $$(BR_ASCIIDOC_CONF)
71endif
72BR_$(4)_ASCIIDOC_CONF = docs/conf/asciidoc-$(4).conf
73ifneq ($$(wildcard $$(BR_$(4)_ASCIIDOC_CONF)),)
74$(2)_$(4)_ASCIIDOC_OPTS += -f $$(BR_$(4)_ASCIIDOC_CONF)
75endif
76
77# Then include the document's AsciiDoc configuration:
78# - generic configuration,
79# - then output-specific configuration
3c40c9ee
YM
80ifneq ($$(wildcard $$($(2)_ASCIIDOC_CONF)),)
81$(2)_$(4)_ASCIIDOC_OPTS += -f $$($(2)_ASCIIDOC_CONF)
82endif
2dfe1b83
YM
83$(2)_$(4)_ASCIIDOC_CONF = $(3)/asciidoc-$(4).conf
84ifneq ($$(wildcard $$($(2)_$(4)_ASCIIDOC_CONF)),)
85$(2)_$(4)_ASCIIDOC_OPTS += -f $$($(2)_$(4)_ASCIIDOC_CONF)
86endif
87
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 =
93ifneq ($$(filter $(5),html split-html),)
94$(2)_$(4)_A2X_OPTS += --destination-dir="$$(@D)"
95else
96define $(2)_$(4)_INSTALL_CMDS
97 $$(Q)cp -f $$(BUILD_DIR)/docs/$(1)/$(1).$(6) $$(@D)
98endef
99endif
100
e2cd2337
YM
101$$(O)/docs/$(1)/$(1).$(6): export TZ=UTC
102
2dfe1b83
YM
103ifeq ($(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')
110else
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 \
9d4a1a78
AS
120 $$(foreach r,$$($(2)_RESOURCES) $$(@D), \
121 --resource="$$(abspath $$(r))") \
2dfe1b83
YM
122 $$($(2)_$(4)_A2X_OPTS) \
123 --asciidoc-opts="$$($(2)_$(4)_ASCIIDOC_OPTS)" \
124 $$(BUILD_DIR)/docs/$(1)/$(1).txt
125# install the generated document
126 $$($(2)_$(4)_INSTALL_CMDS)
127endif
128endef
129
130################################################################################
ab6a6212 131# ASCIIDOC -- generates the make targets needed to build asciidoc documentation.
2dfe1b83 132#
13f5f02e
YM
133# argument 1 is the lowercase name of the document; the document's main file
134# must have the same name, with the .txt extension
135# argument 2 is the uppercase name of the document
136# argument 3 is the directory containing the document's sources
137#
2dfe1b83
YM
138# The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
139# The variable <DOCUMENT_NAME>_RESOURCES defines where the document's
140# resources, such as images, are located; must be an absolute path.
141################################################################################
ab6a6212 142define ASCIIDOC
2dfe1b83 143# Single line, because splitting a foreach is not easy...
3c695928 144$(1)-check-dependencies: asciidoc-check-dependencies $$($(2)_DEPENDENCIES)
13f5f02e 145 $$(Q)$$(foreach hook,$$($(2)_CHECK_DEPENDENCIES_HOOKS),$$(call $$(hook))$$(sep))
2dfe1b83 146
2dfe1b83 147# Single line, because splitting a foreach is not easy...
3d2a49f7
YM
148# Do not touch the stamp file, so we get to rsync again every time we build
149# the document.
150$$(BUILD_DIR)/docs/$(1)/.stamp_doc_rsynced:
13f5f02e 151 $$(Q)$$(call MESSAGE,"Preparing the $(1) sources...")
3d2a49f7
YM
152 $$(Q)mkdir -p $$(@D)
153 $$(Q)rsync -a $(3) $$(@D)
13f5f02e 154 $$(Q)$$(foreach hook,$$($(2)_POST_RSYNC_HOOKS),$$(call $$(hook))$$(sep))
2dfe1b83 155
3d2a49f7 156$(1)-prepare-sources: $$(BUILD_DIR)/docs/$(1)/.stamp_doc_rsynced
2dfe1b83 157
3c40c9ee
YM
158$(2)_ASCIIDOC_CONF = $(3)/asciidoc.conf
159
13f5f02e 160$(call ASCIIDOC_INNER,$(1),$(2),$(3),xhtml,html,html,HTML,\
2dfe1b83
YM
161 --xsltproc-opts "--stringparam toc.section.depth 1")
162
13f5f02e 163$(call ASCIIDOC_INNER,$(1),$(2),$(3),chunked,split-html,chunked,split HTML,\
2dfe1b83
YM
164 --xsltproc-opts "--stringparam toc.section.depth 1")
165
166# dblatex needs to pass the '--maxvars ...' option to xsltproc to prevent it
167# from reaching the template recursion limit when processing the (long) target
168# package table and bailing out.
13f5f02e 169$(call ASCIIDOC_INNER,$(1),$(2),$(3),pdf,pdf,pdf,PDF,\
2dfe1b83
YM
170 --dblatex-opts "-P latex.output.revhistory=0 -x '--maxvars 100000'")
171
13f5f02e 172$(call ASCIIDOC_INNER,$(1),$(2),$(3),text,text,text,text)
2dfe1b83 173
13f5f02e 174$(call ASCIIDOC_INNER,$(1),$(2),$(3),epub,epub,epub,ePUB)
2dfe1b83 175
13f5f02e
YM
176clean: $(1)-clean
177$(1)-clean:
178 $$(Q)$$(RM) -rf $$(BUILD_DIR)/docs/$(1)
179.PHONY: $(1) $(1)-clean
2dfe1b83 180endef
ab6a6212
YM
181
182################################################################################
183# asciidoc-document -- the target generator macro for asciidoc documents
184################################################################################
185
13f5f02e 186asciidoc-document = $(call ASCIIDOC,$(pkgname),$(call UPPERCASE,$(pkgname)),$(pkgdir))
This page took 0.66948 seconds and 4 git commands to generate.