SubDir OBOS_TOP src tests kernel boot loader ;

UsePrivateHeaders [ FDirName kernel ] ;
UsePrivateHeaders [ FDirName kernel disk_device_manager ] ;
UsePrivateHeaders [ FDirName storage ] ;
SubDirHdrs $(OBOS_TOP) headers private kernel arch $(OBOS_ARCH) ;

# we need to redefine certain calls in the boot loader so that
# they will really be used instead of their POSIX counterparts
# in libroot.so

ObjectsDefines
	# boot loader
	main.cpp
	vfs.cpp
	partitions.cpp
	RootFileSystem.cpp
	elf.cpp
	menu.cpp
	loader.cpp
	kernel_args.cpp

	# partitions
	amiga_rdb.cpp
	apple.cpp
	intel.cpp
	PartitionMap.cpp
	:
	read_pos=boot_read_pos fstat=boot_fstat open=boot_open close=boot_close main=boot_main
	;

{
	local defines =
		_BOOT_MODE
		BOOT_ARCH=\\\"intel\\\"
			# the boot loader test application will try to load the BeOS kernel
			# from a supported partition/file system

		BOOT_SUPPORT_PARTITION_AMIGA
		BOOT_SUPPORT_PARTITION_APPLE
		BOOT_SUPPORT_PARTITION_INTEL

		BOOT_SUPPORT_FILE_SYSTEM_BFS
		BOOT_SUPPORT_FILE_SYSTEM_AMIGA_FFS
		;

	defines = [ FDefines $(defines) ] ;

	if $(OS) = "LINUX" {
	#	SubDirC++Flags -include /usr/include/stdio.h ;
	} else {
	#	SubDirC++Flags -include /boot/develop/headers/posix/stdio.h ;
		SubDirC++Flags $(defines) -DHAVE_READ_POS=1 -fcheck-memory-usage -D_NO_INLINE_ASM ;
	}
}

SimpleTest BootLoaderTest :
	# userland bindings
	platform_start.cpp
	platform_debug.cpp
	platform_devices.cpp
	platform_heap.cpp
	platform_misc.cpp
	platform_mmu.cpp
	Handle.cpp

	# boot loader
	main.cpp
	vfs.cpp
	partitions.cpp
	RootFileSystem.cpp
	elf.cpp
	menu.cpp
	loader.cpp
	kernel_args.cpp

	# partitioning systems
	amiga_rdb.cpp
	apple.cpp
	intel.cpp
	PartitionMap.cpp

	# utility functions - Dano has a strlcpy() function in libroot.so, while R5 has not
	list.c
	strlcpy.c

	: boottest_bfs.a boottest_amiga_ffs.a
	;

# Tell Jam where to find the utility sources

SEARCH on [ FGristFiles list.c ]
	= [ FDirName $(OBOS_TOP) src kernel core util ] ;

SEARCH on [ FGristFiles strlcpy.c ]
	= [ FDirName $(OBOS_TOP) src kernel libroot posix string ] ;

SEARCH on [ FGristFiles 
		main.cpp vfs.cpp partitions.cpp
		heap.cpp RootFileSystem.cpp
		elf.cpp menu.cpp loader.cpp
		kernel_args.cpp
	] = [ FDirName $(OBOS_TOP) src kernel boot loader ] ;

# partitioning system modules

SEARCH on [ FGristFiles amiga_rdb.cpp ]
	= [ FDirName $(OBOS_TOP) src add-ons kernel partitioning_systems amiga ] ;

SEARCH on [ FGristFiles apple.cpp ]
	= [ FDirName $(OBOS_TOP) src add-ons kernel partitioning_systems apple ] ;

SEARCH on [ FGristFiles intel.cpp PartitionMap.cpp ]
	= [ FDirName $(OBOS_TOP) src add-ons kernel partitioning_systems intel ] ;


SubInclude OBOS_TOP src tests kernel boot loader file_systems ;
