MEDIA_TYPE = netboot image

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

# D-Link DNS-323 / Conceptronic CH3SNAS
dns-323:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)/d-link/dns-323
	mkdir -p $(TEMP)/dns-323
	# Set machine id 1542 (0x0606)
	devio > $(TEMP)/dns-323/kernel 'wl 0xe3a01c06,4' 'wl 0xe3811006,4'
	cat $(TEMP_KERNEL) >> $(TEMP)/dns-323/kernel
	mkimage -A arm -O linux -T kernel -C none -e 0x00008000 -a 0x00008000 -n "Debian kernel" -d $(TEMP)/dns-323/kernel $(TEMP)/dns-323/kernel.uboot
	mkimage -A arm -O linux -T ramdisk -C gzip -e 0x00800000 -a 0x00800000 -n "debian-installer ramdisk" -d $(TEMP_INITRD) $(TEMP)/dns-323/initrd.uboot
	mkdns323fw -k $(TEMP)/dns-323/kernel.uboot -i $(TEMP)/dns-323/initrd.uboot -p 7 -c 1 -m 1 -o $(SOME_DEST)/$(EXTRANAME)/d-link/dns-323/netboot.img
	update-manifest $(SOME_DEST)/$(EXTRANAME)/d-link/dns-323/netboot.img "installer image for D-Link DNS-323"
	mkdir -p $(SOME_DEST)/$(EXTRANAME)/conceptronic/ch3snas
	mkdns323fw -k $(TEMP)/dns-323/kernel.uboot -i $(TEMP)/dns-323/initrd.uboot -p 7 -c 2 -m 1 -o $(SOME_DEST)/$(EXTRANAME)/conceptronic/ch3snas/netboot.img
	update-manifest $(SOME_DEST)/$(EXTRANAME)/conceptronic/ch3snas/netboot.img "installer image for Conceptronic CH3SNAS"

# 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"

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

# 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 "Debian installer" -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 "installer 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
	echo "TS-109/TS-209" > $(SOME_DEST)/$(EXTRANAME)/qnap/ts-209/model
	# 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 4194304
	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
	echo "TS-409" > $(SOME_DEST)/$(EXTRANAME)/qnap/ts-409/model
	# 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 4194304
	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"

