MEDIUM_SUPPORTED = cdrom netboot

# The version of the kernel to use.
KERNELMAJOR = 2.6
KERNELVERSION = $(LINUX_KERNEL_ABI)-itanium
KERNELNAME = vmlinuz

DEBIAN_RELEASE = unstable

KEYRING = /usr/share/keyrings/debian-ports-archive-keyring.gpg

# Configuration for generating EFI images
GRUB_EFI=y
GRUB_EFI_PLATFORM=ia64-efi
GRUB_EFI_NAME=ia64
# We do *NOT* have support for UEFI Secure Boot on this arch
EFI_SIGNED=n

arch_boot_screens:
arch_tree:

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

# Extract GRUB EFI files.
.PHONY: ia64_grub_efi
ia64_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

# Supply GRUB EFI configuration.
.PHONY: arch_cd_info_dir
arch_cd_info_dir: ia64_grub_efi
	-rm -f $(TEMP_CD_INFO_DIR)/*
	mkdir -p $(TEMP_CD_INFO_DIR)

	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/; \
		grub-gencfg \
			KERNEL /%install%/vmlinuz \
			INITRD /%install%/initrd.gz \
			HEADER boot/$(ARCH)/grub/grub-efi.cfg \
		> $(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

.PHONY: arch_miniiso
arch_miniiso: ia64_grub_efi
	-rm -f $(TEMP_CD_TREE)/*
	mkdir -p $(TEMP_CD_TREE)

	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

	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/$(ARCH)/grub/grub-efi.cfg \
		> $(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)/; \
	fi

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

	if [ "$(GRUB_EFI)" = y ]; then \
		xorriso -as mkisofs -r -J -c boot.cat \
			-boot-load-size 4 -boot-info-table \
			-eltorito-alt-boot \
			--efi-boot boot/grub/efi.img -no-emul-boot \
			-o $(TEMP_MINIISO) $(TEMP_CD_TREE); \
	fi

.PHONY: arch_netboot_dir
arch_netboot_dir: ia64_grub_efi
	-rm -f $(TEMP_NETBOOT_DIR)
	mkdir -p $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)
	cp $(TEMP_KERNEL) $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)/linux
	cp $(TEMP_INITRD) $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)/initrd.gz

	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/$(ARCH)/grub/grub-efi.cfg \
		> $(TEMP_NETBOOT_DIR)/$(NETBOOT_PATH)/grub/grub.cfg; \
	fi

include config/linux.cfg
