X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=SConstruct;h=dc31c211c3d55629477aa44c0b4e85987d71a705;hb=a7da4aa7fd048ef07d9cc2ee796c6eb0a8385c68;hp=3f96db3912ad9667ff59aab89631fa37a2e53e88;hpb=b30c1ad99f89701e883f0532fd6e19cb697538b8;p=android-x86%2Fexternal-exfat.git diff --git a/SConstruct b/SConstruct index 3f96db3..dc31c21 100644 --- a/SConstruct +++ b/SConstruct @@ -2,11 +2,12 @@ # SConstruct (10.09.09) # SConscript for all components. # -# Copyright (C) 2010-2012 Andrew Nayenko +# Free exFAT implementation. +# Copyright (C) 2010-2013 Andrew Nayenko # -# This program is free software: you can redistribute it and/or modify +# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -14,8 +15,9 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # import os @@ -23,56 +25,79 @@ import platform import SCons env = Environment(**ARGUMENTS) -conf = Configure(env) +for var in ['PATH', 'SYSROOT']: + if var in os.environ: + env['ENV'][var] = os.environ[var] destdir = env.get('DESTDIR', '/sbin'); -targets = [] libs = ['exfat'] libfuse = 'fuse' -if 'CC' in os.environ: - conf.env.Replace(CC = os.environ['CC']) -if 'CCFLAGS' in os.environ: - conf.env.Replace(CCFLAGS = os.environ['CCFLAGS']) -# Set default CCFLAGS for known compilers -if not conf.env['CCFLAGS']: - if conf.env['CC'] == 'gcc': - conf.env.Replace(CCFLAGS = '-Wall -O2 -ggdb -std=c99') - elif conf.env['CC'] == 'clang': - conf.env.Replace(CCFLAGS = '-Wall -O2 -g -std=c99') -if 'CPPFLAGS' in os.environ: - conf.env.Replace(CPPFLAGS = os.environ['CPPFLAGS']) -conf.env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64}) -conf.env.Append(CPPPATH = ['libexfat']) -if 'LDFLAGS' in os.environ: - conf.env.Append(LINKFLAGS = os.environ['LDFLAGS']) -conf.env.Append(LIBPATH = ['libexfat']) - -# GNU/Linux requires _BSD_SOURCE define for vsyslog(), _XOPEN_SOURCE >= 500 for -# pread(), pwrite(), snprintf(), strdup(), etc. Everything needed is enabled by -# _GNU_SOURCE. -if platform.system() == 'Linux': - conf.env.Append(CPPDEFINES = '_GNU_SOURCE'); - -# Use 64-bit inode numbers (introduced in Mac OS X 10.5 Leopard). Require -# OSXFUSE (http://osxfuse.github.com). -if platform.system() == 'Darwin': - conf.env.Append(CPPDEFINES = '_DARWIN_USE_64_BIT_INODE') - conf.env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1}) - conf.env.Append(CPPPATH = ['/usr/local/include/osxfuse']) - conf.env.Append(CFLAGS = '-mmacosx-version-min=10.5') - conf.env.Append(LINKFLAGS = '-mmacosx-version-min=10.5') - libfuse = 'osxfuse_i64' - -# FreeBSD does not support block devices, only raw devices. Ublio is required -# for unaligned I/O and caching. -if platform.system() == 'FreeBSD': - conf.env.Append(CPPDEFINES = 'USE_UBLIO') - libs.append('ublio') - conf.env.Append(CPPPATH = ['/usr/local/include']) - conf.env.Append(LIBPATH = ['/usr/local/lib']) - -env = conf.Finish() +if not env.GetOption('clean'): + conf = Configure(env) + + if 'AR' in os.environ: + conf.env.Replace(AR = os.environ['AR']) + if 'RANLIB' in os.environ: + conf.env.Replace(RANLIB = os.environ['RANLIB']) + if 'CC' in os.environ: + conf.env.Replace(CC = os.environ['CC']) + if 'CCFLAGS' in os.environ: + conf.env.Replace(CCFLAGS = os.environ['CCFLAGS']) + # Set default CCFLAGS for known compilers + if not conf.env['CCFLAGS']: + if conf.env['CC'] == 'gcc': + conf.env.Replace(CCFLAGS = '-Wall -O2 -ggdb -std=c99') + elif conf.env['CC'] == 'clang': + conf.env.Replace(CCFLAGS = '-Wall -O2 -g -std=c99') + if 'CPPFLAGS' in os.environ: + conf.env.Replace(CPPFLAGS = os.environ['CPPFLAGS']) + conf.env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64}) + conf.env.Append(CPPPATH = ['libexfat']) + if 'LDFLAGS' in os.environ: + conf.env.Append(LINKFLAGS = os.environ['LDFLAGS']) + conf.env.Append(LIBPATH = ['libexfat']) + + # GNU/Linux requires _BSD_SOURCE define for vsyslog(), _XOPEN_SOURCE >= 500 + # for pread(), pwrite(), snprintf(), strdup(), etc. Everything needed is + # enabled by _GNU_SOURCE. + if platform.system() == 'Linux': + conf.env.Append(CPPDEFINES = '_GNU_SOURCE'); + + # Use 64-bit inode numbers (introduced in Mac OS X 10.5 Leopard). Require + # OSXFUSE (http://osxfuse.github.com). + if platform.system() == 'Darwin': + conf.env.Append(CPPDEFINES = '_DARWIN_USE_64_BIT_INODE') + conf.env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1}) + conf.env.Append(CPPPATH = ['/usr/local/include/osxfuse']) + conf.env.Append(CFLAGS = '-mmacosx-version-min=10.5') + conf.env.Append(LINKFLAGS = '-mmacosx-version-min=10.5') + libfuse = 'osxfuse_i64' + + # FreeBSD does not support block devices, only raw devices. Ublio is + # required for unaligned I/O and caching. + if platform.system() == 'FreeBSD': + conf.env.Append(CPPDEFINES = 'USE_UBLIO') + libs.append('ublio') + conf.env.Append(CPPPATH = ['/usr/local/include']) + conf.env.Append(LIBPATH = ['/usr/local/lib']) + + if not conf.CheckCC(): + print ''' + A working C compiler is needed very much. +''' + Exit(1) + + if not conf.CheckTypeSize('off_t', '#include ', 'C', 8): + print ''' + The size of off_t type must be 64 bits. File systems larger than + 2 GB will be corrupted with 32-bit off_t. +''' + Exit(1) + + env = conf.Finish() + + def make_symlink(dir, target, link_name): workdir = os.getcwd() @@ -94,11 +119,11 @@ def program(pattern, output, alias, libs): return target = env.Program(output, sources, LIBS = libs) if alias: - Alias('install', Install(destdir, target), - symlink(destdir, os.path.basename(output), alias)) + Clean(Alias('install', Install(destdir, target), + symlink(destdir, os.path.basename(output), alias)), + destdir + '/' + alias) else: Alias('install', Install(destdir, target)) - targets.append(target) env.Library('libexfat/exfat', Glob('libexfat/*.c')) @@ -107,5 +132,3 @@ program('dump/*.c', 'dump/dumpexfat', None, libs) program('fsck/*.c', 'fsck/exfatfsck', 'fsck.exfat', libs) program('mkfs/*.c', 'mkfs/mkexfatfs', 'mkfs.exfat', libs) program('label/*.c', 'label/exfatlabel', None, libs) - -Default(targets)