MEDIA_TYPE = netboot image

TARGET = $(TEMP_INITRD) $(TEMP_KERNEL) kuroboxpro lsgl lswtgl
EXTRANAME = $(MEDIUM)/

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

# Buffalo Kurobox Pro
kuroboxpro: $(TEMP_INITRD_XZ)
	mkdir -p $(SOME_DEST)/$(EXTRANAME)buffalo/kuroboxpro
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/orion5x-kuroboxpro.dtb > $(TEMP)/vmlinuz-kuroboxpro
	mkimage -A arm -O linux -T kernel -C none -a 0x01a00000 -e 0x01a00000 -n "Debian kernel" -d $(TEMP)/vmlinuz-kuroboxpro $(SOME_DEST)/$(EXTRANAME)buffalo/kuroboxpro/uImage.buffalo
	mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n "debian-installer ramdisk" -d $(TEMP_INITRD_XZ) $(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 LS-WTGL
lswtgl: lsgl
	mkdir -p $(SOME_DEST)/$(EXTRANAME)buffalo/ls-wtgl
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/orion5x-linkstation-lswtgl.dtb > $(TEMP)/vmlinuz-lswtgl
	mkimage -A arm -O linux -T kernel -C none -a 0x01a00000 -e 0x01a00000 -n "Debian kernel" -d $(TEMP)/vmlinuz-lswtgl $(SOME_DEST)/$(EXTRANAME)buffalo/ls-wtgl/uImage.buffalo
	ln -nfs ../kuroboxpro/initrd.buffalo $(SOME_DEST)/$(EXTRANAME)buffalo/ls-wtgl/
	ln -nfs ../lspro_ls-gl/config-debian $(SOME_DEST)/$(EXTRANAME)buffalo/ls-wtgl/
	update-manifest $(SOME_DEST)/$(EXTRANAME)buffalo/ls-wtgl/config-debian "Script to run debian-installer"
	update-manifest $(SOME_DEST)/$(EXTRANAME)buffalo/ls-wtgl/uImage.buffalo "Linux kernel for Linkstation LS-WTGL"
	update-manifest $(SOME_DEST)/$(EXTRANAME)buffalo/ls-wtgl/initrd.buffalo "initrd for Linkstation LS-WTGL"

# Buffalo Linkstation Pro/Live (LS-GL)
lsgl: kuroboxpro
	mkdir -p $(SOME_DEST)/$(EXTRANAME)buffalo/lspro_ls-gl
	cat $(TEMP_KERNEL) $(TEMP_DTBS)/orion5x-linkstation-lsgl.dtb > $(TEMP)/vmlinuz-lsgl
	mkimage -A arm -O linux -T kernel -C none -a 0x01a00000 -e 0x01a00000 -n "Debian kernel" -d $(TEMP)/vmlinuz-lsgl $(SOME_DEST)/$(EXTRANAME)buffalo/lspro_ls-gl/uImage.buffalo
	ln -nfs ../kuroboxpro/initrd.buffalo $(SOME_DEST)/$(EXTRANAME)buffalo/lspro_ls-gl/
	install -m 744 boot/arm/linkstation-config-debian $(SOME_DEST)/$(EXTRANAME)buffalo/lspro_ls-gl/config-debian
	update-manifest $(SOME_DEST)/$(EXTRANAME)buffalo/lspro_ls-gl/config-debian "Script to run debian-installer"
	update-manifest $(SOME_DEST)/$(EXTRANAME)buffalo/lspro_ls-gl/uImage.buffalo "Linux kernel for Linkstation Pro/Live (LS-GL)"
	update-manifest $(SOME_DEST)/$(EXTRANAME)buffalo/lspro_ls-gl/initrd.buffalo "initrd for Linkstation Pro/Live (LS-GL)"
