SubDir TOP ge-drivers libntfs-3g ;

LOCATE_TARGET = $(SUBDIR)/$(OBJDIR_PFX).$(BE_HOST_CPU) ;  # "libntfs-3g/obj-HoG.x86_64"
	# or $(GenodeRepos)/../build/.... ?


# Upstream origin:
# This replicates/tweaks << world/lib/mk/libntfs-3g.mk >>


#########  Compilation: libntfs-3g.a  #########

SetupHeadersHoG ;

SubDirHdrs $(TOP)/ge-drivers/vfs_fuse_ntfs_tts/world-src-lib-ntfs-3g ;  # config.h, sys/xattr.h
SubDirHdrs $(GenodeRepos)/../contrib/$(Contrib_ntfs3g)/src/lib/ntfs-3g/src ;
SubDirHdrs $(GenodeRepos)/../contrib/$(Contrib_ntfs3g)/include/ntfs-3g ;

SEARCH_SOURCE +=
	$(GenodeRepos)/../contrib/$(Contrib_ntfs3g)/src/lib/ntfs-3g/libntfs-3g
	;

# configure libntfs: boilerplate same as upstream Genode
# configure libntfs: also tweak to add -DHAVE_SETXATTR
# pseudo-libc support: forward libc functions with macros
#
SubDirCcFlags $(ntfs_config_defines) ;
SubDirCcFlags -DDEBUG ;  # -DDEBUG can be applied here safely (no risk of clashing with Genode's cpu_state.h DEBUG enum)
	#///ToDo-2: there are also (two) .c files built from ge-drivers/vfs_fuse_ntfs_tts/Jamfile : for completeness' sake let's add "ObjectDefines DEBUG.." on them

StaticLibrary libntfs-3g :  # Call StaticLibrary instead of just Library, as we use this .a lib also for mkntfs (linked as an exe) not just vfs_fuse.so (shared lib, does not need the MakeLocate extra)
	# contrib/ntfs-xx/src/lib/ntfs-3g/src/
	# - ntfs-3g.c
	# - ntfs-3g_common.c :
	# (those are NOT compiled here in libntfs-3g, but rather in the vfs plug-in that links against us)
	#
	# contrib/ntfs-xx/src/lib/ntfs-3g/libntfs-3g/
	acls.c
	attrib.c
	attrlist.c
	bitmap.c
	bootsect.c
	cache.c
	collate.c
	compat.c
	compress.c
	debug.c
	device.c
	dir.c
	efs.c
	index.c
	inode.c
	lcnalloc.c
	logfile.c
	logging.c
	mft.c
	misc.c
	mst.c
	object_id.c
	realpath.c
	reparse.c
	runlist.c
	security.c
	unistr.c
	unix_io.c  # this one calls fcntl() in a breaking way, needs a 'diverting' macro, see below
	volume.c
	xattrs.c
	;

# Override the fcntl() stub in Genode libc, otherwise mkntfs bails out:
ObjectCcFlags unix_io.c : "-include  fcntl_redirect2success.h" ;



