-#
-# The real magic happens inside these templates
-#
-# $(1), compression method
-# $(2), filename of image data
-# $(3), output filename
-define MkImage
- $(eval imagename=$(if $(4),$(4),MIPS $(VERSION_DIST) Linux-$(LINUX_VERSION)))
- -mkimage -A mips -O linux -T kernel -C $(1) -a $(loadaddr-y) -e $(loadaddr-y) \
- -n "$(imagename)" \
- -d $(2) $(3)
-endef
-
-define CompressLzma
- $(STAGING_DIR_HOST)/bin/lzma e $(1) -lc1 -lp2 -pb2 $(2)
-endef
-
-define MkImageSysupgrade/squashfs
- $(eval output_name=$(IMG_PREFIX)-$(2)-$(1)-$(if $(4),$(4),sysupgrade).bin)
- cat $(KDIR)/vmlinux-$(2).uImage $(KDIR)/root.$(1) > $(KDIR)/$(output_name)
- $(call prepare_generic_squashfs,$(KDIR)/$(output_name))
- if [ `stat -c%s "$(KDIR)/$(output_name)"` -gt $(3) ]; then \
- echo "Warning: $(KDIR)/$(output_name) is too big" >&2; \
- else \
- $(CP) $(KDIR)/$(output_name) $(BIN_DIR)/$(output_name); \
- fi
-endef
-
-# $(1), lowercase board name like "mt7620a_v22sg"
-# $(2), DTS filename without .dts extension
-# $(3), optional filename suffix, e.g. "-initramfs"
-define PatchKernelLzmaDtb
- cp $(KDIR)/vmlinux$(3) $(KDIR)/vmlinux-$(1)$(3)
- $(call Image/BuildDTB,../dts/$(2).dts,$(KDIR)/$(2).dtb)
- $(STAGING_DIR_HOST)/bin/patch-dtb $(KDIR)/vmlinux-$(1)$(3) $(KDIR)/$(2).dtb
- $(call CompressLzma,$(KDIR)/vmlinux-$(1)$(3),$(KDIR)/vmlinux-$(1)$(3).bin.lzma)
-endef
-
-# $(1), lowercase board name
-# $(2), DTS filename without .dts extension
-# $(3), ih_name field of uImage header
-# $(4), optional filename suffix, e.g. "-initramfs"
-define MkImageLzmaDtb
- $(call PatchKernelLzmaDtb,$(1),$(2),$(4))
- $(call MkImage,lzma,$(KDIR)/vmlinux-$(1)$(4).bin.lzma,$(KDIR)/vmlinux-$(1)$(4).uImage,$(3))
-endef
-
-# $(1), Rootfs type, e.g. squashfs
-# $(2), lowercase board name
-# $(3), DTS filename without .dts extension
-# $(4), maximum size of sysupgrade image
-# $(5), uImage header's ih_name field
-define BuildFirmware/OF
- $(call MkImageLzmaDtb,$(2),$(3),$(5))
- $(call MkImageSysupgrade/$(1),$(1),$(2),$(4),$(6))
-endef
-
-# $(1), squashfs/initramfs
-# $(2), lowercase board name
-# $(3), DTS filename without .dts extension
-# $(4), ih_name field of uImage header
-define BuildFirmware/OF/initramfs
- $(call MkImageLzmaDtb,$(2),$(3),$(4),-initramfs)
- $(CP) $(KDIR)/vmlinux-$(2)-initramfs.uImage $(call imgname,$(1),$(2))-uImage.bin
-endef
-
-# Build images for default ralink layout for 4MB flash
-# kernel + roots = 0x3b0000
-# $(1) = squashfs/initramfs
-# $(2) = lowercase board name
-# $(3) = dts file