]> git.sven.stormbind.net Git - sven/exfat-utils.git/blob - SConstruct
Small changes for debian/copyright.
[sven/exfat-utils.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 destdir = env.get('DESTDIR', '/sbin');
27 targets = []
28
29 if not env['CCFLAGS']:
30         if env['CC'] == 'gcc':
31                 env['CCFLAGS'] = '-Wall -O2 -ggdb'
32 env.Append(CPPDEFINES = {'FUSE_USE_VERSION': 26})
33 env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64})
34 # __DARWIN_64_BIT_INO_T=0 define is needed because since Snow Leopard inode
35 # numbers are 64-bit by default, but libfuse operates 32-bit ones. This define
36 # forces 32-bit inode declaration in system headers, but it's also possible to
37 # link against libfuse_ino64 instead.
38 if platform.system() == 'Darwin':
39         env.Append(CPPDEFINES = {'__DARWIN_64_BIT_INO_T' : 0})
40         env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1})
41 env.Append(CPPPATH = ['libexfat'])
42 env.Append(LINKFLAGS = '')
43
44 def make_symlink(dir, target, link_name):
45         workdir = os.getcwd()
46         os.chdir(dir)
47         try:
48                 os.remove(link_name)
49         except OSError:
50                 pass
51         os.symlink(target, link_name)
52         os.chdir(workdir)
53
54 symlink = SCons.Action.ActionFactory(make_symlink,
55                 lambda dir, target, link_name:
56                                 'make_symlink("%s", "%s", "%s")' % (dir, target, link_name))
57
58 def program(pattern, output, alias = None, lib = None):
59         sources = Glob(pattern)
60         if not sources:
61                 return
62         libs = ['exfat']
63         if lib:
64                 libs.append(lib)
65         target = env.Program(output, sources, LIBS = libs, LIBPATH = 'libexfat')
66         if alias:
67                 Alias('install', Install(destdir, target),
68                                 symlink(destdir, os.path.basename(output), alias))
69         else:
70                 Alias('install', Install(destdir, target))
71         targets.append(target)
72
73 env.Library('libexfat/exfat', Glob('libexfat/*.c'))
74
75 program('fuse/*.c', 'fuse/mount.exfat-fuse', 'mount.exfat', ['fuse'])
76 program('dump/*.c', 'dump/dumpexfat')
77 program('fsck/*.c', 'fsck/exfatfsck', 'fsck.exfat')
78 program('mkfs/*.c', 'mkfs/mkexfatfs', 'mkfs.exfat')
79 program('label/*.c', 'label/exfatlabel')
80
81 Default(targets)