Received: by 10.213.65.68 with SMTP id h4csp352843imn; Fri, 23 Mar 2018 06:08:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELsv06APL4OgZ/zxrtuqJoMY0aHlgCe2Jr82qT0XDOBxVPEMRwdqh6Vb4GDEObmlgCrvuPzx X-Received: by 10.98.34.143 with SMTP id p15mr24194102pfj.101.1521810523945; Fri, 23 Mar 2018 06:08:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521810523; cv=none; d=google.com; s=arc-20160816; b=tjA3zy6qlOQYTJo+SLJfJEM70tTTWEtsGpZGXaIVURI/iCrGe1HwWruOU3DFRFB+19 D9yFprZe+gcsRiMBrGjfU+AtFZ2EabYvJiKxc25lFRHzsq9h4Yp9Vb2MFEpFw1+knWOF yW3UdEwiNdxfWFZbdn9j+xYRUlyM0ZBE4B2/PwDYsvmxVATI1xhlkG+8/T9tA57ZeQQe W+dB5dAwzkEOO7YI5C2TYPF2Szncd4FgBO4uZRxMSoqnBtXAPsCc9e2nbrUeYd8gbzzR oHTRJ5ZwjxC9D2xmxQ2mEK8GS+C6e+mUmqlsdSH5Izrbka2ZQsrLAHmmivBpeLTh2DcN Hu5A== 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 :arc-authentication-results; bh=DwwYFANYX+7H0Q7EceUQKHOsircWw6SAo0JHCHQ05CE=; b=pwbQ7i6h2GigiKKsoRRqHBi50okG4EPo6rQhDPw7m5+EDb3Wmx8RXt0zAKFmUmpGvf f5yVItowMgow3Dm2mMJIx3JKUGlT+SBVikGS2n63i6vupy2QB0YKVTdpYMNwbKogJs12 lc8Yo7Bfvg5DIL5AWBIAntEMB0yk27WowOJafgpjxZjB8BR4Yy1YaGfuwser1JE4ezFt uK4L3hScLOMOdqDVJC6gQLu0nvg5jAaygJ3KhnRLnZTM0idD/YztPcxOGz1IQSWhP8Zw MeM9gprGecXKKJ7TJLv+gk+7WGbOFaE11BbFIIZa6VmJExOLedRk639CwO3nWEC1tOMB OM+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Sdi+wt1l; 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 p3si6013227pgc.776.2018.03.23.06.08.14; Fri, 23 Mar 2018 06:08:43 -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=Sdi+wt1l; 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 S1753303AbeCWNGS (ORCPT + 99 others); Fri, 23 Mar 2018 09:06:18 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:53108 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752002AbeCWNGP (ORCPT ); Fri, 23 Mar 2018 09:06:15 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id w2ND4mga011418; Fri, 23 Mar 2018 22:05:04 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w2ND4mga011418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1521810307; bh=DwwYFANYX+7H0Q7EceUQKHOsircWw6SAo0JHCHQ05CE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sdi+wt1llmEx+kEEiEAVEzlc4524qlr1DCpTytttS4WeetFPRSoY4JRgKDmDtIHDA sAnVq8jDFrMhml3OcG2HCwql5fiTSjBQjRFZJUScCzP+D5Tv18VT9TT0GkKtsFmHoc OBiuTcb9lNPd4pxNDjtLMlynbMVR7owBecGKrxtLx26HMwL6rhI36eatZfH7FSIqHt /jV6VxOtWdhlh1mFf9tjR0qhQGNDNVkW7ZUbpKDSUZJ+cIBrwlJf5vx4Yut7drH3T1 Co/x/zPWwnjy5Nwsrk3zwb0rHYFdjfeDa51qSrx5JxrO0b203NPx6bRBNSoyoRbRDv F8KMvB20q6zVA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , linux-kernel@vger.kernel.org, Arnd Bergmann , Laurent Pinchart , Frank Rowand , Geert Uytterhoeven , Masahiro Yamada Subject: [PATCH 04/10] kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically Date: Fri, 23 Mar 2018 22:04:33 +0900 Message-Id: <1521810279-6282-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521810279-6282-1-git-send-email-yamada.masahiro@socionext.com> References: <1521810279-6282-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Files generated by if_changed* must be added to 'targets' to include *.cmd files. Otherwise, they would be regenerated every time. The build system automatically adds objects to 'targets' where appropriate, such as obj-y, extra-y, etc. but does nothing for intermediate files. So, each Makefile needs to add them by itself. There are some common cases where objects are generated by chained rules. Lexers and parsers are compiled like follows: %.lex.o <- %.lex.c <- %.l %.tab.o <- %.tab.c <- %.y They are common patterns, so it is reasonable to take care of them in the core Makefile instead of requiring each Makefile to do so. At this moment, you cannot delete 'target += zconf.lex.c' because zconf.lex.c is included from zconf.tab.c instead of being compiled. This will be possible with further refactoring in the future. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 11 +++++++++++ scripts/dtc/Makefile | 3 --- scripts/genksyms/Makefile | 2 -- scripts/kconfig/Makefile | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 77cce68..36f7990 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -538,6 +538,17 @@ $(call multi_depend, $(multi-used-m), .o, -objs -y -m) targets += $(multi-used-m) targets := $(filter-out $(PHONY), $(targets)) +# Add intermediate targets: +# When building objects with specific suffix patterns, add intermediate +# targets that the final targets are derived from. +intermediate_targets = $(foreach sfx, $(2), \ + $(patsubst %$(strip $(1)),%$(sfx), \ + $(filter %$(strip $(1)), $(targets)))) +# %.lex.o <- %.lex.c <- %.l +# %.tab.o <- %.tab.[ch] <- %.y +targets += $(call intermediate_targets, .lex.o, .lex.c) \ + $(call intermediate_targets, .tab.o, .tab.c .tab.h) + # Descending # --------------------------------------------------------------------------- diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index d17ba64..9cac65b 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile @@ -27,6 +27,3 @@ HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) # dependencies on generated files need to be listed explicitly $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h - -# generated files need to include *.cmd -targets := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile index f4749e8..aeefd47 100644 --- a/scripts/genksyms/Makefile +++ b/scripts/genksyms/Makefile @@ -32,5 +32,3 @@ HOSTCFLAGS_lex.lex.o := -I$(src) # dependencies on generated files need to be listed explicitly $(obj)/lex.lex.o: $(obj)/parse.tab.h - -targets := lex.lex.c parse.tab.c parse.tab.h diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 1dcd797..5def877 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -207,7 +207,7 @@ gconf-objs := gconf.o zconf.tab.o hostprogs-y := conf nconf mconf kxgettext qconf gconf -targets += zconf.tab.c zconf.lex.c +targets += zconf.lex.c clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck clean-files += gconf.glade.h clean-files += config.pot linux.pot -- 2.7.4