MEDIA_TYPE = netboot image (SSH)

TARGET = $(TEMP_INITRD) $(TEMP_KERNEL) ts219 ts41x
EXTRANAME = $(MEDIUM)
TYPE = netboot/network-console

# QNAP TS-119, TS-219 and TS-219P
ts219:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)/qnap/ts-219
	mkdir -p $(TEMP)/ts-219
	echo "TS-11x/TS-21x" > $(SOME_DEST)/$(EXTRANAME)/qnap/ts-219/model
	# Set machine id 2139 (0x085b)
	devio > $(TEMP)/ts-219/kernel 'wl 0xe3a01c08,4' 'wl 0xe381105b,4'
	cat $(TEMP_KERNEL) >> $(TEMP)/ts-219/kernel
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/ts-219/kernel $(TEMP)/ts-219/kernel.uboot
	cp $(TEMP)/ts-219/kernel.uboot $(SOME_DEST)/$(EXTRANAME)/qnap/ts-219/kernel
	cp $(TEMP_INITRD) $(SOME_DEST)/$(EXTRANAME)/qnap/ts-219/initrd.gz
	util/pad $(SOME_DEST)/$(EXTRANAME)/qnap/ts-219/initrd.gz 9437184
	install -m 744 boot/arm/qnap-flash-debian $(SOME_DEST)/$(EXTRANAME)/qnap/ts-219/flash-debian
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-219/flash-debian "Script to flash debian-installer"
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-219/kernel "Linux kernel for QNAP TS-119, TS-219 and TS-219P"
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-219/initrd.gz "initrd for QNAP TS-119, TS-219 and TS-219P"
	ln -s ts-219 $(SOME_DEST)/$(EXTRANAME)/qnap/ts-119
	ln -s ts-219 $(SOME_DEST)/$(EXTRANAME)/qnap/ts-219p

# QNAP TS-41x
ts41x:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)/qnap/ts-41x
	mkdir -p $(TEMP)/ts-41x
	echo "TS-41x" > $(SOME_DEST)/$(EXTRANAME)/qnap/ts-41x/model
	# Set machine id 2502 (0x09c6)
	devio > $(TEMP)/ts-41x/kernel 'wl 0xe3a01c09,4' 'wl 0xe38110c6,4'
	cat $(TEMP_KERNEL) >> $(TEMP)/ts-41x/kernel
	mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/ts-41x/kernel $(TEMP)/ts-41x/kernel.uboot
	cp $(TEMP)/ts-41x/kernel.uboot $(SOME_DEST)/$(EXTRANAME)/qnap/ts-41x/kernel
	cp $(TEMP_INITRD) $(SOME_DEST)/$(EXTRANAME)/qnap/ts-41x/initrd.gz
	util/pad $(SOME_DEST)/$(EXTRANAME)/qnap/ts-41x/initrd.gz 9437184
	install -m 744 boot/arm/qnap-flash-debian $(SOME_DEST)/$(EXTRANAME)/qnap/ts-41x/flash-debian
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-41x/flash-debian "Script to flash debian-installer"
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-41x/kernel "Linux kernel for QNAP TS-41x"
	update-manifest $(SOME_DEST)/$(EXTRANAME)/qnap/ts-41x/initrd.gz "initrd for QNAP TS-41x"

