summaryrefslogtreecommitdiffstats
path: root/rules/pre
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2020-07-02 15:12:09 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2020-07-04 09:43:37 +0200
commit4c98175c55035605a3e596798f9b4bb65b8ce1db (patch)
tree9ec8f5b4572a491499a803e2f50bec20703bf73f /rules/pre
parent7fb691e014c06b17c17dffe0d6c5d5f6c2a54403 (diff)
downloadptxdist-4c98175c55035605a3e596798f9b4bb65b8ce1db.tar.gz
ptxdist-4c98175c55035605a3e596798f9b4bb65b8ce1db.tar.xz
ptx/in-path: handle complex cases in make as well
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'rules/pre')
-rw-r--r--rules/pre/000-ptx-search.make18
1 files changed, 10 insertions, 8 deletions
diff --git a/rules/pre/000-ptx-search.make b/rules/pre/000-ptx-search.make
index 1cf0c2541..f34088f2f 100644
--- a/rules/pre/000-ptx-search.make
+++ b/rules/pre/000-ptx-search.make
@@ -11,22 +11,24 @@ ptx/get_alternative = $(error ptx/get_alternative has been renamed to ptx/get-al
#
# This must produce the same results as ptxd_in_path()
-# Fallback to the shell implementation for the complex case
#
-# Strip whitespaces introduced by the multiline macros
+# resolve all possible paths
define ptx/in-path3
-$(if $(strip $(1)),$(strip $(call ptx/force-shell,$(2))),$(strip $(3)))
+$(wildcard $(addsuffix /$(strip $(2)),$(1)))
endef
-# fallback to shell if a relative path is found
+# expand a relative path if found
define ptx/in-path2
$(call ptx/in-path3,
-$(filter-out /%,$(3)),
-p='$($(strip $(1)))' ptxd_in_path p $(2) && echo $$ptxd_reply,
-$(firstword $(wildcard $(addsuffix /$(strip $(2)),$(3)))))
+$(foreach path,$(1),$(if $(filter-out /%,$(path)),
+$(call ptx/in-path-all,PTXDIST_PATH_LAYERS,$(path)),$(path))),$(2))
endef
# create a path ist from the variable with ':' separated paths
+define ptx/in-path-all
+$(call ptx/in-path2,$(subst :,$(ptx/def/space),$($(strip $(1)))),$(2))
+endef
+# take the first result
define ptx/in-path
-$(call ptx/in-path2,$(1),$(2),$(subst :,$(ptx/def/space),$($(strip $(1)))))
+$(firstword $(call ptx/in-path-all,$(1),$(2)))
endef
#