Use full_path_subst on more places, to avoid replacing the wrong occurrences in
paths.

If ROOTDIR=/rockbox and BUILDDIR=/rockbox/build-something, it is now possible to
successfully build both target binaries and simulators.

Change-Id: If12d1d5933c5a15feebf627a4f1636dc1e3a67fa
diff --git a/apps/plugins/bitmaps/pluginbitmaps.make b/apps/plugins/bitmaps/pluginbitmaps.make
index 85536ed..78294a5 100644
--- a/apps/plugins/bitmaps/pluginbitmaps.make
+++ b/apps/plugins/bitmaps/pluginbitmaps.make
@@ -26,13 +26,14 @@
 
 ifdef PBMP # does player use bitmaps?
 
-PLUGIN_BITMAPS := $(PBMP:$(ROOTDIR)/%.bmp=$(BUILDDIR)/%.o)
+PBMP_BUILD := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(PBMP))
+
+PLUGIN_BITMAPS := $(PBMP_BUILD:%.bmp=%.o)
 
 PLUGINBITMAPLIB := $(BUILDDIR)/apps/plugins/bitmaps/libpluginbitmaps.a
 PLUGINBITMAPDIR := $(dir $(PLUGINBITMAPLIB))
 
-PBMPHFILES := $(subst $(ROOTDIR),$(BUILDDIR),$(PBMP))
-PBMPHFILES := $(shell echo $(PBMPHFILES) | sed  -e 's/\.[0-9x]*\.bmp/.h/g' -e 's/\.bmp/.h/g' | awk "{ gsub(/apps\/plugins\/bitmaps\/(mono|native|remote_mono|remote_native)/, \"pluginbitmaps\"); print }" )
+PBMPHFILES := $(shell echo $(PBMP_BUILD) | sed  -e 's/\.[0-9x]*\.bmp/.h/g' -e 's/\.bmp/.h/g' | awk "{ gsub(/apps\/plugins\/bitmaps\/(mono|native|remote_mono|remote_native)/, \"pluginbitmaps\"); print }" )
 
 $(PBMPHFILES): $(PLUGIN_BITMAPS)
 
diff --git a/apps/plugins/plugins.make b/apps/plugins/plugins.make
index be3d357..d395c00 100644
--- a/apps/plugins/plugins.make
+++ b/apps/plugins/plugins.make
@@ -22,7 +22,7 @@
 endif
 OTHER_SRC += $(PLUGINS_SRC)
 ROCKS1 := $(PLUGINS_SRC:.c=.rock)
-ROCKS1 := $(subst $(ROOTDIR),$(BUILDDIR),$(ROCKS1))
+ROCKS1 := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(ROCKS1))
 
 ROCKS := $(ROCKS1)
 
@@ -35,7 +35,7 @@
 
 PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o)
 PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o)
-PLUGINLIB_OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(PLUGINLIB_OBJ))
+PLUGINLIB_OBJ := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(PLUGINLIB_OBJ))
 
 ### build data / rules
 ifndef APP_TYPE
diff --git a/tools/database/database.make b/tools/database/database.make
index 970aeb5..c29dd47 100644
--- a/tools/database/database.make
+++ b/tools/database/database.make
@@ -14,7 +14,7 @@
                                      echo "\#endif" >> $(3); \
                                      echo $(3))
 
-METADATAS := $(subst $(ROOTDIR), ../.., $(wildcard $(ROOTDIR)/lib/rbcodec/metadata/*.c))
+METADATAS := $(call full_path_subst,$(ROOTDIR)/%,../../%,$(wildcard $(ROOTDIR)/lib/rbcodec/metadata/*.c))
 
 SRCFILE := $(call createsrc, $(TOOLSDIR)/database/SOURCES, \
                              $(METADATAS), \
diff --git a/tools/functions.make b/tools/functions.make
index a2c715e..518b945 100644
--- a/tools/functions.make
+++ b/tools/functions.make
@@ -24,7 +24,7 @@
 asmdefs2file = $(SILENT)$(CC) $(PPCFLAGS) $(3) -S -x c -o - -include config.h $(1) | \
 	perl -ne 'if(/^_?AD_(\w+):$$/){$$var=$$1}else{/^\W\.(?:word|long)\W(.*)$$/ && $$var && print "\#define $$var $$1\n";$$var=0}' > $(2)
 
-c2obj = $(addsuffix .o,$(basename $(subst $(ROOTDIR),$(BUILDDIR),$(1))))
+c2obj = $(addsuffix .o,$(basename $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(1))))
 
 a2lnk = $(patsubst lib%.a,-l%,$(notdir $(1)))