ramips: move umedia build step to Makefile
[openwrt/openwrt.git] / target / linux / ramips / image / Makefile
index 6e0349f02163bf1a2a9af6221e759d38e9ca39bc..ef30c79a4e76932f4688c54f6992d75edb201589 100644 (file)
@@ -22,7 +22,7 @@ define Image/Build/Initramfs
        $(call Image/Build/Profile/$(PROFILE),initramfs)
 endef
 
-DEVICE_VARS += DTS IMAGE_SIZE
+DEVICE_VARS += DTS IMAGE_SIZE KERNEL_SIZE
 
 loadaddr-y := 0x80000000
 loadaddr-$(CONFIG_TARGET_ramips_rt288x) := 0x88000000
@@ -49,8 +49,8 @@ define Build/trx
        $(STAGING_DIR_HOST)/bin/trx \
                -o $@ \
                -m $(IMAGE_SIZE) \
-               -f $(word 1,$^) \
-               -a 4 -f $(word 2,$^)
+               -f $(IMAGE_KERNEL) \
+               -a 4 -f $(IMAGE_ROOTFS)
 endef
 
 define Build/relocate-kernel
@@ -74,6 +74,10 @@ define MkCombineduImage
        $(call MkImage,lzma,$(KDIR)/vmlinux-$(2).bin.lzma.combined,$(call sysupname,$(1),$(2)),$(6))
 endef
 
+define Build/umedia-header
+       fix-u-media-header -T 0x46 -B $(1) -i $@ -o $@.new && mv $@.new $@
+endef
+
 #
 # The real magic happens inside these templates
 #
@@ -107,7 +111,7 @@ endef
 # $(3), optional filename suffix, e.g. "-initramfs"
 define PatchKernelLzmaDtb
        cp $(KDIR)/vmlinux$(3) $(KDIR)/vmlinux-$(1)$(3)
-       $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $(KDIR)/$(2).dtb ../dts/$(2).dts
+       $(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
@@ -197,7 +201,7 @@ define BuildFirmware/Seama/squashfs
        $(call MkImageLzmaDtb,$(2),$(3),$(5))
        $(eval output_name=$(IMG_PREFIX)-$(2)-$(1)-sysupgrade.bin)
        cat $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/root.$(1) > $(KDIR)/img_$(2).$(1).tmp
-       if [ `stat -c%s "$(KDIR)/img_$(2).$(1).tmp"` -gt $$$$(($(5) - 64)) ]; then \
+       if [ `stat -c%s "$(KDIR)/img_$(2).$(1).tmp"` -gt $(5) ]; then \
                echo "Warning: $(KDIR)/img_$(2).$(1).tmp is too big" >&2; \
        else \
                dd if=$(KDIR)/vmlinux-$(2).bin.lzma of=$(KDIR)/vmlinux-$(2).bin.lzma.padded bs=64k conv=sync; \
@@ -246,6 +250,7 @@ endif
 
 ifeq ($(SUBTARGET),rt305x)
 include rt305x.mk
+include rt305x-legacy.mk
 endif
 
 ifeq ($(SUBTARGET),rt3883)
@@ -268,8 +273,7 @@ ifeq ($(SUBTARGET),mt7688)
 include mt7688.mk
 endif
 
-
-ifndef TARGET_DEVICES
+ifdef LEGACY_DEVICES
 #
 # Generic Targets - only needed for legacy image building code
 #
@@ -293,8 +297,12 @@ endef
 define Image/Build
        $(call Image/Build/$(1))
        dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
-       $(call Image/Build/Profile/$(PROFILE),$(1))
 endef
+
+define Image/Build/Profile
+       $(call Image/Build/Profile/$(1),$(2))
+endef
+
 endif
 
 $(eval $(call BuildImage))