[PATCH 1/3] kbuild: Add wilddt function
From: Leonard Crestez
Date: Mon Jan 07 2019 - 14:31:40 EST
Many SOCs have very simple naming conventions for all boards using a
certain chip and long dtb lists can be collapsed using wildcards.
Since this applied to many architectures add a wilddt function to
Kbuild.include. Example usage:
dtb-$CONFIG_SOC_ABC123 += $(call wilddt,abc123-*)
Signed-off-by: Leonard Crestez <leonard.crestez@xxxxxxx>
---
scripts/Kbuild.include | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 46bf1a073f5d..6b8c0cca07c1 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -197,10 +197,16 @@ clean := -f $(srctree)/scripts/Makefile.clean obj
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.headersinst obj=
# Usage:
# $(Q)$(MAKE) $(hdr-inst)=dir
hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
+###
+# Return list of .dtb for all .dts matching $1 in current directory
+#
+# Example usage: dtb-$CONFIG_SOC_ABC123 += $(call wilddt,abc123-*)
+wilddt = $(patsubst $(srctree)/$(src)/%.dts,%.dtb, $(wildcard $(srctree)/$(src)/$(1).dts))
+
# Prefix -I with $(srctree) if it is not an absolute path.
# skip if -I has no parameter
addtree = $(if $(patsubst -I%,%,$(1)), \
$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1))
--
2.17.1