2 # SConstruct (10.09.09)
3 # SConscript for all components.
5 # Copyright (C) 2010-2012 Andrew Nayenko
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 env = Environment(**ARGUMENTS)
28 destdir = env.get('DESTDIR', '/sbin');
33 if 'CC' in os.environ:
34 conf.env.Replace(CC = os.environ['CC'])
35 if 'CCFLAGS' in os.environ:
36 conf.env.Replace(CCFLAGS = os.environ['CCFLAGS'])
37 # Set default CCFLAGS for known compilers
38 if not conf.env['CCFLAGS']:
39 if conf.env['CC'] == 'gcc':
40 conf.env.Replace(CCFLAGS = '-Wall -O2 -ggdb -std=c99')
41 elif conf.env['CC'] == 'clang':
42 conf.env.Replace(CCFLAGS = '-Wall -O2 -g -std=c99')
43 if 'CPPFLAGS' in os.environ:
44 conf.env.Replace(CPPFLAGS = os.environ['CPPFLAGS'])
45 conf.env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64})
46 conf.env.Append(CPPPATH = ['libexfat'])
47 if 'LDFLAGS' in os.environ:
48 conf.env.Append(LINKFLAGS = os.environ['LDFLAGS'])
49 conf.env.Append(LIBPATH = ['libexfat'])
51 # GNU/Linux requires _BSD_SOURCE define for vsyslog(), _XOPEN_SOURCE >= 500 for
52 # pread(), pwrite(), snprintf(), strdup(), etc. Everything needed is enabled by
54 if platform.system() == 'Linux':
55 conf.env.Append(CPPDEFINES = '_GNU_SOURCE');
57 # Use 64-bit inode numbers (introduced in Mac OS X 10.5 Leopard). Require
58 # OSXFUSE (http://osxfuse.github.com).
59 if platform.system() == 'Darwin':
60 conf.env.Append(CPPDEFINES = '_DARWIN_USE_64_BIT_INODE')
61 conf.env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1})
62 conf.env.Append(CPPPATH = ['/usr/local/include/osxfuse'])
63 conf.env.Append(CFLAGS = '-mmacosx-version-min=10.5')
64 conf.env.Append(LINKFLAGS = '-mmacosx-version-min=10.5')
65 libfuse = 'osxfuse_i64'
67 # FreeBSD does not support block devices, only raw devices. Ublio is required
68 # for unaligned I/O and caching.
69 if platform.system() == 'FreeBSD':
70 conf.env.Append(CPPDEFINES = 'USE_UBLIO')
72 conf.env.Append(CPPPATH = ['/usr/local/include'])
73 conf.env.Append(LIBPATH = ['/usr/local/lib'])
77 def make_symlink(dir, target, link_name):
84 os.symlink(target, link_name)
87 symlink = SCons.Action.ActionFactory(make_symlink,
88 lambda dir, target, link_name:
89 'make_symlink("%s", "%s", "%s")' % (dir, target, link_name))
91 def program(pattern, output, alias, libs):
92 sources = Glob(pattern)
95 target = env.Program(output, sources, LIBS = libs)
97 Alias('install', Install(destdir, target),
98 symlink(destdir, os.path.basename(output), alias))
100 Alias('install', Install(destdir, target))
101 targets.append(target)
103 env.Library('libexfat/exfat', Glob('libexfat/*.c'))
105 program('fuse/*.c', 'fuse/mount.exfat-fuse', 'mount.exfat', [libs + [libfuse]])
106 program('dump/*.c', 'dump/dumpexfat', None, libs)
107 program('fsck/*.c', 'fsck/exfatfsck', 'fsck.exfat', libs)
108 program('mkfs/*.c', 'mkfs/mkexfatfs', 'mkfs.exfat', libs)
109 program('label/*.c', 'label/exfatlabel', None, libs)