OSDN Git Service

Add exfatlabel (utility that reads or changes volume label).
[android-x86/external-exfat.git] / SConstruct
1 #
2 #       SConstruct (10.09.09)
3 #       SConscript for all components.
4 #
5 #       Copyright (C) 2009, 2010  Andrew Nayenko
6 #
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.
11 #
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.
16 #
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/>.
19 #
20
21 import os
22 import platform
23 import SCons
24
25 env = Environment(**ARGUMENTS)
26
27 if not env['CCFLAGS']:
28         if env['CC'] == 'gcc':
29                 env['CCFLAGS'] = '-Wall -O2 -ggdb'
30 env.Append(CPPDEFINES = {'FUSE_USE_VERSION': 26})
31 env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64})
32 # __DARWIN_64_BIT_INO_T=0 define is needed because since Snow Leopard inode
33 # numbers are 64-bit by default, but libfuse operates 32-bit ones. This define
34 # forces 32-bit inode declaration in system headers, but it's also possible to
35 # link against libfuse_ino64 instead.
36 if platform.system() == 'Darwin':
37         env.Append(CPPDEFINES = {'__DARWIN_64_BIT_INO_T' : 0})
38         env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1})
39 env.Append(CPPPATH = ['libexfat'])
40 env.Append(LINKFLAGS = '')
41
42 env.Library('libexfat/exfat', Glob('libexfat/*.c'))
43 mount = env.Program('fuse/mount.exfat-fuse', Glob('fuse/*.c'), LIBS = ['exfat', 'fuse'], LIBPATH = 'libexfat')
44 sbdump = env.Program('sbdump/sbdump', Glob('sbdump/*.c'), LIBS = ['exfat'], LIBPATH = 'libexfat')
45 fsck = env.Program('fsck/exfatfsck', Glob('fsck/*.c'), LIBS = ['exfat'], LIBPATH = 'libexfat')
46 mkfs = env.Program('mkfs/mkexfatfs', Glob('mkfs/*.c'), LIBS = ['exfat'], LIBPATH = 'libexfat')
47 label = env.Program('label/exfatlabel', Glob('label/*.c'), LIBS = ['exfat'], LIBPATH = 'libexfat')
48
49 def get_destdir():
50         try:
51                 destdir = os.environ['DESTDIR']
52         except KeyError:
53                 destdir = '/sbin'
54         return destdir
55
56 def make_symlink((dir)):
57         workdir = os.getcwd()
58         os.chdir(dir)
59         try:
60                 os.remove('mount.exfat')
61         except OSError:
62                 pass
63         os.symlink('mount.exfat-fuse', 'mount.exfat')
64         os.chdir(workdir)
65
66 symlink = SCons.Action.ActionFactory(make_symlink,
67                 lambda dir: 'make_symlink("%s")' % dir)
68 Alias('install',
69                 Install(dir = get_destdir(), source = mount),
70                 symlink(dir = get_destdir()))
71
72 Default([mount, sbdump, fsck, mkfs, label])