#
+import distutils.version
import os
import os.path
import re
+import subprocess
import SCons.Action
import SCons.Builder
env['toolchain'] = 'wcesdk'
env.Tool(env['toolchain'])
+ if env['platform'] == 'embedded':
+ # Allow overriding compiler from environment
+ if os.environ.has_key('CC'):
+ env['CC'] = os.environ['CC']
+ # Update CCVERSION to match
+ pipe = SCons.Action._subproc(env, [env['CC'], '--version'],
+ stdin = 'devnull',
+ stderr = 'devnull',
+ stdout = subprocess.PIPE)
+ if pipe.wait() == 0:
+ line = pipe.stdout.readline()
+ match = re.search(r'[0-9]+(\.[0-9]+)+', line)
+ if match:
+ env['CCVERSION'] = match.group(0)
+
+
env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
env['msvc'] = env['CC'] == 'cl'
# different scons versions building the same source file
env['build'] = build_dir
env.SConsignFile(os.path.join(build_dir, '.sconsign'))
- env.CacheDir('build/cache')
+ if 'SCONS_CACHE_DIR' in os.environ:
+ print 'scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],)
+ env.CacheDir(os.environ['SCONS_CACHE_DIR'])
env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf')
env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log')
'_WINDOWS',
#'_UNICODE',
#'UNICODE',
- ('_WIN32_WINNT', '0x0501'), # minimum required OS version
- ('WINVER', '0x0501'),
+ # http://msdn.microsoft.com/en-us/library/aa383745.aspx
+ ('_WIN32_WINNT', '0x0601'),
+ ('WINVER', '0x0601'),
]
if msvc and env['toolchain'] != 'winddk':
cppdefines += [
if platform == 'wince':
cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
+ if platform == 'embedded':
+ cppdefines += ['PIPE_OS_EMBEDDED']
env.Append(CPPDEFINES = cppdefines)
# C compiler options
cxxflags = [] # C++
ccflags = [] # C & C++
if gcc:
+ ccversion = env['CCVERSION']
if debug:
ccflags += ['-O0', '-g3']
- elif env['CCVERSION'].startswith('4.2.'):
+ elif ccversion.startswith('4.2.'):
# gcc 4.2.x optimizer is broken
print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
ccflags += ['-O0', '-g3']
# instead.
ccflags += [
'-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
+ ]
+ if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'):
+ ccflags += [
'-mstackrealign', # ensure stack is aligned
]
if env['machine'] == 'x86_64':
'-Wmissing-prototypes',
'-std=gnu99',
]
- if env['CCVERSION'].startswith('4.2.') or env['CCVERSION'].startswith('4.3.'):
- ccflags += [
- '-Werror=pointer-arith',
- ]
- cflags += [
- '-Werror=declaration-after-statement',
- ]
+ if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'):
+ ccflags += [
+ '-Werror=pointer-arith',
+ ]
+ cflags += [
+ '-Werror=declaration-after-statement',
+ ]
if msvc:
# See also:
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
linkflags += ['-m32']
if env['machine'] == 'x86_64':
linkflags += ['-m64']
- shlinkflags += [
- '-Wl,-Bsymbolic',
- ]
+ if env['platform'] not in ('darwin'):
+ shlinkflags += [
+ '-Wl,-Bsymbolic',
+ ]
# Handle circular dependencies in the libraries
if env['platform'] in ('darwin'):
pass