]> git.sven.stormbind.net Git - sven/exfat-utils.git/blobdiff - SConstruct
releasing version 0.9.8-1
[sven/exfat-utils.git] / SConstruct
index e4b2b104d6af33ab237e98e689342345e63981dc..3206c545abf656197954233c619887994dd95431 100644 (file)
@@ -2,7 +2,7 @@
 #      SConstruct (10.09.09)
 #      SConscript for all components.
 #
-#      Copyright (C) 2009, 2010  Andrew Nayenko
+#      Copyright (C) 2010-2012  Andrew Nayenko
 #
 #      This program is free software: you can redistribute it and/or modify
 #      it under the terms of the GNU General Public License as published by
@@ -23,23 +23,53 @@ import platform
 import SCons
 
 env = Environment(**ARGUMENTS)
+conf = Configure(env)
+
 destdir = env.get('DESTDIR', '/sbin');
 targets = []
+libs = ['exfat']
+
+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 -std=c99')
+       elif conf.env['CC'] == 'clang':
+               conf.env.Replace(CCFLAGS = '-Wall -O2 -g -std=c99')
+if 'CPPFLAGS' in os.environ:
+       conf.env.Replace(CPPFLAGS = os.environ['CPPFLAGS'])
+conf.env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64})
+conf.env.Append(CPPPATH = ['libexfat'])
+if 'LDFLAGS' in os.environ:
+       conf.env.Append(LINKFLAGS = os.environ['LDFLAGS'])
+conf.env.Append(LIBPATH = ['libexfat'])
+
+# GNU/Linux requires _BSD_SOURCE define for vsyslog(), _XOPEN_SOURCE >= 500 for
+# pread(), pwrite(), snprintf(), strdup(), etc. Everything needed is enabled by
+# _GNU_SOURCE.
+if platform.system() == 'Linux':
+       conf.env.Append(CPPDEFINES = '_GNU_SOURCE');
 
-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})
 # __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 = '')
+       conf.env.Append(CPPDEFINES = {'__DARWIN_64_BIT_INO_T' : 0})
+       conf.env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1})
+
+# FreeBSD does not support block devices, only raw devices. Ublio is required
+# for unaligned I/O and caching.
+if platform.system() == 'FreeBSD':
+       conf.env.Append(CPPDEFINES = 'USE_UBLIO')
+       libs.append('ublio')
+       conf.env.Append(CPPPATH = ['/usr/local/include'])
+       conf.env.Append(LIBPATH = ['/usr/local/lib'])
+
+env = conf.Finish()
 
 def make_symlink(dir, target, link_name):
        workdir = os.getcwd()
@@ -55,14 +85,11 @@ symlink = SCons.Action.ActionFactory(make_symlink,
                lambda dir, target, link_name:
                                'make_symlink("%s", "%s", "%s")' % (dir, target, link_name))
 
-def program(pattern, output, alias = None, lib = None):
+def program(pattern, output, alias, libs):
        sources = Glob(pattern)
        if not sources:
                return
-       libs = ['exfat']
-       if lib:
-               libs.append(lib)
-       target = env.Program(output, sources, LIBS = libs, LIBPATH = 'libexfat')
+       target = env.Program(output, sources, LIBS = libs)
        if alias:
                Alias('install', Install(destdir, target),
                                symlink(destdir, os.path.basename(output), alias))
@@ -72,10 +99,10 @@ def program(pattern, output, alias = None, lib = None):
 
 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')
+program('fuse/*.c', 'fuse/mount.exfat-fuse', 'mount.exfat', [libs + ['fuse']])
+program('dump/*.c', 'dump/dumpexfat', None, libs)
+program('fsck/*.c', 'fsck/exfatfsck', 'fsck.exfat', libs)
+program('mkfs/*.c', 'mkfs/mkexfatfs', 'mkfs.exfat', libs)
+program('label/*.c', 'label/exfatlabel', None, libs)
 
 Default(targets)