+endef
+
+define Device/Build
+ $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1)))
+ $(call Device/Build/kernel,$(1))
+
+ $$(eval $$(foreach compile,$$(COMPILE), \
+ $$(call Device/Build/compile,$$(compile),$(1))))
+
+ $$(eval $$(foreach image,$$(IMAGES), \
+ $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \
+ $$(call Device/Build/image,$$(fs),$$(image),$(1)))))
+endef
+
+define Device/DumpInfo
+Target-Profile: DEVICE_$(1)
+Target-Profile-Name: $(DEVICE_TITLE)
+Target-Profile-Packages: $(DEVICE_PACKAGES)
+Target-Profile-Description:
+$(DEVICE_DESCRIPTION)
+@@
+
+endef
+
+define Device/Dump
+$$(eval $$(if $$(DEVICE_TITLE),$$(info $$(call Device/DumpInfo,$(1)))))
+endef
+
+define Device
+ $(call Device/InitProfile,$(1))
+ $(call Device/Init,$(1))
+ $(call Device/Default,$(1))
+ $(call Device/$(1),$(1))
+ $(call Device/Check,$(1))
+ $(call Device/$(if $(DUMP),Dump,Build),$(1))
+
+endef
+
+define BuildImage
+
+ ifneq ($(DUMP),)
+ all: dumpinfo
+ dumpinfo: FORCE
+ @true
+ endif
+
+ download:
+ prepare:
+ compile:
+ clean:
+ legacy-images-prepare:
+ legacy-images:
+ image_prepare:
+
+ ifeq ($(IB),)
+ .PHONY: download prepare compile clean image_prepare kernel_prepare install install-images
+ compile:
+ $(call Build/Compile)
+
+ clean:
+ $(call Build/Clean)
+
+ image_prepare: compile
+ mkdir -p $(BIN_DIR) $(KDIR)/tmp
+ $(call Image/Prepare)
+
+ legacy-images-prepare-make: image_prepare
+ $(MAKE) legacy-images-prepare
+
+ else
+ image_prepare:
+ mkdir -p $(BIN_DIR) $(KDIR)/tmp
+ endif
+
+ kernel_prepare: image_prepare
+ $(call Image/Build/targz)
+ $(call Image/Build/cpiogz)
+ $(call Image/BuildKernel)
+ $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(if $(IB),,$(call Image/BuildKernel/Initramfs)))
+ $(call Image/InstallKernel)
+
+ $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))
+ $(foreach device,$(LEGACY_DEVICES),$(call LegacyDevice,$(device)))
+
+ install-images: kernel_prepare $(foreach fs,$(filter-out $(if $(UBIFS_OPTS),,ubifs),$(TARGET_FILESYSTEMS) $(fs-subtypes-y)),$(KDIR)/root.$(fs))
+ $(foreach fs,$(TARGET_FILESYSTEMS),
+ $(call Image/Build,$(fs))
+ )
+
+ legacy-images-make: install-images
+ $(call Image/mkfs/ubifs/legacy)
+ $(MAKE) legacy-images
+
+ install: install-images
+ $(call Image/Manifest)
+
+endef