From patchwork Fri Feb 22 07:40:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 158990 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1421334jaa; Thu, 21 Feb 2019 23:40:27 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibec0IU6Hz+o9tTq4Kk4bWlqg1aP6DikFg2mcbp4XezbcZL1AzcB842B6NWIdwXyne7DALu X-Received: by 2002:a62:be02:: with SMTP id l2mr2871313pff.55.1550821226912; Thu, 21 Feb 2019 23:40:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550821226; cv=none; d=google.com; s=arc-20160816; b=nY26cesRVZti9TrZekolCjiHEA3WuJpWt/8+NafGhx76X3hdYjwBzL1L7t56ETGi3N nPxe6dw9rWPn/Xs/PDYOejy7sctOJQfSlz0urnuQp/92oth7IgvmkbxHNmQU7lIVswHu S1YrINWRz33Hm6nXN3mlCat9sz1vN/Is04YDUE+41uFvucSYWNcWrurlTUK8h/zq+0vz uORcisD1raeacFBWgQXi4Miis7SYzODtP28/HvNuRefghp158WNpulk4zkZTQfskkU44 TeDxQ+TnklE0QGCJXtL9RWLv8A1gRMLJ5GG4L+g4doUjpdxxR1q2hHHdP0BMbffnMSPX rc7Q== 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=ShLhb3WIzeeB+W+Duw3DHWEdsX60HCOwaHOO2R3ie0k=; b=xHIp6NuaRt4y2yNCFisLk9SN0xqTGFRPBaF104oOQ2TjiQhSwHPIisXGwVao7CPQGM pdfhZHp+acYdkORbI0uZv9j5gBQzDmNcWMKXPaO6XY0C1poLS4xkUR3TjxYLpuIRl1BX YOLEq7zJMjkgoaJAkTVRQS6B+wMEhzciPLghS7QlFt+I1lno1ainbF91ccaagTDRnIRH 9wYc9DmgGF+Oeu2HZnOBwxL6fPbF4daUUspcUdzxomcb5K5r40vq13I23VZupRboa/kg odNwbmoE/4D9t9Wx66yaQQbguq/dj+GDFRj6ZfjmFE1PZ8taYa2xmRIYBwvXSokybFAb WY2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=qJcl0Md1; 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 25si765370pgt.419.2019.02.21.23.40.26; Thu, 21 Feb 2019 23:40:26 -0800 (PST) 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=qJcl0Md1; 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 S1726648AbfBVHkZ (ORCPT + 32 others); Fri, 22 Feb 2019 02:40:25 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:53325 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbfBVHkW (ORCPT ); Fri, 22 Feb 2019 02:40:22 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1M7eEN1013122; Fri, 22 Feb 2019 16:40:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1M7eEN1013122 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550821215; bh=ShLhb3WIzeeB+W+Duw3DHWEdsX60HCOwaHOO2R3ie0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qJcl0Md10oQcoXayGlWXNY+W8O17qfDDowqRNY21BFSSaJW1JNH/kZ4PnY+mjDwMy 6ho86dwoE6PzWBTMmChQaNCGhTuKzMOqYk0MjoOBtOTJKCkp+jsy7JzQJXSSIrZV3X p+RJj/+mqn7jnCdLUKsiTbCSxIajc/hggYCWsJltvw+NvBZxtO9buY5Q3U47RmLs9E KUtXSAm3Bmb3UVFmDn6LVtw9jtamhd0DrV/TewFR4e4jFF8TpVOCqa8zz06CpUqxSo oZt2vv+CirwZl50AIpUup0UWy+lAkkmsf/qOA8cTg1wJYJwsd/KIa4NrZOgAforUD7 qHVoAmczjamNw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] kbuild: make -r/-R effective in top Makefile for old Make versions Date: Fri, 22 Feb 2019 16:40:07 +0900 Message-Id: <1550821211-30324-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> References: <1550821211-30324-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 Adding -rR to MAKEFLAGS is important because we do not want to be bothered by built-in implicit rules or variables. One problem that used to exist in older GNU Make versions is MAKEFLAGS += -rR ... does not become effective in the current Makefile. When you are building with O= option, it becomes effective in the top Makefile since it recurses via 'sub-make' target. Otherwise, the top Makefile tries implicit rules. That is why we explicitly add empty rules for Makefiles, but we often miss to do that. In fact, adding -d option to older GNU Make versions shows it is trying a bunch of implicit pattern rules. Considering target file `scripts/Makefile.kcov'. Looking for an implicit rule for `scripts/Makefile.kcov'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.o'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.c'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.cc'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.C'. ... This issue was fixed by GNU Make commit 58dae243526b ("[Savannah #20501] Handle adding -r/-R to MAKEFLAGS in the makefile"). So, it is no longer a problem if you use GNU Make 4.0 or later. However, older versions are still widely used. So, I decided to patch the kernel Makefile to invoke sub-make regardless of O= option. This will allow further cleanups. Signed-off-by: Masahiro Yamada --- Changes in v2: - Rename KBUILD_SUBMAKE to sub-make-done Makefile | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 82091b8..f0bc078 100644 --- a/Makefile +++ b/Makefile @@ -15,19 +15,6 @@ NAME = Shy Crocodile PHONY := _all _all: -# Do not use make's built-in rules and variables -# (this increases performance and avoids hard-to-debug behaviour) -MAKEFLAGS += -rR - -# Avoid funny character set dependencies -unexport LC_ALL -LC_COLLATE=C -LC_NUMERIC=C -export LC_COLLATE LC_NUMERIC - -# Avoid interference with shell env settings -unexport GREP_OPTIONS - # We are using a recursive build, so we need to do a little thinking # to get the ordering right. # @@ -44,6 +31,21 @@ unexport GREP_OPTIONS # descending is started. They are now explicitly listed as the # prepare rule. +ifneq ($(sub-make-done),1) + +# Do not use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour) +MAKEFLAGS += -rR + +# Avoid funny character set dependencies +unexport LC_ALL +LC_COLLATE=C +LC_NUMERIC=C +export LC_COLLATE LC_NUMERIC + +# Avoid interference with shell env settings +unexport GREP_OPTIONS + # Beautify output # --------------------------------------------------------------------------- # @@ -111,7 +113,6 @@ export quiet Q KBUILD_VERBOSE # KBUILD_SRC is not intended to be used by the regular user (for now), # it is set on invocation of make with KBUILD_OUTPUT or O= specified. -ifeq ($(KBUILD_SRC),) # OK, Make called in directory where kernel src resides # Do we want to locate output files in a separate directory? @@ -141,6 +142,13 @@ $(if $(KBUILD_OUTPUT),, \ # 'sub-make' below. MAKEFLAGS += --include-dir=$(CURDIR) +else + +# Do not print "Entering directory ..." at all for in-tree build. +MAKEFLAGS += --no-print-directory + +endif # ifneq ($(KBUILD_OUTPUT),) + PHONY += $(MAKECMDGOALS) sub-make $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make @@ -148,16 +156,12 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make # Invoke a second make in the output directory, passing relevant variables sub-make: - $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ + $(Q)$(MAKE) sub-make-done=1 \ + $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \ -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) -# Leave processing to above invocation of make -skip-makefile := 1 -endif # ifneq ($(KBUILD_OUTPUT),) -endif # ifeq ($(KBUILD_SRC),) - +else # sub-make-done # We process the rest of the Makefile if this is the final invocation of make -ifeq ($(skip-makefile),) # Do not print "Entering directory ...", # but we want to display it when entering to the output directory @@ -1766,7 +1770,7 @@ $(cmd_files): ; # Do not try to update included dependency files endif # ifeq ($(config-targets),1) endif # ifeq ($(mixed-targets),1) -endif # skip-makefile +endif # sub-make-done PHONY += FORCE FORCE: