OSDN Git Service

Create symlink mount.exfat -> mount.exfat-fuse when running install target (required...
[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 SCons
23
24 # Define __DARWIN_64_BIT_INO_T=0 is needed for Snow Leopard support because
25 # in it's headers inode numbers are 64-bit by default, but libfuse operates
26 # 32-bit inode numbers. It's also possible to link against libfuse_ino64
27 # instead.
28 cflags = '-Wall -O2 -ggdb -D_FILE_OFFSET_BITS=64 -D__DARWIN_64_BIT_INO_T=0 -Ilibexfat'
29 ldflags = ''
30
31 Library('libexfat/exfat', Glob('libexfat/*.c'), CFLAGS = cflags, LINKFLAGS = ldflags)
32 fsck = Program('fsck/exfatck', Glob('fsck/*.c'), CFLAGS = cflags, LINKFLAGS = ldflags, LIBS = ['exfat'], LIBPATH = 'libexfat')
33 mount = Program('fuse/mount.exfat-fuse', Glob('fuse/*.c'), CFLAGS = cflags + ' -DFUSE_USE_VERSION=26', LINKFLAGS = ldflags, LIBS = ['exfat', 'fuse'], LIBPATH = 'libexfat')
34
35 def get_destdir():
36         try:
37                 destdir = os.environ['DESTDIR']
38         except KeyError:
39                 destdir = '/sbin'
40         return destdir
41
42 def make_symlink((dir)):
43         workdir = os.getcwd()
44         os.chdir(dir)
45         try:
46                 os.remove('mount.exfat')
47         except OSError:
48                 pass
49         os.symlink('mount.exfat-fuse', 'mount.exfat')
50         os.chdir(workdir)
51
52 symlink = SCons.Action.ActionFactory(make_symlink,
53                 lambda dir: 'make_symlink("%s")' % dir)
54 Alias('install',
55                 Install(dir = get_destdir(), source = mount),
56                 symlink(dir = get_destdir()))
57
58 Default([mount, fsck])