import SCons
env = Environment(**ARGUMENTS)
+conf = Configure(env)
-if not env['CCFLAGS']:
- if env['CC'] == 'gcc':
- env['CCFLAGS'] = '-Wall -O2 -ggdb'
-env.Append(CPPDEFINES = {'FUSE_USE_VERSION': 26})
-env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64})
+destdir = env.get('DESTDIR', '/sbin');
+targets = []
+
+if 'CC' in os.environ:
+ conf.env.Replace(CC = os.environ['CC'])
+if 'CCFLAGS' in os.environ:
+ conf.env.Replace(CCFLAGS = os.environ['CCFLAGS'])
+# Set default CCFLAGS for known compilers
+if not conf.env['CCFLAGS']:
+ if conf.env['CC'] == 'gcc':
+ conf.env.Replace(CCFLAGS = '-Wall -O2 -ggdb')
+ elif conf.env['CC'] == 'clang':
+ conf.env.Replace(CCFLAGS = '-Wall -O2 -g')
+conf.env.Append(CPPDEFINES = {'FUSE_USE_VERSION': 26})
+conf.env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64})
# __DARWIN_64_BIT_INO_T=0 define is needed because since Snow Leopard inode
# numbers are 64-bit by default, but libfuse operates 32-bit ones. This define
# forces 32-bit inode declaration in system headers, but it's also possible to
# link against libfuse_ino64 instead.
if platform.system() == 'Darwin':
- env.Append(CPPDEFINES = {'__DARWIN_64_BIT_INO_T' : 0})
- env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1})
-env.Append(CPPPATH = ['libexfat'])
-env.Append(LINKFLAGS = '')
-
-env.Library('libexfat/exfat', Glob('libexfat/*.c'))
-fsck = env.Program('fsck/exfatck', Glob('fsck/*.c'), LIBS = ['exfat'], LIBPATH = 'libexfat')
-mount = env.Program('fuse/mount.exfat-fuse', Glob('fuse/*.c'), LIBS = ['exfat', 'fuse'], LIBPATH = 'libexfat')
+ conf.env.Append(CPPDEFINES = {'__DARWIN_64_BIT_INO_T' : 0})
+ conf.env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1})
+conf.env.Append(CPPPATH = ['libexfat'])
+if 'LDFLAGS' in os.environ:
+ conf.env.Append(LINKFLAGS = os.environ['LDFLAGS'])
-def get_destdir():
- try:
- destdir = os.environ['DESTDIR']
- except KeyError:
- destdir = '/sbin'
- return destdir
+env = conf.Finish()
-def make_symlink((dir)):
+def make_symlink(dir, target, link_name):
workdir = os.getcwd()
os.chdir(dir)
try:
- os.remove('mount.exfat')
+ os.remove(link_name)
except OSError:
pass
- os.symlink('mount.exfat-fuse', 'mount.exfat')
+ os.symlink(target, link_name)
os.chdir(workdir)
symlink = SCons.Action.ActionFactory(make_symlink,
- lambda dir: 'make_symlink("%s")' % dir)
-Alias('install',
- Install(dir = get_destdir(), source = mount),
- symlink(dir = get_destdir()))
+ lambda dir, target, link_name:
+ 'make_symlink("%s", "%s", "%s")' % (dir, target, link_name))
+
+def program(pattern, output, alias = None, lib = None):
+ sources = Glob(pattern)
+ if not sources:
+ return
+ libs = ['exfat']
+ if lib:
+ libs.append(lib)
+ target = env.Program(output, sources, LIBS = libs, LIBPATH = 'libexfat')
+ if alias:
+ Alias('install', Install(destdir, target),
+ symlink(destdir, os.path.basename(output), alias))
+ else:
+ Alias('install', Install(destdir, target))
+ targets.append(target)
+
+env.Library('libexfat/exfat', Glob('libexfat/*.c'))
+
+program('fuse/*.c', 'fuse/mount.exfat-fuse', 'mount.exfat', ['fuse'])
+program('dump/*.c', 'dump/dumpexfat')
+program('fsck/*.c', 'fsck/exfatfsck', 'fsck.exfat')
+program('mkfs/*.c', 'mkfs/mkexfatfs', 'mkfs.exfat')
+program('label/*.c', 'label/exfatlabel')
-Default([mount, fsck])
+Default(targets)