SubDir HAIKU_TOP src tools makebootable platform bios_ia32 ;

SubDirHdrs $(HAIKU_TOP) src add-ons kernel file_systems bfs ;

UsePrivateHeaders storage shared ;
UsePrivateSystemHeaders system ;

SEARCH_SOURCE
	+= [ FDirName $(HAIKU_TOP) src bin makebootable platform bios_ia32 ] ;

USES_BE_API on <build>makebootable = true ;

local hostPlatformSources ;
if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd || $(HOST_PLATFORM) = darwin {
	hostPlatformSources = PartitionMap.cpp PartitionMapParser.cpp ;

	SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel
		partitioning_systems intel ] ;

	DEFINES += _USER_MODE ;
}

# Write the stage 1 boot loader into the makebootable resources. On Darwin
# resources don't seem to work; there we use an attribute instead.
if $(HOST_PLATFORM) != darwin && $(HOST_PLATFORM) != cygwin
	&& $(HOST_PLATFORM) != sunos {
	AddFileDataResource <build>makebootable : RAWT:666:BootCode : stage1.bin ;
}

BuildPlatformMain <build>makebootable :
	makebootable.cpp
	$(hostPlatformSources)
	: $(HOST_LIBBE) $(HOST_LIBSTDC++) $(HOST_LIBSUPC++)
;

# on Darwin write the boot loader code into an attribute
if $(HOST_PLATFORM) = darwin || $(HOST_PLATFORM) = cygwin
	|| $(HOST_PLATFORM) = sunos {
	AddFileDataAttribute <build>makebootable : BootCode : raw : stage1.bin ;
}
