# Common configuration and targets for i386 and amd64 systems.

# May be needed in rare cases.
#SYSLINUX_OPTS = -s

# The DOS volume id to use for DOS floppies. This is a 32 bit hexadecimal
# number.
DOS_VOLUME_ID = $(shell printf "%08x" $$((${SOURCE_DATE_EPOCH}%4294967296)))
# The DOS volume label to use for DOS floppies. This is a 11 character
# string.
DOS_VOLUME_LABEL = "Debian Inst"

# The image to use for a syslinux splash screen.
SPLASH_PNG=boot/artwork/13-ceratopsian/ceratopsian.png
SPLASH_SVG=$(patsubst %.png,%.svg,$(SPLASH_PNG))

# The directory boot screens for syslinux will go in.
BOOT_SCREEN_DIR = 

# Location for Xen example configuration.
XENCFG = $(SOME_DEST)/$(EXTRANAME)debian.cfg

# The font to load in GRUB
GRUB_FONT = /usr/share/grub/ascii.pf2

# Create syslinux config.
.PHONY: x86_syslinux
x86_syslinux:
	-rm -rf $(TEMP_SYSLINUX)/*
	mkdir -p $(TEMP_SYSLINUX)
	TYPE=$(SYSLINUX_CFG) INCLUDE_GTK=$(INITRD_GTK) IS_PURE_GTK=$(IS_PURE_GTK) \
		syslinux-cfgs boot/x86 $(TEMP_SYSLINUX)

# Extract GRUB EFI files.
.PHONY: x86_grub_efi
x86_grub_efi:
ifeq ($(GRUB_EFI),y)
	efi-image -o $(TEMP_GRUB_EFI) -g $(GRUB_EFI_PLATFORM) \
		-e $(GRUB_EFI_NAME) -n $(NETBOOT_PATH) \
		-s $(EFI_SIGNED)
endif

# Compress binaries to save more space.
# Doesn't really save much since we gzip the image later though.
.PHONY: arch_tree
arch_tree:
ifdef UPX
	for bin in $(UPX_BINS); do \
		$(UPX) -9 $(TREE)/$$bin; \
	done
endif

# Create a bootable image.
.PHONY: arch_boot
arch_boot: x86_syslinux
ifdef UPX
	$(UPX) -f -9 $(TEMP_KERNEL) || true
endif
	mkfs.msdos --invariant -v -i $(DOS_VOLUME_ID) -n $(DOS_VOLUME_LABEL) -C $(TEMP_BOOT) $(FLOPPY_SIZE)
	
	# syslinux is used to make the image bootable
	syslinux $(SYSLINUX_OPTS) $(TEMP_BOOT)
	mcopy -i$(TEMP_BOOT) $(TEMP_KERNEL) ::linux
	mcopy -i$(TEMP_BOOT) $(TEMP_INITRD) ::initrd.gz
	
	if [ -n "$(INITRD_GTK)" ]; then \
		mcopy -i$(TEMP_BOOT) $(INITRD_GTK) ::initrdg.gz; \
	fi

	# generate a disk label
	makelabel $(DISK_LABEL) $(BUILD_DATE) > $(TEMP)/disk.lbl
	mcopy -i$(TEMP_BOOT) $(TEMP)/disk.lbl ::disk.lbl

	# syslinux configs

        # Use a non-empty character for beep by default to make sure the menu
        # is wide enough when beep is enabled.
	beep="_"; \
	[ "$(BOOTMENU_BEEP)" = y ] && beep="$$(printf '\a')"; \
	subdirs=""; \
	$(foreach file,$(shell IS_PURE_GTK=$(IS_PURE_GTK) syslinux-cfgs "$(TEMP_SYSLINUX)"), \
		subdir=`dirname $(file)`; \
		outfile=$(file); \
		if [ "$$subdir" != "." ] && \
		   ! echo "$$subdirs " | grep -q " $$subdir "; then \
			mmd -i$(TEMP_BOOT) ::$$subdir; \
			subdirs="$$subdirs $$subdir"; \
		fi; \
		cat $(TEMP_SYSLINUX)/$(file) \
		| bootvars-subst MEDIA_TYPE "$(MEDIA_TYPE)" \
			DEBIAN_VERSION "$(DEBIAN_VERSION)" \
			BUILD_DATE "$(BUILD_DATE)" \
			LSB_DISTRIB_DESCRIPTION "$(LSB_DISTRIB_DESCRIPTION)" \
			KERNEL linux INITRD initrd.gz \
			INITRD_GTK initrdg.gz \
			VIDEO_MODE $(VIDEO_MODE) \
			VIDEO_MODE_GTK $(VIDEO_MODE_GTK) \
			BEEP "$$beep" \
			SYSLINUX_CFG syslinux.cfg \
		| todos | mcopy -i$(TEMP_BOOT) - ::$$outfile; \
	)

	# syslinux help screens
	if [ -z "$(OMIT_BOOT_HELP)" ]; then \
		set -e; \
		$(foreach file,$(sort $(wildcard $(TEMP_BOOT_SCREENS)/*.txt)), \
			if [ -e $(file).withgtk ] && [ -n "$(INITRD_GTK)" ]; then \
				mcopy -i$(TEMP_BOOT) $(file).withgtk ::`basename $(file)`; \
			else \
				mcopy -i$(TEMP_BOOT) $(file) ::`basename $(file)`; \
			fi; \
		) \
	fi
	
	if [ "$(SYSLINUX_CFG)" != prompt ]; then \
		mcopy -i$(TEMP_BOOT) /usr/lib/syslinux/modules/bios/vesamenu.c32 ::vesamenu.c32; \
		mcopy -i$(TEMP_BOOT) /usr/lib/syslinux/modules/bios/libcom32.c32 ::libcom32.c32; \
		mcopy -i$(TEMP_BOOT) /usr/lib/syslinux/modules/bios/libutil.c32  ::libutil.c32 ; \
		if [ -e $(TEMP_BOOT_SCREENS)/splash.png ]; then \
			mcopy -i$(TEMP_BOOT) $(TEMP_BOOT_SCREENS)/splash.png ::splash.png; \
		fi; \
	fi

	$(if $(GZIPPED),pigz -nmv9f $(TEMP_BOOT))

# Set up syslinux help screens.
.PHONY: arch_boot_screens
arch_boot_screens:
	-rm -f $(TEMP_BOOT_SCREENS)/*
	mkdir -p $(TEMP_BOOT_SCREENS)
	$(foreach SCREEN,$(wildcard boot/x86/*.txt boot/x86/*.txt.with*), \
		bootvars-subst MEDIA_TYPE "$(MEDIA_TYPE)" \
			DEBIAN_VERSION "$(DEBIAN_VERSION)" \
			BUILD_DATE "$(BUILD_DATE)" \
			LSB_DISTRIB_DESCRIPTION "$(LSB_DISTRIB_DESCRIPTION)" \
			SYSDIR "$(BOOT_SCREEN_DIR)" \
		       < $(SCREEN) > $(TEMP_BOOT_SCREENS)/`basename $(SCREEN)`\
	;)
	if [ -n "$(SPLASH_PNG)" ]; then \
		if [ -n "$(SPLASH_SVG)" -a -f "$(SPLASH_SVG)" ]; then \
			rsvg-convert $(SPLASH_SVG) > $(SPLASH_PNG); \
		fi; \
		cp $(SPLASH_PNG) $(TEMP_BOOT_SCREENS)/splash.png; \
	fi

# isolinux CD info directory, including help screens and an isolinux.cfg.
# Note that the configuration is extensively manipulated by debian-cd to
# support all the available CD/DVD variants.
# Supply GRUB EFI configuration.
.PHONY: arch_cd_info_dir
arch_cd_info_dir: x86_syslinux x86_grub_efi
	-rm -f $(TEMP_CD_INFO_DIR)/*
	mkdir -p $(TEMP_CD_INFO_DIR)
	
	cp -a $(TEMP_BOOT_SCREENS)/*.txt $(TEMP_CD_INFO_DIR)
	if [ -n "$(INITRD_GTK)" ]; then \
		cp -a $(TEMP_BOOT_SCREENS)/*.txt.withgtk $(TEMP_CD_INFO_DIR); \
	fi
	if [ -e $(TEMP_BOOT_SCREENS)/splash.png ]; then \
		cp -a $(TEMP_BOOT_SCREENS)/splash.png $(TEMP_CD_INFO_DIR); \
	fi

        # Use a non-empty character for beep by default to make sure the menu
        # is wide enough when beep is enabled.
	beep="_"; \
	[ "$(BOOTMENU_BEEP)" = y ] && beep="$$(printf '\a')"; \
	$(foreach file,$(shell IS_PURE_GTK=$(IS_PURE_GTK) syslinux-cfgs "$(TEMP_SYSLINUX)"), \
		subdir=`dirname $(file)`; \
		outfile=$(file); \
		if [ "$$subdir" != "." ]; then \
			mkdir -p $(TEMP_CD_INFO_DIR)/$$subdir; \
		fi; \
		if [ $$outfile = syslinux.cfg ]; then \
			outfile=isolinux.cfg; \
		fi; \
		cat $(TEMP_SYSLINUX)/$(file) \
		| bootvars-subst MEDIA_TYPE "$(MEDIA_TYPE)" \
			DEBIAN_VERSION "$(DEBIAN_VERSION)" \
			BUILD_DATE "$(BUILD_DATE)" \
			LSB_DISTRIB_DESCRIPTION "$(LSB_DISTRIB_DESCRIPTION)" \
			KERNEL /%install%/vmlinuz \
			INITRD /%install%/initrd.gz \
			INITRD_GTK /%install%/gtk/initrd.gz \
			X86_KERNEL /%install-x86%/vmlinuz \
			X86_INITRD /%install-x86%/initrd.gz \
			X86_INITRD_GTK /%install-x86%/gtk/initrd.gz \
			VIDEO_MODE $(VIDEO_MODE) \
			VIDEO_MODE_GTK $(VIDEO_MODE_GTK) \
			BEEP "$$beep" \
			SYSLINUX_CFG isolinux.cfg \
		> $(TEMP_CD_INFO_DIR)/$$outfile; \
	)

	if [ "$(GRUB_EFI)" = y ]; then \
		set -e; \
		mkdir -p $(TEMP_CD_INFO_DIR)/grub/$(GRUB_EFI_PLATFORM); \
		cp -a $(TEMP_GRUB_EFI)/efi.img $(TEMP_CD_INFO_DIR)/grub/; \
		cat boot/x86/grub/grub-efi.cfg \
		| bootvars-subst KERNEL /%install%/vmlinuz \
			INITRD /%install%/initrd.gz \
		> $(TEMP_CD_INFO_DIR)/grub/grub.cfg; \
		cp -a $(GRUB_FONT) $(TEMP_CD_INFO_DIR)/grub/font.pf2; \
		cp -a $(TEMP_GRUB_EFI)/boot/grub/$(GRUB_EFI_PLATFORM)/* \
			$(TEMP_CD_INFO_DIR)/grub/$(GRUB_EFI_PLATFORM)/; \
	fi

	# win32-loader
	if [ -z "$(OMIT_WIN32_LOADER)" ]; then \
		cp /usr/share/win32/win32-loader.exe		$(TEMP_CD_INFO_DIR)/setup.exe; \
		cp /usr/share/win32/win32-loader/g2ldr		$(TEMP_CD_INFO_DIR)/g2ldr; \
		cp /usr/share/win32/win32-loader/g2ldr.mbr	$(TEMP_CD_INFO_DIR)/g2ldr.mbr; \
		\
		(printf "[installer]\n"; \
		printf "kernel=linux\n"; \
		printf "arch=$(ARCH)\n"; \
		if [ -n "$(INITRD_GTK)" ]; then \
			printf "$(ARCH)/linux=install/vmlinuz\n$(ARCH)/initrd=install/initrd.gz\n"; \
			printf "$(ARCH)/gtk/linux=install/vmlinuz\n$(ARCH)/gtk/initrd=install/gtk/initrd.gz\n"; \
		else \
			printf "user_interface=text\n"; \
			printf "$(ARCH)/linux=install/vmlinuz\n$(ARCH)/initrd=install/initrd.gz\n"; \
		fi; \
		printf "\n[grub]\ng2ldr=g2ldr\ng2ldr.mbr=g2ldr.mbr\n") \
			| todos > $(TEMP_CD_INFO_DIR)/win32-loader.ini; \
	fi

.PHONY: arch_miniiso
arch_miniiso: x86_syslinux x86_grub_efi
	-rm -f $(TEMP_CD_TREE)/*
	mkdir -p $(TEMP_CD_TREE)
	cp /usr/lib/ISOLINUX/isolinux.bin $(TEMP_CD_TREE)
	cp /usr/lib/syslinux/modules/bios/vesamenu.c32 $(TEMP_CD_TREE)
	cp /usr/lib/syslinux/modules/bios/ldlinux.c32  $(TEMP_CD_TREE)
	cp /usr/lib/syslinux/modules/bios/libcom32.c32 $(TEMP_CD_TREE)
	cp /usr/lib/syslinux/modules/bios/libutil.c32  $(TEMP_CD_TREE)

	$(foreach file,$(wildcard boot/x86/*.txt), \
		cat $(file) | \
		bootvars-subst MEDIA_TYPE "$(MEDIA_TYPE)" \
			DEBIAN_VERSION "$(DEBIAN_VERSION)" \
			BUILD_DATE "$(BUILD_DATE)" "" \
		       > $(TEMP_CD_TREE)/`basename $(file)`; \
	)

	if [ -e $(TEMP_BOOT_SCREENS)/splash.png ]; then \
		cp $(TEMP_BOOT_SCREENS)/splash.png $(TEMP_CD_TREE); \
	fi
	ln -f $(TEMP_KERNEL) $(TEMP_CD_TREE)/linux
	ln -f $(TEMP_INITRD) $(TEMP_CD_TREE)/initrd.gz

	mkdir -p $(TEMP_CD_TREE)/.disk
	echo "Debian GNU/Linux $(DEBIAN_VERSION) $(ARCH) - netboot mini.iso $(BUILD_DATE)"\
	> $(TEMP_CD_TREE)/.disk/info

        # Use a non-empty character for beep by default to make sure the menu
        # is wide enough when beep is enabled.
	beep="_"; \
	[ "$(BOOTMENU_BEEP)" = y ] && beep="$$(printf '\a')"; \
	$(foreach file,$(shell IS_PURE_GTK=$(IS_PURE_GTK) syslinux-cfgs "$(TEMP_SYSLINUX)"), \
		subdir=`dirname $(file)`; \
		outfile=$(file); \
		if [ "$$subdir" != "." ]; then \
			mkdir -p $(TEMP_CD_TREE)/$$subdir; \
		fi; \
		if [ $$outfile = syslinux.cfg ]; then \
			outfile=isolinux.cfg; \
		fi; \
		cat $(TEMP_SYSLINUX)/$(file) \
		| bootvars-subst MEDIA_TYPE "$(MEDIA_TYPE)" \
			DEBIAN_VERSION "$(DEBIAN_VERSION)" \
			BUILD_DATE "$(BUILD_DATE)" \
			LSB_DISTRIB_DESCRIPTION "$(LSB_DISTRIB_DESCRIPTION)" \
			KERNEL linux \
			INITRD initrd.gz \
			INITRD_GTK /install/gtk/initrd.gz \
			VIDEO_MODE $(VIDEO_MODE) \
			VIDEO_MODE_GTK $(VIDEO_MODE_GTK) \
			BEEP "$$beep" \
			SYSLINUX_CFG isolinux.cfg \
		| todos > $(TEMP_CD_TREE)/$$outfile; \
	)
	
	if [ "$(GRUB_EFI)" = y ]; then \
		set -e; \
		mkdir -p $(TEMP_CD_TREE)/boot/grub/$(GRUB_EFI_PLATFORM); \
		cp -a $(TEMP_GRUB_EFI)/efi.img $(TEMP_CD_TREE)/boot/grub/; \
		grub-gencfg \
			KERNEL /linux \
			INITRD /initrd.gz \
			HEADER boot/x86/grub/grub-efi.cfg \
			IS_PURE_GTK "$(IS_PURE_GTK)" \
			IS_X86 1 \
			-- \
			$(VIDEO_MODE) \
		> $(TEMP_CD_TREE)/boot/grub/grub.cfg; \
		cp -a $(GRUB_FONT) $(TEMP_CD_TREE)/boot/grub/font.pf2; \
		cp -a $(TEMP_GRUB_EFI)/boot/grub/$(GRUB_EFI_PLATFORM)/* \
			$(TEMP_CD_TREE)/boot/grub/$(GRUB_EFI_PLATFORM)/; \
		mkdir -p $(TEMP_CD_TREE)/EFI/debian; \
		echo "search --file --set=root /.disk/info" > $(TEMP_CD_TREE)/EFI/debian/grub.cfg; \
		echo "set prefix=(\$$root)/boot/grub" >> $(TEMP_CD_TREE)/EFI/debian/grub.cfg; \
		echo "source \$$prefix/$(GRUB_EFI_PLATFORM)/grub.cfg" >> $(TEMP_CD_TREE)/EFI/debian/grub.cfg; \
	fi

	# win32-loader
	if [ -z "$(OMIT_WIN32_LOADER)" ]; then \
		cp /usr/share/win32/win32-loader.exe		$(TEMP_CD_TREE)/setup.exe; \
		cp /usr/share/win32/win32-loader/g2ldr		$(TEMP_CD_TREE)/g2ldr; \
		cp /usr/share/win32/win32-loader/g2ldr.mbr	$(TEMP_CD_TREE)/g2ldr.mbr; \
		\
		(printf "[installer]\n"; \
		printf "kernel=linux\n"; \
		printf "arch=$(ARCH)\n"; \
		if [ "$(TYPE)" = "netboot/gtk" ]; then \
			printf "user_interface=graphical\n"; \
			printf "$(ARCH)/gtk/linux=linux\n$(ARCH)/gtk/initrd=initrd.gz\n"; \
		else \
			printf "user_interface=text\n"; \
			printf "$(ARCH)/linux=linux\n$(ARCH)/initrd=initrd.gz\n"; \
		fi; \
		printf "\n[grub]\ng2ldr=g2ldr\ng2ldr.mbr=g2ldr.mbr\n") \
			| todos > $(TEMP_CD_TREE)/win32-loader.ini; \
	fi

	$(clamp_mtimes) $(TEMP_CD_TREE)
	$(normalise_permissions) $(TEMP_CD_TREE)

	mkfs.msdos --invariant -i $(DOS_VOLUME_ID) -n "Firmware" \
		-C $(TEMP)/fat.img $$((6 * 1024))

	if [ "$(GRUB_EFI)" = y ]; then \
		xorriso -as mkisofs -r -J -b isolinux.bin -c boot.cat \
			-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
			-no-emul-boot -boot-load-size 4 -boot-info-table \
			-eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot \
			-append_partition 3 0x01 $(TEMP)/fat.img \
			-isohybrid-gpt-basdat \
			-o $(TEMP_MINIISO) $(TEMP_CD_TREE); \
	else \
		xorriso -as mkisofs -r -J -b isolinux.bin -c boot.cat \
			-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
			-no-emul-boot -boot-load-size 4 -boot-info-table \
			-append_partition 3 0x01 $(TEMP)/fat.img \
			-isohybrid-gpt-basdat \
			-o $(TEMP_MINIISO) $(TEMP_CD_TREE); \
	fi

	rm $(TEMP)/fat.img

# Netboot files
.PHONY: arch_netboot_dir
arch_netboot_dir: x86_syslinux x86_grub_efi
	-rm -f $(TEMP_NETBOOT_DIR)
	mkdir -p $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)
	cp $(TEMP_INITRD) $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)
	cp $(TEMP_KERNEL) $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)/linux
	cp /usr/lib/PXELINUX/pxelinux.0 $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)
	mkdir -p $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)/pxelinux.cfg
	mkdir -p $(TEMP_NETBOOT_DIR)/$(BOOT_SCREEN_DIR)
	cp /usr/lib/syslinux/modules/bios/vesamenu.c32 $(TEMP_NETBOOT_DIR)/$(BOOT_SCREEN_DIR)
	cp /usr/lib/syslinux/modules/bios/ldlinux.c32  $(TEMP_NETBOOT_DIR)/$(BOOT_SCREEN_DIR)
	cp /usr/lib/syslinux/modules/bios/libcom32.c32 $(TEMP_NETBOOT_DIR)/$(BOOT_SCREEN_DIR)
	cp /usr/lib/syslinux/modules/bios/libutil.c32  $(TEMP_NETBOOT_DIR)/$(BOOT_SCREEN_DIR)

        # Use a non-empty character for beep by default to make sure the menu
        # is wide enough when beep is enabled.
	beep="_"; \
	[ "$(BOOTMENU_BEEP)" = y ] && beep="$$(printf '\a')"; \
	$(foreach file,$(shell IS_PURE_GTK=$(IS_PURE_GTK) syslinux-cfgs "$(TEMP_SYSLINUX)"), \
		subdir=`dirname $(file)`; \
		outfile=$(TEMP_NETBOOT_DIR)/$(BOOT_SCREEN_DIR)/$(file); \
		if [ "$$subdir" != "." ]; then \
			mkdir -p $(TEMP_NETBOOT_DIR)/$(BOOT_SCREEN_DIR)/$$subdir; \
		fi; \
		cat $(TEMP_SYSLINUX)/$(file) \
		| bootvars-subst MEDIA_TYPE "$(MEDIA_TYPE)" \
			DEBIAN_VERSION "$(DEBIAN_VERSION)" \
			BUILD_DATE "$(BUILD_DATE)" \
			LSB_DISTRIB_DESCRIPTION "$(LSB_DISTRIB_DESCRIPTION)" \
			SYSDIR "$(BOOT_SCREEN_DIR)" \
			KERNEL $(NETBOOT_PATH)/linux \
			INITRD $(NETBOOT_PATH)/initrd.gz \
			VIDEO_MODE $(VIDEO_MODE) \
			BEEP "$$beep" \
			SYSLINUX_CFG syslinux.cfg \
		> $$outfile; \
	)

	# This is where pxelinux looks for the config file.
	ln -sf ../boot-screens/syslinux.cfg \
		$(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)/pxelinux.cfg/default
	# This symlink is required as pxelinux always looks in the root
	# of the tftp server for its config.
	rm -f $(TEMP_NETBOOT_DIR)/pxelinux.cfg
	ln -sf $(NETBOOT_PATH)/pxelinux.cfg $(TEMP_NETBOOT_DIR)/pxelinux.cfg
	# This symlink is not strictly required, but it allows more usual
	# dhcp server setups to work without modification.
	rm -f $(TEMP_NETBOOT_DIR)/pxelinux.0
	ln -sf $(NETBOOT_PATH)/pxelinux.0 $(TEMP_NETBOOT_DIR)/pxelinux.0
	# This link is required because pxelinux only looks in the tftp root
	# for this library (it does a PATH search for any others).
	ln -sf $(BOOT_SCREEN_DIR)ldlinux.c32 $(TEMP_NETBOOT_DIR)/ldlinux.c32

	set -e; \
	$(foreach file,$(wildcard $(TEMP_BOOT_SCREENS)/*.txt), \
		cp $(file) $(TEMP_NETBOOT_DIR)/$(BOOT_SCREEN_DIR); \
	)

	if [ -n "$(SPLASH_PNG)" ]; then \
		cp $(SPLASH_PNG) $(TEMP_NETBOOT_DIR)/$(BOOT_SCREEN_DIR)/splash.png; \
		ln -sf $(BOOT_SCREEN_DIR)/splash.png $(TEMP_NETBOOT_DIR); \
	fi

	if [ "$(GRUB_EFI)" = y ]; then \
		set -e; \
		mkdir -p $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)/grub/$(GRUB_EFI_PLATFORM); \
		cp -a $(TEMP_GRUB_EFI)/*.efi $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH); \
		cp -a $(GRUB_FONT) $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)/grub/font.pf2; \
		cp -a $(TEMP_GRUB_EFI)/boot/grub/$(GRUB_EFI_PLATFORM)/* \
			$(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)/grub/$(GRUB_EFI_PLATFORM)/; \
		grub-gencfg \
			KERNEL /$(NETBOOT_PATH)/linux \
			INITRD /$(NETBOOT_PATH)/initrd.gz \
			HEADER boot/x86/grub/grub-efi.cfg \
			IS_PURE_GTK "$(IS_PURE_GTK)" \
			IS_X86 1 \
			-- \
			$(VIDEO_MODE) \
		> $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)/grub/grub.cfg; \
	fi

# ChromeOS devices
.PHONY: arch_depthcharge
arch_depthcharge: $(TEMP_KERNEL) $(TEMP_INITRD_XZ)
	-rm -f $(TEMP_DEPTHCHARGE)/*
	mkdir -p $(TEMP_DEPTHCHARGE)
	for board in $(DEPTHCHARGE_BOARDS); do \
		depthchargectl build -v \
			--board $${board} \
			--kernel-release $(KERNELVERSION) \
			--kernel $(TEMP_KERNEL) \
			--initramfs $(TEMP_INITRD_XZ) \
			--root none \
			--kernel-cmdline "partman-partitioning/default_label=gpt --- quiet" \
			--output $(TEMP_DEPTHCHARGE)/$${board}.kernel.img; \
		gen-hd-image -v -z \
			-X gpt \
			-p $$(($$(stat -c%s $(TEMP_DEPTHCHARGE)/$${board}.kernel.img) / 512 + 2048)) \
			-i $$(mktemp -d) \
			-o $(TEMP_DEPTHCHARGE)/$${board}.disk.img \
			-d FE3A2A5D-4F32-41A7-B725-ACCC3285A309 \
			$(TEMP_DEPTHCHARGE)/$${board}.kernel.img \
			2048; \
		pigz -9nmf $(TEMP_DEPTHCHARGE)/$${board}.kernel.img; \
	done

.PHONY: xen_config
xen_config:
	sed -e "s/@ARCH@/$(ARCH)/g" \
	    -e "s/@XEN_INSTALL_METHOD@/$(XEN_INSTALL_METHOD)/g" \
	    -e "s/@DEBIAN_RELEASE@/$(DEBIAN_RELEASE)/g" \
	    <boot/x86/xen/debian.cfg >$(XENCFG)
	chmod 644 $(XENCFG)
	update-manifest $(XENCFG) $(MANIFEST-XENCFG)

include config/linux.cfg
