MEDIA_TYPE = netboot image

TARGET = $(TEMP_INITRD) $(TEMP_KERNEL) kuroboxpro ts209 ts409 # mv2120
EXTRANAME = $(MEDIUM)
TYPE = netboot/network-console

# Buffalo Kurobox Pro
kuroboxpro:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)/buffalo/kuroboxpro
	mkdir -p $(TEMP)/kuroboxpro
	# Set machine id 1509 (0x05e5)
	devio > $(TEMP)/kuroboxpro/kernel 'wl 0xe3a01c05,4' 'wl 0xe38110e5,4'
	cat $(TEMP_KERNEL) >> $(TEMP)/kuroboxpro/kernel
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/kuroboxpro/kernel $(TEMP)/kuroboxpro/kernel.uboot
	cp $(TEMP)/kuroboxpro/kernel.uboot $(SOME_DEST)/$(EXTRANAME)/buffalo/kuroboxpro/uImage.buffalo
	mkimage -A arm -O linux -T ramdisk -C gzip -a 0x02000000 -e 0x02000000 -n "debian-installer ramdisk" -d $(TEMP_INITRD) $(TEMP)/kuroboxpro/initrd.uboot
	cp $(TEMP)/kuroboxpro/initrd.uboot $(SOME_DEST)/$(EXTRANAME)/buffalo/kuroboxpro/initrd.buffalo
	install -m 744 boot/arm/kuroboxpro-config-debian $(SOME_DEST)/$(EXTRANAME)/buffalo/kuroboxpro/config-debian
	update-manifest $(SOME_DEST)/$(EXTRANAME)/buffalo/kuroboxpro/config-debian "Script to run debian-installer"
	update-manifest $(SOME_DEST)/$(EXTRANAME)/buffalo/kuroboxpro/uImage.buffalo "Linux kernel for Kurobox Pro"
	update-manifest $(SOME_DEST)/$(EXTRANAME)/buffalo/kuroboxpro/initrd.buffalo "initrd for Kurobox Pro"

# HP Media Vault mv2120
mv2120:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)/hp/mv2120
	mkdir -p $(TEMP)/mv2120
	# Set machine id 1693 (0x069d)
	devio > $(TEMP)/mv2120/kernel 'wl 0xe3a01c06,4' 'wl 0xe381109d,4'
	cat $(TEMP_KERNEL) >> $(TEMP)/mv2120/kernel
	mkimage -A arm -O linux -T kernel -C none -e 0x01000000 -a 0x01000000 -n "Debian kernel" -d $(TEMP)/mv2120/kernel $(TEMP)/mv2120/kernel.uboot
	util/pad $(TEMP)/mv2120/kernel.uboot 2097152 # 2 MB
	mkimage -A arm -O linux -T ramdisk -C none -n "netboot image" -d $(TEMP_INITRD) $(TEMP)/mv2120/initrd.uboot
	cat $(TEMP)/mv2120/kernel.uboot $(TEMP)/mv2120/initrd.uboot > $(SOME_DEST)/$(EXTRANAME)/hp/mv2120/netboot.img
	update-manifest $(SOME_DEST)/$(EXTRANAME)/hp/mv2120/netboot.img "netboot image for HP Media Vault mv2120/mv51x0"

# QNAP TS-109/TS-209
ts209:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)/qnap/ts-209
	mkdir -p $(TEMP)/ts-209
	# Set machine id 1565 (0x061d)
	devio > $(TEMP)/ts-209/kernel 'wl 0xe3a01c06,4' 'wl 0xe381101d,4'
	cat $(TEMP_KERNEL) >> $(TEMP)/ts-209/kernel
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/ts-209/kernel $(TEMP)/ts-209/kernel.uboot
	cp $(TEMP)/ts-209/kernel.uboot $(SOME_DEST)/$(EXTRANAME)/qnap/ts-209/kernel
	cp $(TEMP_INITRD) $(SOME_DEST)/$(EXTRANAME)/qnap/ts-209/initrd.gz
	util/pad $(SOME_DEST)/$(EXTRANAME)/qnap/ts-209/initrd.gz 4194303
	install -m 744 boot/arm/qnap-flash-debian $(SOME_DEST)/$(EXTRANAME)/qnap/ts-209/flash-debian
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-209/flash-debian "Script to flash debian-installer"
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-209/kernel "Linux kernel for QNAP TS-109/TS-209"
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-209/initrd.gz "initrd for QNAP TS-109/TS-209"
	ln -s ts-209 $(SOME_DEST)/$(EXTRANAME)/qnap/ts-109

# QNAP TS-409
ts409:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)/qnap/ts-409
	mkdir -p $(TEMP)/ts-409
	# Set machine id 1601 (0x0641)
	devio > $(TEMP)/ts-409/kernel 'wl 0xe3a01c06,4' 'wl 0xe3811041,4'
	cat $(TEMP_KERNEL) >> $(TEMP)/ts-409/kernel
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/ts-409/kernel $(TEMP)/ts-409/kernel.uboot
	cp $(TEMP)/ts-409/kernel.uboot $(SOME_DEST)/$(EXTRANAME)/qnap/ts-409/kernel
	cp $(TEMP_INITRD) $(SOME_DEST)/$(EXTRANAME)/qnap/ts-409/initrd.gz
	util/pad $(SOME_DEST)/$(EXTRANAME)/qnap/ts-409/initrd.gz 4194303
	install -m 744 boot/arm/qnap-flash-debian $(SOME_DEST)/$(EXTRANAME)/qnap/ts-409/flash-debian
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-409/flash-debian "Script to flash debian-installer"
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-409/kernel "Linux kernel for QNAP TS-409"
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-409/initrd.gz "initrd for QNAP TS-409"

