SubDir HAIKU_TOP src tests add-ons kernel file_systems fs_shell ;

include [ FDirName $(HAIKU_TOP) src tests add-ons kernel file_systems fs_shell
				   FSShellRules ] ;

# We compile the fs_shell in a mixed environment: We use the platform POSIX
# and STL headers (to have a proper interface to use), and we use all other
# BeOS specific headers. Ideally we would get rid of the latter, but we still
# have dependencies to them.

# platform specific sources
local fsShellCommandSources ;
local externalCommandsSources ;
local attributeSupportSources ;
local byteOrderSupportSources ;
if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
	fsShellCommandSources = fs_shell_command_beos.cpp ;
	externalCommandsSources = external_commands_beos.cpp ;
} else {
	fsShellCommandSources = fs_shell_command_unix.cpp ;
	externalCommandsSources = external_commands_unix.cpp ;
	attributeSupportSources = fs_attr.cpp ;
	byteOrderSupportSources = byteorder.cpp ;
}

SetupFSShellIncludes ;

if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
	SubDirHdrs [ FDirName $(HAIKU_TOP) src build libroot ] ;
}

UsePrivateHeaders shared ;

rule BuildLibFSShell
{
	# some defines actually only relevant for fs_attr.cpp
	local defines =
		HAIKU_BUILD_ATTRIBUTES_DIR="\\\"$(HAIKU_BUILD_ATTRIBUTES_DIR)\\\""
		BUILDING_FS_SHELL=1
	;
	
	ObjectDefines $(2) : $(defines) ;

	BuildPlatformStaticLibrary $(1) : $(2) : false ;
}

{
	local defines = [ FDefines USER _GNU_SOURCE ] ;
	SubDirCcFlags $(defines) ;
	SubDirC++Flags $(defines) -fno-exceptions -fno-rtti ;
}
		
BuildLibFSShell libfs_shell.a
	:
	fsh.cpp rootfs.c initfs.c kernel.c cache.c $(externalCommandsSources) sl.c
	stub.c tracker.cpp sysdep.c hexdump.c argv.c errors.cpp xcp.cpp
	path_util.cpp stat_util.cpp
	$(attributeSupportSources)
	$(byteOrderSupportSources)
;

SEARCH on [ FGristFiles fs_attr.cpp byteorder.cpp ]
	= [ FDirName $(HAIKU_TOP) src build libroot ] ;

# fs_shell_command

BuildPlatformMain fs_shell_command
	: fs_shell_command.cpp $(fsShellCommandSources) ;
