1# Set anyboot file name and directory defaults.
2HAIKU_ANYBOOT_NAME ?= $(HAIKU_DEFAULT_ANYBOOT_NAME) ;
3HAIKU_ANYBOOT_DIR ?= $(HAIKU_DEFAULT_ANYBOOT_DIR) ;
4HAIKU_ANYBOOT = $(HAIKU_ANYBOOT_NAME) ;
5HAIKU_ANYBOOT_LABEL ?= $(HAIKU_DEFAULT_ANYBOOT_LABEL) ;
6
7rule BuildAnybootImageEfi anybootImage : mbrPart : efiPart : isoPart : imageFile {
8	local anyboot = <build>anyboot ;
9
10	Depends $(anybootImage) : $(anyboot) ;
11	Depends $(anybootImage) : $(isoPart) ;
12	Depends $(anybootImage) : $(mbrPart) ;
13	Depends $(anybootImage) : $(efiPart) ;
14	Depends $(anybootImage) : $(imageFile) ;
15
16	BuildAnybootImageEfi1 $(anybootImage) : $(anyboot) $(mbrPart) $(efiPart) $(isoPart) $(imageFile) ;
17}
18
19actions BuildAnybootImageEfi1 {
20	$(2[1]) -b $(2[2]) -e $(2[3]) $(2[4]) $(2[5]) $(1)
21}
22
23local baseMBR = base_mbr.bin ;
24local mbrSource = [ FDirName $(HAIKU_TOP) src bin writembr mbr.S ] ;
25BuildMBR $(baseMBR) : $(mbrSource) ;
26MakeLocate $(baseMBR) : $(HAIKU_OUTPUT_DIR) ;
27MakeLocate $(HAIKU_ANYBOOT) : $(HAIKU_ANYBOOT_DIR) ;
28
29# Currently the Anyboot image is available only for EFI+BIOS or BIOS-only
30# systems. It is not needed for other systems, where usually you can boot
31# the same way from an USB or CD drive, instead of needing completely
32# different layouts.
33for platform in [ MultiBootSubDirSetup ] {
34	on $(platform) {
35		if $(TARGET_BOOT_PLATFORM) = efi {
36			local efiLoader = haiku_loader.efi ;
37			local efiPartition = esp.image ;
38			MakeLocateDebug $(efiPartition) : system boot ;
39			BuildEfiSystemPartition $(efiPartition) : $(efiLoader) ;
40			BuildAnybootImageEfi $(HAIKU_ANYBOOT) : $(baseMBR)
41				: $(efiPartition) : $(HAIKU_CD_BOOT_IMAGE)
42				: $(HAIKU_IMAGE_NAME) ;
43		}
44	}
45}
46
47# TODO: this one seems to cause the build to fail each other run (caching?)
48#RmTemps $(HAIKU_ANYBOOT) : $(baseMBR) ;
49RmTemps $(HAIKU_ANYBOOT) : $(HAIKU_CD_BOOT_IMAGE) ;
50RmTemps $(HAIKU_ANYBOOT) : $(HAIKU_IMAGE_NAME) ;
51RmTemps $(HAIKU_ANYBOOT) : $(HAIKU_BOOT_FLOPPY) ;
52
53NotFile haiku-anyboot-image ;
54Depends haiku-anyboot-image : $(HAIKU_ANYBOOT) ;
55