From patchwork Fri Feb 22 07:40:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 158993 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1421586jaa; Thu, 21 Feb 2019 23:40:46 -0800 (PST) X-Google-Smtp-Source: AHgI3IblS2fHKW9+LVnu48i3yJnH023V6J0q/VSHM2mH4NACMyvDmS5qe0IlPePNb+oWcs0YgEjy X-Received: by 2002:a17:902:8c95:: with SMTP id t21mr2786952plo.300.1550821246297; Thu, 21 Feb 2019 23:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550821246; cv=none; d=google.com; s=arc-20160816; b=ccWo9XOBi9DvVPt7J2VshU/UUSiDB1TOH7mE4fC5c/TozS867E8iybPm7K56rpgWEJ CZAYKRNvxsTCZFT0vWehBZeUlhSbT7agdnGaBwORCqQqls/tcfn5HHNL1hzKJ0nP+CmS 4FbNo4+xn87fIawWNJkN70EfKcr2GUBtuJQmxy36LwZA8VwT9F/uRgplsW1EgoEVFYoT KOrSaQdrjlnVNMrbjkHgksgO7ImZUKvRLTKNmjDFFRqa0NmhmFE1SoRT1f8v/F/cIJNl f79BBlLNl+cO0g0nGxKceo9XBEexd7dn+nLbA7rWCRtABRrtW5v5W4fod3AEI1njfZI9 qctg== 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=UcWNwsux7b1JpeJdXT16j2ZgXx6alk2fUysrOhB9agQ=; b=0TmwfDfoYTlPZCyVqp2LKazZeW8kL89BIfrCB5JJR82XUF3vdFNoXihzHwUyBh5C35 bASRR+UCzRr9k5zw9E1AMe6Re508fGZSTrqNIJssyged45bMmRTBfQx1tGeQuN8Q65vC kKn91Emg6JRtt/bbKB8qipjHGmohUgy0nXNQcRUYAJKkCOoPyZRJjBgrTqC9K6h/s1pN LG6CkqoLeP7wD9z2NHN53bjbZ6gl8sWamPFfHjtsIEp2rmhFu0Fop5ThXpQuiWLHNpdM ZtnTqw0rW0tlrIeH2Hprmlq/OZyi3A/qQ0l/8aWrA66oLSgRn5D4tJFshQT8HTW/K+3u X6WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=d1VCRaOU; 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 128si734459pgb.373.2019.02.21.23.40.44; Thu, 21 Feb 2019 23:40:46 -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=d1VCRaOU; 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 S1726890AbfBVHkn (ORCPT + 32 others); Fri, 22 Feb 2019 02:40:43 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:53323 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725894AbfBVHkW (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 x1M7eEN3013122; Fri, 22 Feb 2019 16:40:16 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1M7eEN3013122 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550821216; bh=UcWNwsux7b1JpeJdXT16j2ZgXx6alk2fUysrOhB9agQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d1VCRaOUNPYV1EmPwqZ2gKCkt7j4bSA6poEYuGWUcvxPOg9a+Igydih6CmYtl/T12 /tAUcE1p6hv3o6AZBCecFoy2oG/HRE2uIt1QIXrXYZVHBw3vNs+zAxhgArylt4GJFd wp92HZ9Ju5ph5ZYc/FIRKzcnnF3EzJT3RZm1hAAEM6krFIyUb0Soqv1iDk5cU6TeU2 Ny8X4wV3Jo9zIQ+nIiPRosnZQtFZOBLUj2R46SEl8eRM8qcylSG9XiJ+8d3NOft8X5 167HDIJLYNsmVJrMN8A27kLRQvdNHZLuaawYY2+3DepfmBCFx7vD4Ks3dUvCAQAXyN rqLZ1JLb8/mSA== 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 4/6] kbuild: simplify single target rules Date: Fri, 22 Feb 2019 16:40:09 +0900 Message-Id: <1550821211-30324-4-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 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 presence of the source file, which is located in in the external module directory. One good thing is, it can compile an object from a generated source file. $ make crypto/rsapubkey.asn1.o ... ASN.1 crypto/rsapubkey.asn1.c CC crypto/rsapubkey.asn1.o Signed-off-by: Masahiro Yamada --- Changes in v2: - Do not merge pattern rules Makefile | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 538a4f1..4d8516e 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 @@ -1703,31 +1703,23 @@ 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: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.ll: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.lst: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.o: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.s: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.symtypes: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.ko: %.o + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost # Modules PHONY += / @@ -1737,9 +1729,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 # ===========================================================================