From patchwork Sat Jul 20 16:27:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 169305 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5290813ilk; Sat, 20 Jul 2019 09:27:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwje+2q1OcFdQhsvWY67GSWQqPT24ZXa3GExCrbrAPNwmekQAtUT6OEIU20Q8TYhgsDidz6 X-Received: by 2002:a63:3805:: with SMTP id f5mr27908139pga.272.1563640077715; Sat, 20 Jul 2019 09:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563640077; cv=none; d=google.com; s=arc-20160816; b=aQDhZL/MkxAYvmo+9mPj/y+9U0T7GdLDOyHPERyNd6OzE6zGbs43H2WnJ14Xjq4Q9k +wsjt1s1ooY+9GqF5byTbJVplafOiNtFyZwzrIw4N0npUbXm5GsozSRTERKXtJoRfUy4 5YKgAr9kBjncXgE+OrnJlRWIlnUOOwjOfRa//6d3Hz9B0pAe91LexTBHjRz6C3hLTubr J9F/Qbezr6ujzRKWp56CpkFUXV9XwzrdZvt0qOqCyuQRHzps65fyRyHGhYkz/NhgxOIU N5XhjSrEBgdWuMyhZlFj7A5iEB0XMIvVRhMrf5YefbLpIfpGpzHc4ibXOkMR1Mh7i4XG UjNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=YWYhkhyNQMCU9Geqh6mdxj3ov/tBxwsPizahvUIX/a0=; b=cENo+2Ny83LtZE+u5+SuzPpeU0+LOsLgpKZG3tDwzWXCevDxcYyh/GEsUvZBpnMC35 U00rW3vn9mxAxBAbrv4U5eNZ0P4zU32TI201+flST7dIR3EMOmvuttlsoHx6eF+G6Yv5 D+sfYsITKB2J1/LgG5cikJ7SAS2W7QXTPW1k4+0QdvvoXsOKplxT/gCl8EnsmUnXQtUP Yep8UR4H7fOkdsH8g55qCS2z2LdKxtmXjiFbKNek8SNAgt/X7lW863hfGVAgwT0LglGG Q0WoAnkxMbF4qPV7CIutYxIRJQdk2P0TiE0FoyracLV5umM71IpxQJGgrgaEMU1hiWlw xH9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BEEnwqfb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si2917262pgh.159.2019.07.20.09.27.57; Sat, 20 Jul 2019 09:27:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BEEnwqfb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726651AbfGTQ1v (ORCPT + 29 others); Sat, 20 Jul 2019 12:27:51 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:52415 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbfGTQ1u (ORCPT ); Sat, 20 Jul 2019 12:27:50 -0400 Received: from grover.flets-west.jp (softbank126026094249.bbtec.net [126.26.94.249]) (authenticated) by conuserg-09.nifty.com with ESMTP id x6KGRfOr009136; Sun, 21 Jul 2019 01:27:42 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com x6KGRfOr009136 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1563640062; bh=YWYhkhyNQMCU9Geqh6mdxj3ov/tBxwsPizahvUIX/a0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BEEnwqfbXR19pOuh8SGXJnppQecZhxjLGO7rcueaPNBJMBeHmFhXoV2yuVP5nSa3F rhRmz/hTIAG7AacdWnf5hnkBuuvHsSJ3Je8hdQ9+nYsAbC9TdHtIYt7iNbqaGCdjuw nIZrRjFbpOheuDQeWBJ/tqq9dVnKmm8UGdgH9ONM3KhK4RaXZcRk+ny39u8xnloylD 5PQJxrykWKviZioQq32/JNXDM5vgZV1wTifngvAe3BIrLQmh5/aeVyd2qoNAS2jPuc tmAU1qDvakt0y1OQ9DmomwmywpeOdnRgajPxo7S0enjqmHSUvBssY4GOEDKvmMVN+8 GllZ+WwU8+BYg== X-Nifty-SrcIP: [126.26.94.249] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] kbuild: make bison create C file and header in a single pattern rule Date: Sun, 21 Jul 2019 01:27:39 +0900 Message-Id: <20190720162740.4292-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190720162740.4292-1-yamada.masahiro@socionext.com> References: <20190720162740.4292-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We generally expect bison to create not only a C file, but also a header, which will be included from the lexer. Currently, Kbuild generates them in separate rules. So, for instance, when building Kconfig, you will notice bison is invoked twice: HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o LEX scripts/kconfig/lexer.lex.c YACC scripts/kconfig/parser.tab.h HOSTCC scripts/kconfig/lexer.lex.o YACC scripts/kconfig/parser.tab.c HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTLD scripts/kconfig/conf Make handles such cases nicely in pattern rules [1]. Merge the two rules so that one invokcation of bison can generate both of them. HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o LEX scripts/kconfig/lexer.lex.c YACC scripts/kconfig/parser.tab.[ch] HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTLD scripts/kconfig/conf [1] Pattern rule GNU Make manual says: "Pattern rules may have more than one target. Unlike normal rules, this does not act as many different rules with the same prerequisites and recipe. If a pattern rule has multiple targets, make knows that the rule's recipe is responsible for making all of the targets. The recipe is executed only once to make all the targets. When searching for a pattern rule to match a target, the target patterns of a rule other than the one that matches the target in need of a rule are incidental: make worries only about giving a recipe and prerequisites to the file presently in question. However, when this file's recipe is run, the other targets are marked as having been updated themselves." https://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html Signed-off-by: Masahiro Yamada --- scripts/Makefile.lib | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 8625e9b4572c..6c4a2332f6d6 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -199,18 +199,12 @@ $(obj)/%.lex.c: $(src)/%.l FORCE # YACC # --------------------------------------------------------------------------- -quiet_cmd_bison = YACC $@ - cmd_bison = $(YACC) -o$@ -t -l $< +quiet_cmd_bison = YACC $(basename $@).[ch] + cmd_bison = $(YACC) -o $(basename $@).c --defines=$(basename $@).h -t -l $< -$(obj)/%.tab.c: $(src)/%.y FORCE +$(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE $(call if_changed,bison) -quiet_cmd_bison_h = YACC $@ - cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l $< - -$(obj)/%.tab.h: $(src)/%.y FORCE - $(call if_changed,bison_h) - # Shipped files # ===========================================================================