From patchwork Fri Mar 23 13:04:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 132331 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp571128ljb; Fri, 23 Mar 2018 06:06:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELurilvg1mcSFRQ70S2FXwk6yt3xI+rjPS9N4lepyUgTENrMi1nbeSXPgAm1Ns3ZnVG76kdL X-Received: by 2002:a17:902:c1:: with SMTP id a59-v6mr29079984pla.284.1521810382504; Fri, 23 Mar 2018 06:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521810382; cv=none; d=google.com; s=arc-20160816; b=qTxCF1ex+VLF6xkynFV+O2Vnb4cyCm3SSG+Z/7kV+nV6WSv6fwIe6oPul+tW9Juiea rzcZt3TkBqT6PqqWADy7FbiatBSqAdo3qLPN7L3Ya8llbCSgr3SKbzC3xWFo5WZF+b+h QR+64sSG9+8KKRxqSJT1Rbb7F5EKGfdQw3hM9nLfr24Eb1RFRp7xuAftVZ51JkSxLL/B 1vo881saN1GoMqdlv0P+26Pc92WEb/qYx7AXnwQA5BLsQx755KDtdREeVd2aV/7k3BM6 wRRvleoI6mzvxdBofDLTosJTCdgUI4FZJlHpCWxHvBBO2pqF/6XO9PurhiYl2mkE1TiJ v3pg== 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 l8si5424771pgr.187.2018.03.23.06.06.22; Fri, 23 Mar 2018 06:06:22 -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 S1753307AbeCWNGS (ORCPT + 28 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(-) -- 2.7.4 Acked-by: Frank Rowand 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