Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] Makefile: support defconfigs in subdirectories
@ 2017-03-26 19:43 Arnout Vandecappelle
  2017-03-26 19:43 ` [Buildroot] [PATCH 2/2] configs: add autobuild configs Arnout Vandecappelle
  0 siblings, 1 reply; 4+ messages in thread
From: Arnout Vandecappelle @ 2017-03-26 19:43 UTC (permalink / raw)
  To: 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) <arnout@mind.be>
---
 Makefile | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index cceae92a26..96c4d10cb3 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)))
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-26 21:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-26 19:43 [Buildroot] [PATCH 1/2] Makefile: support defconfigs in subdirectories Arnout Vandecappelle
2017-03-26 19:43 ` [Buildroot] [PATCH 2/2] configs: add autobuild configs Arnout Vandecappelle
2017-03-26 20:03   ` Thomas Petazzoni
2017-03-26 21:40     ` Arnout Vandecappelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox