+define BuildFirmware/Generic/initramfs
+ $(call MkImageLzma,$(2),$(3) $($(4)))
+ $(CP) $(KDIR)/vmlinux-$(2).uImage $(call imgname,$(1),$(2))-uImage.bin
+endef
+
+define BuildFirmware/WL341V3
+ $(call MkImageLzma,$(2),$(3) $($(4)))
+ if [ `stat -c%s "$(KDIR)/vmlinux-$(2).uImage"` -gt $(5) ]; then \
+ echo "Warning: $(KDIR)/vmlinux-$(2).uImage is too big"; \
+ else if [ `stat -c%s $(KDIR)/root.$(1)` -gt $(6) ]; then \
+ echo "Warning: $(KDIR)/root.$(1) is too big"; \
+ else \
+ ( \
+ dd if=/dev/zero bs=195936 count=1; \
+ echo "1.01"; \
+ dd if=/dev/zero bs=581 count=1; \
+ echo -n -e "\x73\x45\x72\x43\x6F\x4D\x6D\x00\x01\x00\x00\x59\x4E\x37\x95\x58\x10\x00\x20\x00\x28\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x03\x00\x00\x80\x00\x00\x00\x00\x03\x00\x00\x10\x12\x00\x00\x00\x10\x73\x45\x72\x43\x6F\x4D\x6D"; \
+ dd if=/dev/zero bs=65552 count=1; \
+ dd if=$(KDIR)/vmlinux-$(2).uImage bs=$(5) conv=sync; \
+ dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
+ dd if=/dev/zero bs=`expr 4194304 - 262144 - 16 - $(5) - \( \( \( \`stat -c%s $(KDIR)/root.$(1)\` / 65536 \) + 1 \) \* 65536 \)` count=1; \
+ echo -n -e "\x11\x03\x80\x00\x10\x12\x90\xF7\x65\x52\x63\x4F\x6D\x4D\x00\x00"; \
+ ) > $(call imgname,$(1),$(2))-factory.bin; \
+ fi; fi
+endef
+
+define BuildFirmware/Buffalo
+ $(call MkImageLzma,$(2),board=$(3) $($(4)))
+ if [ `stat -c%s "$(KDIR)/vmlinux-$(2).uImage"` -gt $(5) ]; then \
+ echo "Warning: $(KDIR)/vmlinux-$(2).uImage is too big"; \
+ else if [ `stat -c%s $(KDIR)/root.$(1)` -gt $(6) ]; then \
+ echo "Warning: $(KDIR)/root.$(1) is too big"; \
+ else \
+ buffalo-enc -p $(3) -v 1.76 \
+ -i $(KDIR)/vmlinux-$(2).uImage \
+ -o $(KDIR)/vmlinux-$(2).uImage.enc; \
+ buffalo-enc -p $(3) -v 1.76 \
+ -i $(KDIR)/root.$(1) \
+ -o $(KDIR)/root.$(2).enc; \
+ buffalo-tag -b $(3) -p $(3) -a ram -v 1.76 -m 1.01 \
+ -l mlang8 -f 1 -r EU \
+ -i $(KDIR)/vmlinux-$(2).uImage.enc \
+ -i $(KDIR)/root.$(2).enc \
+ -o $(call imgname,$(1),$(2))-factory-EU.bin; \
+ fi; fi
+endef
+
+define BuildFirmware/Buffalo2
+ $(call BuildFirmware/Generic,$(1),$(2),board=$(3),$($(4)),$(5),$(6))
+endef
+
+define BuildFirmware/NW718
+ $(call PatchKernelLzma,$(2),$(3) $($(4)))
+ mkimage -A mips -O linux -T kernel -C lzma $(call kernel_entry) \
+ -n "ARA1B4NCRNW718;1" \
+ -d "$(KDIR)/vmlinux-$(2).bin.lzma" \
+ "$(KDIR)/vmlinux-$(2).uImage"
+ if [ `stat -c%s "$(KDIR)/vmlinux-$(2).uImage"` -gt $(5) ]; then \
+ echo "Warning: $(KDIR)/vmlinux-$(2).uImage is too big"; \
+ else if [ `stat -c%s $(KDIR)/root.$(1)` -gt $(6) ]; then \
+ echo "Warning: $(KDIR)/root.$(1) is too big"; \
+ else \
+ ( \
+ dd if=$(KDIR)/vmlinux-$(2).uImage bs=$(5) conv=sync; \
+ dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
+ ) > $(call imgname,$(1),$(2))-factory.bin; \
+ fi; fi
+endef
+
+define BuildFirmware/Edimax
+ mkedimaximg -i $(call imgname,$(1),$(2))-sysupgrade.bin \
+ -o $(call imgname,$(1),$(2))-factory.bin \
+ -s $(3) -m $(4) -f $(5) -S $(6)
+endef
+
+define Image/Build/Template/initramfs/initramfs
+ $(call Image/Build/Template/$(1)/initramfs,initramfs,$(2),$(3),$(4),$(5),$(6),$(7),$(8))
+endef
+
+define Image/Build/Template/squashfs-only/squashfs
+ $(call Image/Build/Template/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7),$(8))
+endef
+