MEDIA_TYPE = netboot image

NETBOOT_DIR_TARGETS = $(TEMP_INITRD) $(TEMP_KERNEL)

TYPE = netboot/gtk

TARGET = $(NETBOOT_DIR) $(NETBOOT_TAR) $(MINIISO) $(DEPTHCHARGE) netboot_images_concatenateable
EXTRANAME = netboot/gtk/

BOOT_SCREEN_DIR = $(NETBOOT_PATH)/boot-screens/

MANIFEST-NETBOOT_DIR = "PXE boot directory for tftp server (graphical installer)"
MANIFEST-NETBOOT_TAR = "tarball of PXE boot directory (graphical installer)"
MANIFEST-MINIISO = "not so tiny CD image that boots the graphical netboot installer"
MANIFEST-DEPTHCHARGE = "Disk/partition images for ChromeOS devices (graphical netboot installer)"

IS_PURE_GTK = 1

KEEP_GI_LANGS = 1

VIDEO_MODE=$(VIDEO_MODE_GTK)

# All images that include cdebconf should include symbols needed by these
# plugins.
EXTRAUDEBS += cdebconf-gtk-entropy

IMAGE_SIZE = 400000

.PHONY: netboot_images_concatenateable
netboot_images_concatenateable: $(TEMP_KERNEL) $(TEMP_INITRD) $(TEMP_DTBS)
	-rm -rf $(TEMP)/netboot_images_concatenateable
	mkdir $(TEMP)/netboot_images_concatenateable
	cp $(TEMP_KERNEL) $(TEMP)/netboot_images_concatenateable/vmlinuz
	cp $(TEMP_INITRD) $(TEMP)/netboot_images_concatenateable/initrd.gz
	mkdir $(TEMP)/netboot_images_concatenateable/extlinux
	cp boot/arm64/extlinux/extlinux.conf $(TEMP)/netboot_images_concatenateable/extlinux/
	cp -r $(TEMP_DTBS) $(TEMP)/netboot_images_concatenateable/dtbs/
	cp boot/README.device-tree $(TEMP)/netboot_images_concatenateable/dtbs/README
	mkdir -p $(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)
	for target in a64-olinuxino nanopi_neo2 orangepi_one_plus orangepi_zero_plus2 pine64_plus pinebook teres_i ; do \
		echo "Providing u-boot binaries for $$target ..." ; \
		gen-hd-image -v -s "$(IMAGE_SIZE)" -p 32768 -b firmware -o $(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/firmware.$${target}.img ; \
		TARGET=/usr/lib/u-boot/$${target} u-boot-install-sunxi $(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/firmware.$${target}.img ; \
		pigz -9nmf $(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/firmware.$${target}.img ; \
	done
	for target in firefly-rk3399 pinebook-pro-rk3399 rockpro64-rk3399 rock64-rk3328 rock-pi-4-rk3399; do \
		echo "Providing u-boot binaries for $$target ..." ; \
		gen-hd-image -v -p 32768 -s "$(IMAGE_SIZE)" -b firmware -o $(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/firmware.$${target}.img ; \
		TARGET=/usr/lib/u-boot/$${target} u-boot-install-rockchip $(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/firmware.$${target}.img ; \
		pigz -9nmf $(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/firmware.$${target}.img ; \
	done
	for target in puma-rk3399 ; do \
		echo "Providing u-boot binaries for $$target ..." ; \
		gen-hd-image -v -p 32768 -s "$(IMAGE_SIZE)" -b firmware -o $(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/firmware.$${target}.img ; \
		TARGET=/usr/lib/u-boot/$${target} UBOOT_OFFSET=512 u-boot-install-rockchip $(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/firmware.$${target}.img ; \
		pigz -9nmf $(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/firmware.$${target}.img ; \
	done
	gen-hd-image -v -z -p 32768 -b firmware -s "$(IMAGE_SIZE)" -o "$(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/firmware.none.img"
	gen-hd-image -v -z -p 32768 -b partition -s "$(IMAGE_SIZE)" -i "$(TEMP)/netboot_images_concatenateable" -o "$(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/partition.img"
	cp boot/README.concatenateable_images "$(SOME_DEST)/$(EXTRANAME)/SD-card-images/$(CONCATENATEABLE_SUFFIX)/"
