SubDir HAIKU_TOP src system boot platform efi ;

UsePrivateHeaders [ FDirName kernel boot ] ;
UsePrivateHeaders [ FDirName kernel platform ] ;
UsePrivateHeaders [ FDirName kernel boot platform efi ] ;
UsePrivateHeaders [ FDirName kernel boot arch $(TARGET_KERNEL_ARCH_DIR) ] ;

if $(TARGET_ARCH) != x86_64 && $(TARGET_ARCH) != x86 {
	UseLibraryHeaders [ FDirName libfdt ] ;
}

SubDirHdrs $(HAIKU_TOP) src add-ons kernel partitioning_systems gpt ;

{
	local defines = _BOOT_MODE _BOOT_PLATFORM_EFI ;

	if $(TARGET_ARCH) != x86_64 && $(TARGET_ARCH) != x86 {
		defines += _BOOT_FDT_SUPPORT ;
	}

	defines = [ FDefines $(defines) ] ;
	SubDirCcFlags $(defines) ;
	SubDirC++Flags $(defines) -fno-rtti ;
}

local platform_src =
	start.cpp
	console.cpp
	cpu.cpp
	video.cpp
	debug.cpp
	mmu.cpp
	heap.cpp
	acpi.cpp
	timer.cpp
	menu.cpp
	devices.cpp
	quirks.cpp
	smp.cpp
	serial.cpp
	;

local support_libs ;

if $(TARGET_ARCH) != x86_64 && $(TARGET_ARCH) != x86 {
	support_libs += boot_fdt.a ;
	platform_src += dtb.cpp ;
}

local platform ;
for platform in [ MultiBootSubDirSetup efi ] {
	on $(platform) {

		BootMergeObject boot_platform_efi_common.o :
			$(platform_src)
			: :
			[ MultiBootGristFiles $(support_libs) ]
			boot_platform_generic_efi.a
		;

		BootMergeObject boot_platform_efi.o :
			: :
			boot_platform_efi_$(TARGET_ARCH).o
			boot_platform_efi_common.o
		;
	}
}

SubInclude HAIKU_TOP src system boot platform efi arch $(TARGET_ARCH) ;