SubDir HAIKU_TOP src tests add-ons kernel file_systems bfs r5 ;

SetSubDirSupportedPlatformsBeOSCompatible ;

# save original optimization level
oldOPTIM = $(OPTIM) ;

# set some additional defines
{
	local defines =
		KEEP_WRONG_DIRENT_RECLEN
		UNSAFE_GET_VNODE
		#BFS_BIG_ENDIAN_ONLY
		;

	# By default, the R5 API version is used unless you define this
	if $(COMPILE_FOR_ZETA) {
		defines += COMPILE_FOR_ZETA ;
	}

	# Enable OpenBFS to be compiled as a full BFS replacement. Will
	# report itself as "bfs" instead of "obfs" (only R5 version)
	if $(BFS_REPLACEMENT) {
		defines += BFS_REPLACEMENT ;
		bfsAddOnName = bfs ;
	} else {
		bfsAddOnName = obfs ;
	}

	if $(DEBUG) = 0 {
		# the gcc on BeOS doesn't compile BFS correctly with -O2 or more
		OPTIM = -O1 ;
	}

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

UsePrivateHeaders [ FDirName kernel ] ;			# For kernel_cpp.cpp

KernelStaticLibrary libbfs :
	BlockAllocator.cpp
	BPlusTree.cpp
	kernel_cpp.cpp
	Debug.cpp
	Index.cpp
	Inode.cpp
	Journal.cpp
	Query.cpp
	Utility.cpp
	Volume.cpp
	BufferPool.cpp
	;

KernelAddon $(bfsAddOnName)_r5 :
	kernel_interface_r5.cpp
	: libbfs.a
	;

SEARCH on [ FGristFiles
		kernel_cpp.cpp
	] = [ FDirName $(HAIKU_TOP) src system kernel util ] ;

#-----------------------------------------------------

rule InstallBFS
{
	Depends $(<) : $(>) ;
}

actions ignore InstallBFS
{
	cp $(>) /boot/home/config/add-ons/kernel/file_systems/
}

InstallBFS install : obfs ;

# restore original optimization level
OPTIM = $(oldOPTIM) ;
