OSDN Git Service

Support building on FreeBSD.
[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 conf = Configure(env)
27
28 destdir = env.get('DESTDIR', '/sbin');
29 targets = []
30
31 if 'CC' in os.environ:
32         conf.env.Replace(CC = os.environ['CC'])
33 if 'CCFLAGS' in os.environ:
34         conf.env.Replace(CCFLAGS = os.environ['CCFLAGS'])
35 # Set default CCFLAGS for known compilers
36 if not conf.env['CCFLAGS']:
37         if conf.env['CC'] == 'gcc':
38                 conf.env.Replace(CCFLAGS = '-Wall -O2 -ggdb')
39         elif conf.env['CC'] == 'clang':
40                 conf.env.Replace(CCFLAGS = '-Wall -O2 -g')
41 conf.env.Append(CPPDEFINES = {'FUSE_USE_VERSION': 26})
42 conf.env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64})
43 conf.env.Append(CPPPATH = ['libexfat'])
44 if 'LDFLAGS' in os.environ:
45         conf.env.Append(LINKFLAGS = os.environ['LDFLAGS'])
46 conf.env.Append(LIBPATH = ['libexfat'])
47
48 # __DARWIN_64_BIT_INO_T=0 define is needed because since Snow Leopard inode
49 # numbers are 64-bit by default, but libfuse operates 32-bit ones. This define
50 # forces 32-bit inode declaration in system headers, but it's also possible to
51 # link against libfuse_ino64 instead.
52 if platform.system() == 'Darwin':
53         conf.env.Append(CPPDEFINES = {'__DARWIN_64_BIT_INO_T' : 0})
54         conf.env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1})
55
56 if platform.system() == 'FreeBSD':
57         conf.env.Append(CPPPATH = ['/usr/local/include'])
58         conf.env.Append(LIBPATH = ['/usr/local/lib'])
59
60 env = conf.Finish()
61
62 def make_symlink(dir, target, link_name):
63         workdir = os.getcwd()
64         os.chdir(dir)
65         try:
66                 os.remove(link_name)
67         except OSError:
68                 pass
69         os.symlink(target, link_name)
70         os.chdir(workdir)
71
72 symlink = SCons.Action.ActionFactory(make_symlink,
73                 lambda dir, target, link_name:
74                                 'make_symlink("%s", "%s", "%s")' % (dir, target, link_name))
75
76 def program(pattern, output, alias = None, lib = None):
77         sources = Glob(pattern)
78         if not sources:
79                 return
80         libs = ['exfat']
81         if lib:
82                 libs.append(lib)
83         target = env.Program(output, sources, LIBS = libs)
84         if alias:
85                 Alias('install', Install(destdir, target),
86                                 symlink(destdir, os.path.basename(output), alias))
87         else:
88                 Alias('install', Install(destdir, target))
89         targets.append(target)
90
91 env.Library('libexfat/exfat', Glob('libexfat/*.c'))
92
93 program('fuse/*.c', 'fuse/mount.exfat-fuse', 'mount.exfat', ['fuse'])
94 program('dump/*.c', 'dump/dumpexfat')
95 program('fsck/*.c', 'fsck/exfatfsck', 'fsck.exfat')
96 program('mkfs/*.c', 'mkfs/mkexfatfs', 'mkfs.exfat')
97 program('label/*.c', 'label/exfatlabel')
98
99 Default(targets)