Import('env')
Import('rtconfig')
Import('RTT_ROOT')

dfs = Split("""
src/dfs_cache.c
src/dfs_fs.c
src/dfs_init.c
src/dfs_posix.c
src/dfs_raw.c
src/dfs_util.c
""")

# DFS-FatFs options
fatfs = Split("""
filesystems/fatfs/fatfs_cache.c
filesystems/fatfs/fatfs_direntry.c
filesystems/fatfs/fatfs_fat.c
filesystems/fatfs/fatfs_file.c
filesystems/fatfs/fatfs_filename.c
filesystems/fatfs/fatfs_init.c
filesystems/fatfs_misc.c
filesystems/fatfs/fatfs_mount.c""")

# DFS-EFSL options
efsl = Split("""
filesystems/efsl/src/base/efs.c
filesystems/efsl/src/base/extract.c
filesystems/efsl/src/base/partition.c
filesystems/efsl/src/base/plibc.c
filesystems/efsl/src/fs/vfat/dir.c
filesystems/efsl/src/fs/vfat/fat.c
filesystems/efsl/src/fs/vfat/file.c
filesystems/efsl/src/fs/vfat/fs.c
filesystems/efsl/src/fs/vfat/ls.c
filesystems/efsl/src/fs/vfat/time.c
filesystems/efsl/src/fs/vfat/ui.c
""")

# DFS-ELMFAT options
elmfat = Split("""
filesystems/elmfat/dfs_elm.c
filesystems/elmfat/ff.c
filesystems/elmfat/option/cc936.c
""")

# DFS-YAFFS2 options
yaffs2_main = Split("""
filesystems/yaffs2/direct/yaffscfg.c
filesystems/yaffs2/direct/yaffs_fileem.c
filesystems/yaffs2/direct/yaffsfs.c
filesystems/yaffs2/direct/dfs_yaffs2.c
""")

yaffs2_comm = Split("""
filesystems/yaffs2/yaffs_ecc.c
filesystems/yaffs2/yaffs_guts.c
filesystems/yaffs2/yaffs_packedtags1.c
filesystems/yaffs2/yaffs_tagscompat.c
filesystems/yaffs2/yaffs_packedtags2.c
filesystems/yaffs2/yaffs_tagsvalidity.c
filesystems/yaffs2/yaffs_nand.c
filesystems/yaffs2/yaffs_checkptrw.c
filesystems/yaffs2/yaffs_qsort.c
""")

# The set of source files associated with this SConscript file.
src_local = dfs
path = [RTT_ROOT + '/filesystem/dfs', RTT_ROOT + '/filesystem/dfs/include']

if rtconfig.RT_USING_DFS_YAFFS2:
    src_local = src_local + yaffs2_main + yaffs2_comm
    path = path + [RTT_ROOT + '/filesystem/dfs/filesystems/yaffs2', RTT_ROOT + '/filesystem/dfs/filesystems/yaffs2/direct']

if rtconfig.RT_USING_DFS_EFSL:
    src_local = src_local + efsl
    path = path + [RTT_ROOT + '/filesystem/dfs/filesystems/efsl/src/include', RTT_ROOT + '/filesystem/dfs/filesystems/efsl/src/base/include', RTT_ROOT + '/filesystem/dfs/filesystems/efsl/src/fs/vfat/include']

if rtconfig.RT_USING_DFS_ELMFAT:
    src_local = src_local + elmfat
    path = path + [RTT_ROOT + '/filesystem/dfs/filesystems/elmfat']

env.Append(CPPPATH = path)

obj = env.Object(src_local)

Return('obj')
