From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH for-4.7 1/3] docs/build: Avoid using multi-target pattern rules
Date: Thu, 19 May 2016 15:29:44 +0100 [thread overview]
Message-ID: <1463668186-1567-1-git-send-email-andrew.cooper3@citrix.com> (raw)
Multi-target non-pattern rules and Multi-target pattern rules behave rather
differently. From `Pattern Intro':
Pattern rules may have more than one target. Unlike normal rules, this does
not act as many different rules with the same prerequisites and commands.
If a pattern rule has multiple targets, `make' knows that the rule's
commands are responsible for making all of the targets. The commands are
executed only once to make all the targets.
The intended use of the multi-target pattern rules was to avoid repeating the
identical recipe multiple times. The issue can be demonstrated with the
generation of documentation from pandoc source.
./xen.git$ touch docs/features/template.pandoc
./xen.git$ make -C docs/
# Regenerates html/features/template.html
./xen.git$ make -C docs/
# Regenerates txt/features/template.txt
./xen.git$ make -C docs/
# Regenerates pdf/features/template.pdf
To work around this, there need to be three distinct rules, so the execution
of one recipe doesn't short ciruit the others. To avoid copy&paste
duplication, introduce a metarule, and evalute it for each document target.
As $(PANDOC) is used to generate documentation from different source types,
the metarule can be extended to also encompas the rule to create pdfs from
markdown.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
---
docs/Makefile | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/docs/Makefile b/docs/Makefile
index b9da605..e2537e8 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -180,22 +180,24 @@ txt/%.txt: %.markdown
@$(INSTALL_DIR) $(@D)
$(INSTALL_DATA) $< $@
-pdf/%.pdf: %.markdown
-ifneq ($(PANDOC),)
- @$(INSTALL_DIR) $(@D)
- $(PANDOC) --number-sections --toc --standalone $< --output $@
-else
- @echo "pandoc not installed; skipping $@"
-endif
+# Metarule for generating pandoc rules.
+define GENERATE_PANDOC_RULE
+# $(1) is the target documentation format. $(2) is the source format.
-pdf/%.pdf txt/%.txt html/%.html: %.pandoc
+$(1)/%.$(1): %.$(2)
ifneq ($(PANDOC),)
- @$(INSTALL_DIR) $(@D)
- $(PANDOC) --number-sections --toc --standalone $< --output $@
+ @$(INSTALL_DIR) $$(@D)
+ $(PANDOC) --number-sections --toc --standalone $$< --output $$@
else
- @echo "pandoc not installed; skipping $@"
+ @echo "pandoc not installed; skipping $$@"
endif
+endef
+$(eval $(call GENERATE_PANDOC_RULE,pdf,pandoc)) # pdf/%.pdf: %.pandoc
+$(eval $(call GENERATE_PANDOC_RULE,txt,pandoc)) # txt/%.txt: %.pandoc
+$(eval $(call GENERATE_PANDOC_RULE,html,pandoc)) # html/%.html: %.pandoc
+$(eval $(call GENERATE_PANDOC_RULE,pdf,markdown)) # pdf/%.pdf: %.markdown
+
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
$(XEN_ROOT)/config/Docs.mk:
$(error You have to run ./configure before building docs)
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next reply other threads:[~2016-05-19 14:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-19 14:29 Andrew Cooper [this message]
2016-05-19 14:29 ` [PATCH for-4.7 2/3] docs/xsplice: Fix syntax when compiling to pdf with pandoc Andrew Cooper
2016-05-19 14:36 ` Konrad Rzeszutek Wilk
2016-05-19 14:41 ` Andrew Cooper
2016-05-19 14:56 ` Konrad Rzeszutek Wilk
2016-05-19 15:04 ` Andrew Cooper
2016-05-19 15:07 ` Wei Liu
2016-05-19 20:37 ` Konrad Rzeszutek Wilk
2016-05-20 18:09 ` [PATCH v2 for-4.7] " Andrew Cooper
2016-05-20 18:30 ` Konrad Rzeszutek Wilk
2016-05-19 14:29 ` [PATCH for-4.7 3/3] docs/feature: Tweaks to the feature document template Andrew Cooper
2016-05-23 10:19 ` [PATCH for-4.7 1/3] docs/build: Avoid using multi-target pattern rules Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463668186-1567-1-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).