MEDIA_TYPE = netboot image

TARGET = $(INITRD) $(KERNEL) openrd-base openrd-client openrd-ultimate sheevaplug sheevaplug-esata guruplug dreamplug dockstar
EXTRANAME = $(MEDIUM)/

MANIFEST-INITRD = "netboot initrd"
MANIFEST-KERNEL = "kernel image to netboot"

openrd-base:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)marvell/openrd-base
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/kirkwood-openrd-base.dtb > $(TEMP)/vmlinuz-openrd-base
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/vmlinuz-openrd-base $(SOME_DEST)/$(EXTRANAME)marvell/openrd-base/uImage
	mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n "debian-installer ramdisk" -d $(TEMP_INITRD) $(SOME_DEST)/$(EXTRANAME)marvell/openrd-base/uInitrd
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/openrd-base/uImage "Linux kernel for OpenRD Base"
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/openrd-base/uInitrd "initrd for OpenRD Base"

openrd-client: openrd-base
	mkdir -p $(SOME_DEST)/$(EXTRANAME)marvell/openrd-client
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/kirkwood-openrd-client.dtb > $(TEMP)/vmlinuz-openrd-client
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/vmlinuz-openrd-client $(SOME_DEST)/$(EXTRANAME)marvell/openrd-client/uImage
	ln -nfs ../openrd-base/uInitrd $(SOME_DEST)/$(EXTRANAME)marvell/openrd-client/uInitrd
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/openrd-client/uImage "Linux kernel for OpenRD Client"
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/openrd-client/uInitrd "initrd for OpenRD Client"

openrd-ultimate: openrd-base
	mkdir -p $(SOME_DEST)/$(EXTRANAME)marvell/openrd-ultimate
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/kirkwood-openrd-ultimate.dtb > $(TEMP)/vmlinuz-openrd-ultimate
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/vmlinuz-openrd-ultimate $(SOME_DEST)/$(EXTRANAME)marvell/openrd-ultimate/uImage
	ln -nfs ../openrd-base/uInitrd $(SOME_DEST)/$(EXTRANAME)marvell/openrd-ultimate/uInitrd
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/openrd-ultimate/uImage "Linux kernel for OpenRD Ultimate"
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/openrd-ultimate/uInitrd "initrd for OpenRD Ultimate"

sheevaplug:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)marvell/sheevaplug
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/kirkwood-sheevaplug.dtb > $(TEMP)/vmlinuz-sheevaplug
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/vmlinuz-sheevaplug $(SOME_DEST)/$(EXTRANAME)marvell/sheevaplug/uImage
	mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n "debian-installer ramdisk" -d $(TEMP_INITRD) $(SOME_DEST)/$(EXTRANAME)marvell/sheevaplug/uInitrd
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/sheevaplug/uImage "Linux kernel for SheevaPlug"
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/sheevaplug/uInitrd "initrd for SheevaPlug"

sheevaplug-esata: sheevaplug
	mkdir -p $(SOME_DEST)/$(EXTRANAME)marvell/sheevaplug-esata
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/kirkwood-sheevaplug-esata.dtb > $(TEMP)/vmlinuz-sheevaplug-esata
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/vmlinuz-sheevaplug-esata $(SOME_DEST)/$(EXTRANAME)marvell/sheevaplug-esata/uImage
	ln -nfs ../sheevaplug/uInitrd $(SOME_DEST)/$(EXTRANAME)marvell/sheevaplug-esata/uInitrd
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/sheevaplug-esata/uImage "Linux kernel for SheevaPlug eSATA"
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/sheevaplug-esata/uInitrd "initrd for SheevaPlug eSATA"

guruplug: sheevaplug
	mkdir -p $(SOME_DEST)/$(EXTRANAME)marvell/guruplug
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/kirkwood-guruplug-server-plus.dtb > $(TEMP)/vmlinuz-guruplug
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/vmlinuz-guruplug $(SOME_DEST)/$(EXTRANAME)marvell/guruplug/uImage
	ln -nfs ../sheevaplug/uInitrd $(SOME_DEST)/$(EXTRANAME)marvell/guruplug/uInitrd
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/guruplug/uImage "Linux kernel for GuruPlug"
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/guruplug/uInitrd "initrd for GuruPlug"

dreamplug: sheevaplug
	mkdir -p $(SOME_DEST)/$(EXTRANAME)marvell/dreamplug
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/kirkwood-dreamplug.dtb > $(TEMP)/vmlinuz-dreamplug
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/vmlinuz-dreamplug $(SOME_DEST)/$(EXTRANAME)marvell/dreamplug/uImage
	ln -nfs ../sheevaplug/uInitrd $(SOME_DEST)/$(EXTRANAME)marvell/dreamplug/uInitrd
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/dreamplug/uImage "Linux kernel for DreamPlug"
	update-manifest $(SOME_DEST)/$(EXTRANAME)marvell/dreamplug/uInitrd "initrd for DreamPlug"

dockstar:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)seagate/dockstar
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/kirkwood-dockstar.dtb > $(TEMP)/vmlinuz-dockstar
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/vmlinuz-dockstar $(SOME_DEST)/$(EXTRANAME)seagate/dockstar/uImage
	mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n "debian-installer ramdisk" -d $(TEMP_INITRD) $(SOME_DEST)/$(EXTRANAME)seagate/dockstar/uInitrd
	update-manifest $(SOME_DEST)/$(EXTRANAME)seagate/dockstar/uImage "Linux kernel for Seagate DockStar"
	update-manifest $(SOME_DEST)/$(EXTRANAME)seagate/dockstar/uInitrd "initrd for Seagate DockStar"
