-define copy_include
-$(STAGING_DIR)/include-host/.done:
- @mkdir -p $$$$(dirname $$@)
- @cp $(1)/include/*.h $$$$(dirname $$@)/
- @touch $$@
-$(curdir)//prepare = $(STAGING_DIR)/include-host/.done
+$(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" "$$@"
+