From patchwork Thu Feb 14 03:05:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 158294 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp834943jaa; Wed, 13 Feb 2019 19:06:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IaCjoA29zhFWI90pn3ZzeCNgvlGdtOIKi40wbxoaiadMvEcdAvtTnHnVTMavIG/UwnT+UvT X-Received: by 2002:a17:902:778d:: with SMTP id o13mr1722261pll.234.1550113585343; Wed, 13 Feb 2019 19:06:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550113585; cv=none; d=google.com; s=arc-20160816; b=QmYwufu7seGTmqAbNOyZg8UfAYKQcSRBLqsqBaaq/30lXCba8cEZWMx0z3t7utF56B /TVRDjNzQ3oLptIzMnTkNuI6h2WG8sS3X6hedj3eksEq1dKugy7vN6BlWYSlSnZsUkJS JtHBTeE2CTPo+9jE1lwbk8iqtDIuRo61M2Qu+IXKX/SP7oigW2XXf2qsTMeId5uf89AA tQfNdCmGKsz0MaJsubBQn/zw2SF+Ib5KnXzDu0z8qqs5lsc9kbHf951InXGxr3/v1XSp CHI3D2Kpt+2J4UOXx4rjN5tkiNkLNRq3CywIRiq0U+fEyFwIPtKHjFEXLGyHrM89MOF3 fvTQ== 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=VnFzu1pRBkse1rgGgc43E28soFZDRai0oiY6uEajTrc=; b=LSJVqHXmwF9tVFqHY/hVt6qJw5tN4KomqVXcXIyLMW/pDGocSeRZZu7F3F9ETUUC2e bDD9L2L6TB7tfPhjbVBCPVh8dRZzrH+vbVa6Iiaw7/HubnAyMW432n9cm4VHapkMUgcR 9Vq3f45icc9pVLRBqDM1lslzT+yzXqRP3vskc25viH5fUDvLnNEwioauDPgQc/qc6oz9 /Nwq2O09nXDgfOyPkDyQhkN+md8QNTQAsXxdfLx++Sth7PqYZOOxjoUHlI5OB0SlOvzR maRlr4Lb5C7dzWPJRwUKJKYgmFFUbohWHxx0qR5TXq0ePcPCvYDi1k3Pn9JZwwZKKphw nDTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=o9Udx84v; 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 e9si1125330pgk.173.2019.02.13.19.06.25; Wed, 13 Feb 2019 19:06:25 -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=o9Udx84v; 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 S2405244AbfBNDGX (ORCPT + 31 others); Wed, 13 Feb 2019 22:06:23 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64386 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393527AbfBNDGG (ORCPT ); Wed, 13 Feb 2019 22:06:06 -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 x1E35Pg9020814; Thu, 14 Feb 2019 12:05:30 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1E35Pg9020814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550113530; bh=VnFzu1pRBkse1rgGgc43E28soFZDRai0oiY6uEajTrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o9Udx84v3yeIM0EAKBWQuWLIjCN5zZoaes7EcO/oM3OqAil+9BT3IM8dWkAQZVOez A6xzIGv4dQjpPG4qm7Apl4rCZV75ZHN4jNNOKcRZQospeyxDXuUdvQY6TSUHRrE2dA 5u6iVZwUNa5TYa6H4fHf//Id/NaiOnO5b8nWLGPtY8MgsM3wymuzgI+m7J0bHvmdOX MHZpc4mwPBey7X6YpF9WEForOxFl8IdNVUqdQxckfSRMlpHNSEnsbUCT1jSFij8mZz mBhkswIpVFnP+89h3pTKIfaVgGg74pnXYLHIurShSmFk3LR57wpUvJZmfKug5jhVZl h06Vnc05KqBkg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 8/8] kbuild: simplify single targets Date: Thu, 14 Feb 2019 12:05:21 +0900 Message-Id: <1550113521-23577-8-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550113521-23577-1-git-send-email-yamada.masahiro@socionext.com> References: <1550113521-23577-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 The dependency will be checked anyway after Kbuild descends into a sub-directory. Skip object/source dependency checks in top Makefile. VPATH can be simpler since the top Makefile no longer checks the preprense of the source file, which is located in in the external module directory. [Pros] - Code is cleaner - It can compile an object from a generated source file For example, $ make crypto/rsapubkey.asn1.o ... ASN.1 crypto/rsapubkey.asn1.c CC crypto/rsapubkey.asn1.o [Cons] - The top Makefile does not let it fail immediately when a user tries to build a wrong object. Signed-off-by: Masahiro Yamada --- Makefile | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index f7f1aa1..8bf0ed6 100644 --- a/Makefile +++ b/Makefile @@ -219,7 +219,7 @@ objtree := . src := $(srctree) obj := $(objtree) -VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) +VPATH := $(srctree) export srctree objtree VPATH @@ -1686,31 +1686,14 @@ tools/%: FORCE # target-dir => where to store outputfile # build-dir => directory in kernel source tree to use -ifeq ($(KBUILD_EXTMOD),) - build-dir = $(patsubst %/,%,$(dir $@)) - target-dir = $(dir $@) -else - zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) - build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) - target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) -endif - -%.s: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.i: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.o: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.lst: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.s: %.S prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.o: %.S prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.symtypes: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.ll: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +build-target = $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD)/)$@ +build-dir = $(patsubst %/,%,$(dir $(build-target))) + +%.i %.ll %.lst %.o %.s %.symtypes: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) + +%.ko: %.o + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost # Modules PHONY += / @@ -1720,9 +1703,6 @@ PHONY += / Documentation/ samples/: headers_install %/: prepare FORCE $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) -%.ko: prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(@:.ko=.o) - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost # FIXME Should go into a make.lib or something # ===========================================================================