-QUILT?=$(strip $(shell test -f $(PKG_BUILD_DIR)/.quilt_used && echo y))
-ifneq ($(QUILT),)
- STAMP_PATCHED:=$(PKG_BUILD_DIR)/.quilt_patched
- STAMP_CHECKED:=$(PKG_BUILD_DIR)/.quilt_checked
- override CONFIG_AUTOREBUILD=
- prepare: $(STAMP_PATCHED)
- quilt-check: $(STAMP_CHECKED)
+ifneq ($(PKG_BUILD_DIR),)
+ QUILT?=$(if $(wildcard $(PKG_BUILD_DIR)/.quilt_used),y)
+ ifneq ($(QUILT),)
+ STAMP_PATCHED:=$(PKG_BUILD_DIR)/.quilt_patched
+ STAMP_CHECKED:=$(PKG_BUILD_DIR)/.quilt_checked
+ override CONFIG_AUTOREBUILD=
+ prepare: $(STAMP_PATCHED)
+ quilt-check: $(STAMP_CHECKED)
+ endif
+endif
+
+ifneq ($(HOST_BUILD_DIR),)
+ HOST_QUILT?=$(if $(findstring command,$(origin $(QUILT))),$(QUILT),$(if $(wildcard $(HOST_BUILD_DIR)/.quilt_used),y))
+ ifneq ($(HOST_QUILT),)
+ HOST_STAMP_PATCHED:=$(HOST_BUILD_DIR)/.quilt_patched
+ HOST_STAMP_CHECKED:=$(HOST_BUILD_DIR)/.quilt_checked
+ override CONFIG_AUTOREBUILD=
+ host-prepare: $(HOST_STAMP_PATCHED)
+ host-quilt-check: $(HOST_STAMP_CHECKED)
+ endif