Fix unsafe substitutions in Makefile.
Strange things can happen in the (unlikely) case that ROOTDIR=/rockbox Change-Id: I085f928fd859b307667e8fccf40b29a9c325f7ae
This commit is contained in:
parent
65c6a14e5f
commit
b959655822
3 changed files with 17 additions and 2 deletions
|
@ -25,7 +25,7 @@ ifneq ($(strip $(BMP2RB_REMOTENATIVE)),)
|
|||
BMP += $(call preprocess, $(BITMAPDIR)/remote_native/SOURCES)
|
||||
endif
|
||||
|
||||
BMPOBJ = $(BMP:$(ROOTDIR)/%.bmp=$(BUILDDIR)/%.o)
|
||||
BMPOBJ = $(call full_path_subst,$(ROOTDIR)/%.bmp,$(BUILDDIR)/%.o,$(BMP))
|
||||
|
||||
BMPHFILES = $(BMPINCDIR)/usblogo.h $(BMPINCDIR)/remote_usblogo.h \
|
||||
$(BMPINCDIR)/default_icons.h $(BMPINCDIR)/remote_default_icons.h \
|
||||
|
|
|
@ -73,3 +73,18 @@ ifeq ($(call info),old)
|
|||
export info=echo "$$(1)";
|
||||
endif
|
||||
|
||||
# path substituion can be surprisingly tricky, indeed the following almost
|
||||
# always work but not quite:
|
||||
# BMPOBJ = $(BMP:$(ROOTDIR)/%.bmp=$(BUILDDIR)/%.o)
|
||||
# indeed if
|
||||
# ROOTDIR=/rockbox
|
||||
# BUILDDIR=/rockbox/build-bla
|
||||
# then:
|
||||
# /rockbox/apps/bitmaps/rockboxlogo-bla.bmp -> /rockbox/apps/bitmaps/rockbox/build-blalogo.o
|
||||
# this function ensure that this type of problems does not occur
|
||||
#
|
||||
# usage: $(call full_path_subst,patterm,replacement,text)
|
||||
#
|
||||
# example: $(call full_path_subst,$(ROOTDIR)/%.bmp,$(BUILDDIR)/%.o,$(BMP))
|
||||
NO_MATCH=this_string_will_never_match_anything
|
||||
full_path_subst=$(patsubst $(NO_MATCH)/%,%, $(patsubst $(NO_MATCH)/$(1), $(2), $(addprefix $(NO_MATCH)/, $(3))))
|
||||
|
|
|
@ -157,7 +157,7 @@ endif # CORE_GCSECTIONS
|
|||
OBJ := $(SRC:.c=.o)
|
||||
OBJ := $(OBJ:.S=.o)
|
||||
OBJ += $(BMP:.bmp=.o)
|
||||
OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
|
||||
OBJ := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(OBJ))
|
||||
|
||||
build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
|
||||
|
||||
|
|
Loading…
Reference in a new issue