summaryrefslogtreecommitdiffstats
path: root/rules/pre/get_alternative.make
diff options
context:
space:
mode:
Diffstat (limited to 'rules/pre/get_alternative.make')
-rw-r--r--rules/pre/get_alternative.make20
1 files changed, 19 insertions, 1 deletions
diff --git a/rules/pre/get_alternative.make b/rules/pre/get_alternative.make
index f8043639f..c93499162 100644
--- a/rules/pre/get_alternative.make
+++ b/rules/pre/get_alternative.make
@@ -11,7 +11,25 @@
ptx/get-alternative = $(shell ptxd_get_alternative $(1) $(2) && echo $$ptxd_reply)
ptx/get_alternative = $(error ptx/get_alternative has been renamed to ptx/get-alternative)
-ptx/in-path = $(shell ptxd_in_path $(1) $(2) && echo $$ptxd_reply)
+#
+# 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
+define ptx/in-path3
+$(if $(strip $(1)),$(strip $(2)),$(strip $(3)))
+endef
+# fallback to shell if a relative path is found
+define ptx/in-path2
+$(call ptx/in-path3,
+$(filter-out /%,$(3)),
+$(shell p='$($(strip $(1)))' ptxd_in_path p $(2) && echo $$ptxd_reply),
+$(firstword $(wildcard $(addsuffix /$(strip $(2)),$(3)))))
+endef
+# create a path ist from the variable with ':' separated paths
+define ptx/in-path
+$(call ptx/in-path2,$(1),$(2),$(subst :,$(ptx/def/space),$($(strip $(1)))))
+endef
ptx/in-platformconfigdir = $(if $(strip $(1)),$(shell ptxd_in_platformconfigdir $(1)))