# Filesystem type for the initrd.
INITRD_FS = ext2

# We have to redefine genext2fs to use 4k blocks and leave some space
define genext2fs
  nb=$$(find $(TREE) | wc -l); \
  sz=$$(du -s $(TREE) | cut -f 1); \
  genext2fs -d $(TREE) -B 4096 -o hurd -m 0 \
	-b $$(expr $$sz / 4 + $$nb / 2 + 1024) \
	-N $$(expr $$nb + 1024)
endef

# The image to use for a syslinux splash screen.
SPLASH_PNG=boot/hurd/pics/klowner-hurd.png

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

# Library reduction needs some extra stuff which for now
# is not usually available.
MKLIBS = mklibs-copy

# Unsupported targets
arch_boot_screens:
arch_tree:

# Miniature CD image using GRUB, with only an initrd, no udebs or debs.
.PHONY: arch_miniiso
arch_miniiso: $(TEMP_INITRD) $(TEMP_KERNEL) $(TREE)
	-rm -f $(TEMP_CD_TREE)/*
	mkdir -p $(TEMP_CD_TREE)/boot/kernel
	mkdir -p $(TEMP_CD_TREE)/boot/grub

	cp $(TEMP_KERNEL)		$(TEMP_CD_TREE)/boot/kernel/
	cp $(TEMP_INITRD)		$(TEMP_CD_TREE)/boot/initrd.gz
	cp $(GRUB_CFG)			$(TEMP_CD_TREE)/boot/grub/grub.cfg
	if [ -n "$(GRUB_FONT)" ] ; then \
		cp $(GRUB_FONT) $(TEMP_CD_TREE)/boot/grub/font.pf2; \
	fi
	if [ -n "$(SPLASH_PNG)" ]; then \
		cp $(SPLASH_PNG) $(TEMP_CD_TREE)/boot/grub/splash.png; \
	fi

	grub-mkrescue --output=$(TEMP_MINIISO) $(TEMP_CD_TREE)

# Netboot files
.PHONY: arch_netboot_dir
arch_netboot_dir:
	-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)

