-define Build/Prepare
- $(if $(Build/Prepare/$(ARCH)),$(Build/Prepare/$(ARCH)),$(call Kernel/Prepare/Default))
- $(SED) 's/@expr length/@-expr length/' $(PKG_BUILD_DIR)/Makefile
- ln -sf linux-$(LINUX_VERSION) $(LINUX_HEADERS_DIR)
+define Host/Configure/all
+ mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev
+ $(KMAKE) \
+ INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/" \
+ headers_install
+endef
+
+# XXX: the following is needed to build lzma-loader
+ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
+ define Host/Configure/lzma
+ $(CP) \
+ $(HOST_BUILD_DIR)/arch/mips/include/asm/asm.h \
+ $(HOST_BUILD_DIR)/arch/mips/include/asm/regdef.h \
+ $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/
+ endef
+endif
+
+define Host/Configure/post/cris
+ $(CP) \
+ $(HOST_BUILD_DIR)/include/linux/user.h \
+ $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/linux/
+ ln -snf $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/arch-v10/arch \
+ $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/arch
+ $(SED) '/#include <asm\/page\.h>/d' $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/user.h
+endef
+
+define Host/Configure/post/ubicom32
+ $(CP) \
+ $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/elf.h \
+ $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/user.h \
+ $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/page.h \
+ $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/page_offset.h \
+ $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/
+endef
+
+define Host/Configure/post/mips
+ $(call Host/Configure/lzma)
+endef
+
+define Host/Configure/post/mipsel
+ $(call Host/Configure/lzma)
+endef
+
+define Host/Prepare
+ $(call Kernel/Prepare/Default)
+ ln -sf linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
+ $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile
+endef
+
+define Host/Configure
+ env