xref: /haiku/build/jam/images/AnybootImage (revision 6f80a9801fedbe7355c4360bd204ba746ec3ec2d)
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 BuildAnybootImage anybootImage : mbrPart : isoPart : imageFile {
8	local anyboot = <build>anyboot ;
9
10	Depends $(anybootImage) : $(anyboot) ;
11	Depends $(anybootImage) : $(isoPart) ;
12	Depends $(anybootImage) : $(mbrPart) ;
13	Depends $(anybootImage) : $(imageFile) ;
14
15	BuildAnybootImage1 $(anybootImage) : $(anyboot) $(mbrPart) $(isoPart) $(imageFile) ;
16}
17
18actions BuildAnybootImage1 {
19	$(2[1]) -b $(2[2]) $(2[3]) $(2[4]) $(1)
20}
21
22rule BuildAnybootImageEfi anybootImage : mbrPart : efiPart : isoPart : imageFile {
23	local anyboot = <build>anyboot ;
24
25	Depends $(anybootImage) : $(anyboot) ;
26	Depends $(anybootImage) : $(isoPart) ;
27	Depends $(anybootImage) : $(mbrPart) ;
28	Depends $(anybootImage) : $(efiPart) ;
29	Depends $(anybootImage) : $(imageFile) ;
30
31	BuildAnybootImageEfi1 $(anybootImage) : $(anyboot) $(mbrPart) $(efiPart) $(isoPart) $(imageFile) ;
32}
33
34actions BuildAnybootImageEfi1 {
35	$(2[1]) -b $(2[2]) -e $(2[3]) $(2[4]) $(2[5]) $(1)
36}
37
38local baseMBR = base_mbr.bin ;
39local mbrSource = [ FDirName $(HAIKU_TOP) src bin writembr mbr.S ] ;
40BuildMBR $(baseMBR) : $(mbrSource) ;
41MakeLocate $(baseMBR) : $(HAIKU_OUTPUT_DIR) ;
42MakeLocate $(HAIKU_ANYBOOT) : $(HAIKU_ANYBOOT_DIR) ;
43
44# Currently the Anyboot image is available only for EFI+BIOS or BIOS-only
45# systems. It is not needed for other systems, where usually you can boot
46# the same way from an USB or CD drive, instead of needing completely
47# different layouts.
48for platform in [ MultiBootSubDirSetup ] {
49	on $(platform) {
50		if $(TARGET_BOOT_PLATFORM) = efi {
51			local efiLoader = haiku_loader.efi ;
52			local efiPartition = esp.image ;
53			MakeLocateDebug $(efiPartition) : system boot ;
54			BuildEfiSystemPartition $(efiPartition) : $(efiLoader) ;
55			BuildAnybootImageEfi $(HAIKU_ANYBOOT) : $(baseMBR)
56				: $(efiPartition) : $(HAIKU_CD_BOOT_IMAGE)
57				: $(HAIKU_IMAGE_NAME) ;
58		} else if $(HAIKU_ANYBOOT_LEGACY) = 1 {
59			BuildAnybootImage $(HAIKU_ANYBOOT) : $(baseMBR)
60				: $(HAIKU_CD_BOOT_IMAGE) : $(HAIKU_IMAGE_NAME) ;
61		}
62	}
63}
64
65# TODO: this one seems to cause the build to fail each other run (caching?)
66#RmTemps $(HAIKU_ANYBOOT) : $(baseMBR) ;
67RmTemps $(HAIKU_ANYBOOT) : $(HAIKU_CD_BOOT_IMAGE) ;
68RmTemps $(HAIKU_ANYBOOT) : $(HAIKU_IMAGE_NAME) ;
69RmTemps $(HAIKU_ANYBOOT) : $(HAIKU_BOOT_FLOPPY) ;
70
71NotFile haiku-anyboot-image ;
72Depends haiku-anyboot-image : $(HAIKU_ANYBOOT) ;
73