summaryrefslogtreecommitdiff
path: root/Makefile.inc
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2018-07-02 18:19:40 +0200
committerPatrick Georgi <pgeorgi@google.com>2018-07-04 08:57:40 +0000
commitafc74cab6ec05ed515252e0b5da94598c3c80867 (patch)
tree734c266c237f008a20c5891b0bdb1af49d18a5ca /Makefile.inc
parent7d48ac5c7dfb52fc470bbad1013b4d460bc6a1e0 (diff)
downloadcoreboot-afc74cab6ec05ed515252e0b5da94598c3c80867.tar.xz
Makefile.inc: Rewrite $(files-in-dir)
The `files-in-dir` macro is supposed to return all files (out of a given set) that reside directly (non-recursive) in a given directory. While the current solution worked splendidly, we can achieve the same without recursive macros that look at each parent dir individually. Beside providing better readability, this also fixes a future make error, as make doesn't like the variable name ` ` anymore ;) Change-Id: Iac0eacdf91b8b5098592ad301c1f3fdb632454e9 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/27324 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Patrick Georgi <pgeorgi@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'Makefile.inc')
-rw-r--r--Makefile.inc26
1 files changed, 8 insertions, 18 deletions
diff --git a/Makefile.inc b/Makefile.inc
index 6eacb20029..bf6c4f0103 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -155,29 +155,19 @@ ws_to_under=$(shell echo '$1' | tr ' \t' '_')
# Helper functions for ramstage postprocess
spc :=
spc +=
-$(spc) :=
-$(spc) +=
comma := ,
-# files-in-dir-recursive,dir,files
-files-in-dir-recursive=$(filter $(1)%,$(2))
+# Returns all files and dirs below `dir` (recursively).
+# files-below-dir,dir,files
+files-below-dir=$(filter $(1)%,$(2))
-# parent-dir,dir/
-parent-dir=$(dir $(if $(patsubst /%,,$(1)),,/)$(subst $( ),/,$(strip $(subst /, ,$(1)))))
-
-# filters out exactly the directory specified
-# filter-out-dir,dir_to_keep,dirs
-filter-out-dir=$(filter-out $(1),$(2))
-
-# filters out dir_to_keep and all its parents
-# filter-out-dirs,dir_to_keep,dirs
-filter-out-dirs=$(if $(filter-out ./ /,$(1)),$(call filter-out-dirs,$(call parent-dir,$(1)),$(call filter-out-dir,$(1),$(2))),$(call filter-out-dir,$(1),$(2)))
-
-# dir-wildcards,dirs
-dir-wildcards=$(addsuffix %,$(1))
+# Returns all dirs below `dir` (recursively).
+# dirs-below-dir,dir,files
+dirs-below-dir=$(filter-out $(1),$(sort $(dir $(call files-below-dir,$(1),$(2)))))
+# Returns all files directly in `dir` (non-recursively).
# files-in-dir,dir,files
-files-in-dir=$(filter-out $(call dir-wildcards,$(call filter-out-dirs,$(1),$(sort $(dir $(2))))),$(call files-in-dir-recursive,$(1),$(2)))
+files-in-dir=$(filter-out $(addsuffix %,$(call dirs-below-dir,$(1),$(2))),$(call files-below-dir,$(1),$(2)))
#######################################################################
# reduce command line length by linking the objects of each