summaryrefslogtreecommitdiff
path: root/tools/functions.make
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-05-12 19:50:56 +1000
committerAmaury Pouly <amaury.pouly@gmail.com>2017-05-12 20:28:57 +1000
commitb959655822df6c5610372c9da54ea93f93ac87e9 (patch)
treef24104fb9da7a911ba7c9fb8a3e0137ddc7d1eac /tools/functions.make
parent65c6a14e5fa41906176f93aa04512508e719d970 (diff)
downloadrockbox-b959655822df6c5610372c9da54ea93f93ac87e9.tar.gz
rockbox-b959655822df6c5610372c9da54ea93f93ac87e9.zip
Fix unsafe substitutions in Makefile.
Strange things can happen in the (unlikely) case that ROOTDIR=/rockbox Change-Id: I085f928fd859b307667e8fccf40b29a9c325f7ae
Diffstat (limited to 'tools/functions.make')
-rw-r--r--tools/functions.make15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/functions.make b/tools/functions.make
index 2a26e48bf2..806e1a2f3e 100644
--- a/tools/functions.make
+++ b/tools/functions.make
@@ -73,3 +73,18 @@ ifeq ($(call info),old)
73export info=echo "$$(1)"; 73export info=echo "$$(1)";
74endif 74endif
75 75
76# path substituion can be surprisingly tricky, indeed the following almost
77# always work but not quite:
78# BMPOBJ = $(BMP:$(ROOTDIR)/%.bmp=$(BUILDDIR)/%.o)
79# indeed if
80# ROOTDIR=/rockbox
81# BUILDDIR=/rockbox/build-bla
82# then:
83# /rockbox/apps/bitmaps/rockboxlogo-bla.bmp -> /rockbox/apps/bitmaps/rockbox/build-blalogo.o
84# this function ensure that this type of problems does not occur
85#
86# usage: $(call full_path_subst,patterm,replacement,text)
87#
88# example: $(call full_path_subst,$(ROOTDIR)/%.bmp,$(BUILDDIR)/%.o,$(BMP))
89NO_MATCH=this_string_will_never_match_anything
90full_path_subst=$(patsubst $(NO_MATCH)/%,%, $(patsubst $(NO_MATCH)/$(1), $(2), $(addprefix $(NO_MATCH)/, $(3))))