+$(STAGING_DIR)/.prepared: $(TMP_DIR)/.build
+ $(call PrepareStaging,$(STAGING_DIR))
+ mkdir -p $(BUILD_DIR)/stamp
+ touch $@
+
+$(STAGING_DIR_HOST)/.prepared: $(TMP_DIR)/.build
+ $(call PrepareStaging,$(STAGING_DIR_HOST))
+ mkdir -p $(BUILD_DIR_HOST)/stamp
+ $(INSTALL_DATA) $(TOPDIR)/tools/include/*.h $(STAGING_DIR_HOST)/include/
+ touch $@
+
+
+define PrepareCommand
+$(STAGING_DIR_HOST)/bin/$(1): $(STAGING_DIR)/.prepared
+ @mkdir -p "$$(dir $$@)"; rm -f "$$@"
+ @export FILE="$$$$(which $(2) 2>/dev/null | grep -v 'not found' | head -n1)"; [ -n "$$$$FILE" ] || { \
+ echo "Command $(1) not found."; false; \
+ }; ln -s "$$$$FILE" "$$@"
+
+endef
+endif
+
+$(eval $(call PrepareCommand,find,gfind find))
+$(eval $(call PrepareCommand,md5sum,md5sum $(SCRIPT_DIR)/md5sum))
+$(eval $(call PrepareCommand,cp,gcp cp))
+$(eval $(call PrepareCommand,stat,gstat stat))
+
+$(curdir)/cmddeps = $(patsubst %,$(STAGING_DIR_HOST)/bin/%,find md5sum cp stat)
+$(curdir)//prepare = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $($(curdir)/cmddeps)
+$(curdir)//compile = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $($(curdir)/cmddeps)