From patchwork Thu Apr 6 18:18:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnout Vandecappelle X-Patchwork-Id: 747929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vzWG90l1Sz9s7g for ; Fri, 7 Apr 2017 04:20:00 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 228F586978; Thu, 6 Apr 2017 18:19:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T+60R27OXnCu; Thu, 6 Apr 2017 18:19:49 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 1A5DE86972; Thu, 6 Apr 2017 18:19:32 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 74F9D1C276A for ; Thu, 6 Apr 2017 18:19:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6D1F888B4F for ; Thu, 6 Apr 2017 18:19:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vev2lAlxkgIJ for ; Thu, 6 Apr 2017 18:19:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exchange.essensium.com (220.77.144.195.ipv4.evonet.be [195.144.77.220]) by hemlock.osuosl.org (Postfix) with ESMTPS id D18AE88B3E for ; Thu, 6 Apr 2017 18:19:16 +0000 (UTC) Received: from vandecaa-laptop.septentrio.local (10.3.4.134) by beleexch01.local.ess-mail.com (10.3.7.8) with Microsoft SMTP Server (TLS) id 15.0.847.32; Thu, 6 Apr 2017 20:18:56 +0200 From: "Arnout Vandecappelle (Essensium/Mind)" To: Date: Thu, 6 Apr 2017 20:18:45 +0200 Message-ID: <20170406181854.5242-5-arnout@mind.be> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.3.4.134] X-ClientProxiedBy: beleexch01.local.ess-mail.com (10.3.7.8) To beleexch01.local.ess-mail.com (10.3.7.8) Subject: [Buildroot] [PATCH v5 05/13] Makefile: support defconfigs in subdirectories X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The pattern rule %_defconfig doesn't support a pattern that includes a / because of the following weird make behavior. From the GNU make info page: When the target pattern does not contain a slash (and it usually does not), directory names in the file names are removed from the file name before it is compared with the target prefix and suffix. After the comparison of the file name to the target pattern, the directory names, along with the slash that ends them, are added on to the prerequisite file names generated from the pattern rule's prerequisite patterns and the file name. In other words, foo/bar_defconfig would depend on foo/configs/bar_defconfig instead of configs/foo/bar_defconfig. As a workaround, introduce an intermediate target that does contain a / and where the pattern is at the beginning: %/.../defconfig. Since this target does contain a /, the weird splitting of the pattern doesn't occur and we can make that target depend on .../configs/%_defconfig. It gets slightly more complicated still because chains of pattern rules only work if they all have commands. So we need to add a dummy command for the %_defconfig rule. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 941bf789c8..1d377099b2 100644 --- a/Makefile +++ b/Makefile @@ -895,10 +895,17 @@ defconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN) define percent_defconfig +# Introduce a phony intermediate target to handle / in the pattern. +# make puts anything up to the / in the beginning if the target pattern doesn't +# contain a /. Without the intermediate, foo/bar_defconfig would depend on +# foo/$(1)/configs/bar_defconfig instead of $(1)/configs/foo/bar_defconfig. +.PHONY: %$(1)/defconfig +%_defconfig: %$(1)/defconfig + @: dummy command to make chain of phony targets work # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig -%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig prepare-kconfig - @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \ - $$< --defconfig=$(1)/configs/$$@ $$(CONFIG_CONFIG_IN) +%$(1)/defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig prepare-kconfig + @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$*_defconfig \ + $$< --defconfig=$(1)/configs/$$*_defconfig $$(CONFIG_CONFIG_IN) endef $(eval $(foreach d,$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(call percent_defconfig,$(d))$(sep)))