+
+ifeq "$(HAS_MEMTEST)" "1"
+ # Install memtest
+ cp /usr/lib/memtest86+/memtest.bin /install/cdrom/boot/isolinux/memtest
+endif
+
+ifeq "$(HAS_IPXE)" "1"
+ cp /usr/share/ipfire-netboot/ipxe.lkrn /install/cdrom/boot/isolinux/netboot
+endif
+
+ifeq "$(EFI)" "1"
+ # Generate embedded GRUB configuration
+ sed -e "s/NAME/$(NAME)/g" -e "s/VERSION/$(VERSION)/g" -e "s/ARCH/$(BUILD_ARCH)/g" \
+ $(DIR_SRC)/config/cdrom/grub-efi.cfg > /tmp/grub-efi.cfg
+
+ # Build a GRUB EFI image
+ mkdir -pv /install/cdrom/EFI/BOOT
+ grub-mkimage \
+ --format=$(GRUB_ARCH)-efi \
+ --output=/install/cdrom/EFI/BOOT/boot$(EFI_ARCH).efi \
+ --config=/tmp/grub-efi.cfg \
+ --compression=xz \
+ --prefix=/EFI/BOOT \
+ $$(for mod in $(GRUB_EFI_MODULES); do [ -f "/usr/lib/grub/$(GRUB_ARCH)-efi/$${mod}.mod" ] && echo "$${mod}"; done)
+
+ # Install GRUB configuration
+ mkdir -pv /install/cdrom/EFI/BOOT
+ sed -e "s/NAME/$(NAME)/g" -e "s/VERSION/$(VERSION)/g" -e "s/ARCH/$(BUILD_ARCH)/g" \
+ < $(DIR_SRC)/config/cdrom/grub.cfg > /install/cdrom/EFI/BOOT/grub.cfg
+
+ # Create the EFI Eltorito image
+ dd if=/dev/zero of=/install/cdrom/boot/isolinux/efiboot.img bs=1k count=1440
+ mkdosfs -F 12 -n "IPFIRE_EFI" /install/cdrom/boot/isolinux/efiboot.img
+
+ # Mount the EFI image
+ mkdir -pv /install/efiboot.img
+ mount -o loop /install/cdrom/boot/isolinux/efiboot.img /install/efiboot.img
+
+ # Copy the bootloader into the image
+ mkdir -pv /install/efiboot.img/EFI/BOOT
+ cp -a /install/cdrom/EFI/BOOT/boot$(EFI_ARCH).efi \
+ /install/efiboot.img/EFI/BOOT/boot$(EFI_ARCH).efi
+
+ # Cleanup
+ umount /install/efiboot.img
+ rm -rf /install/efiboot.img /tmp/grub-efi.cfg
+endif
+