-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=
- $(STAMP_CONFIGURED): $(STAMP_CHECKED) FORCE
- prepare: $(STAMP_PATCHED)
- quilt-check: $(STAMP_CHECKED)
+define HostPatchDir
+$(call PatchDir/$(if $(strip $(HOST_QUILT)),Quilt,Default),$(strip $(1)),$(strip $(2)),$(strip $(3)))
+endef
+
+ifneq ($(PKG_BUILD_DIR),)
+ QUILT?=$(if $(wildcard $(PKG_BUILD_DIR)/.quilt_used),y)
+ ifneq ($(QUILT),)
+ STAMP_CHECKED:=$(PKG_BUILD_DIR)/.quilt_checked
+ override CONFIG_AUTOREBUILD=
+ 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_CHECKED:=$(HOST_BUILD_DIR)/.quilt_checked
+ override CONFIG_AUTOREBUILD=
+ host-quilt-check: $(HOST_STAMP_CHECKED)
+ endif