From patchwork Thu May 19 14:29:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9127737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 34F0960213 for ; Thu, 19 May 2016 14:32:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28454281BF for ; Thu, 19 May 2016 14:32:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D65E281C7; Thu, 19 May 2016 14:32:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4644D281C6 for ; Thu, 19 May 2016 14:32:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b3OxZ-0000lk-3k; Thu, 19 May 2016 14:29:57 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b3OxX-0000lN-Mz for xen-devel@lists.xen.org; Thu, 19 May 2016 14:29:55 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id 1C/1D-02973-2EDCD375; Thu, 19 May 2016 14:29:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRWlGSWpSXmKPExsXitHSDve6js7b hBs+eKlos+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmbln9kL3giVvHo5hK2Bsbdwl2MnBwSAv4S TVtXMoPYbAL6ErtffGICsUUE1CVOd1xk7WLk4GAW0JVY9VMDJCwMVH7x4hJWEJtFQFXi25qfb CA2r4CHxKnfV9kgRspJnD/+E2ykkICaxLX+S+wQNYISJ2c+YQGxmQUkJA6+eMEMMl5CgFvib7 f9BEaeWUiqZiGpWsDItIpRozi1qCy1SNfQSC+pKDM9oyQ3MTNH19DAVC83tbg4MT01JzGpWC8 5P3cTIzBAGIBgB2PfLOdDjJIcTEqivO5nbMOF+JLyUyozEosz4otKc1KLDzHKcHAoSfDmgeQE i1LTUyvSMnOAoQqTluDgURLh1QdJ8xYXJOYWZ6ZDpE4xKkqJ88aAJARAEhmleXBtsPi4xCgrJ czLCHSIEE9BalFuZgmq/CtGcQ5GJWHeapApPJl5JXDTXwEtZgJafEvMBmRxSSJCSqqBcfEBtT 7VP+LSpY+VXmypU647LstQf7bl+5FYt2f8URsCGlZW2FkKWV2cz5Rhanf7to4Ou99blbVuVqL M9189YF657Lr3eaWwBe2VbkrHJ7OkdPuldPxlSpjLv87xpM/PZab9PjsO5s0o3nzWsUZyUdIR Uw2xrKcP+lckHb5rkNhk8osn8fhjJZbijERDLeai4kQA/k7tkooCAAA= X-Env-Sender: prvs=9409b5aa3=Andrew.Cooper3@citrix.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1463668192!28479520!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10627 invoked from network); 19 May 2016 14:29:54 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-15.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 19 May 2016 14:29:54 -0000 X-IronPort-AV: E=Sophos;i="5.26,334,1459814400"; d="scan'208";a="362089919" From: Andrew Cooper To: Xen-devel Date: Thu, 19 May 2016 15:29:44 +0100 Message-ID: <1463668186-1567-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH for-4.7 1/3] docs/build: Avoid using multi-target pattern rules X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Ian Jackson Release-acked-by: Wei Liu --- 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)