diff -r 5785cca4cdb9 -r 242839c6d27d SConstruct --- a/SConstruct Wed Apr 09 17:55:29 2008 +0200 +++ b/SConstruct Thu Apr 10 23:20:36 2008 +0200 @@ -25,32 +25,116 @@ - everything but docs and downloadable models Default target is no-download. + +Options: """) +import os, sys +env = Environment(ENV = {'PATH' : os.environ['PATH']}) Decider('MD5-timestamp') -import os -env = Environment(ENV = {'PATH' : os.environ['PATH']}) + +opt = Options(['.optioncache']) +opt.AddOptions( + BoolOption('intelc', 'use Intel C++ Compiler, if available', True), + ('flags', 'add additional compiler flags', ""), +) +if env['PLATFORM'] == 'win32': + opt.AddOptions( + ('pythonpath', 'path to Python installation', + 'C:\\Python%c%c' % (sys.version[0], sys.version[2])), + ) +opt.Update(env) +opt.Save('.optioncache', env) +Help(opt.GenerateHelpText(env)) + +if env['intelc']: + Tool("intelc")(env) -### GNU C++ Compiler -#env.Replace(CXX="g++") -#env.Append(CCFLAGS="-O3 -Wall -pipe -ffast-math -msse3 ") +platform = 'unknown' +def CheckPlatform(context): + global platform + context.Message('Platform is... ') + if sys.platform[:5] == 'linux': + platform = 'linux' + elif env['PLATFORM'] == 'posix': + platform = 'posix' + elif env['PLATFORM'] == 'win32': + platform = 'win32' + context.Result(platform) + return True + +cpu = 'unknown' +def CheckCPU(context): + global cpu, platform + context.Message('Checking CPU model... ') + if (platform == 'linux'): + if (os.system("cat /proc/cpuinfo | grep 'Core(TM)2 CPU' >/dev/null") == 0): + cpu = 'core2' + context.Result(cpu) + return True -### Intel C++ Compiler -env.Replace(CXX="icpc") -env.Append(CCFLAGS="-O3 -w1 -mtune=core2 -xT ") +def CheckIntelC(context): + global intelc + context.Message('Checking for Intel C++ Compiler... ') + intelc = "intelc" in env['TOOLS'] + context.Result(intelc) + return intelc + +def CheckGCC(context): + global gcc, gccversion + context.Message('Checking for GCC... ') + gcc = "g++" in env['TOOLS'] + if gcc: + gccversion = os.popen("g++ --version").read().split()[2] + context.Result(gccversion) + else: + context.Result(False) + return gcc + +conf = Configure(env, + custom_tests = { + 'CheckPlatform' : CheckPlatform, 'CheckCPU' : CheckCPU, + 'CheckIntelC' : CheckIntelC, 'CheckGCC' : CheckGCC}) +conf.CheckPlatform() +conf.CheckCPU() +conf.CheckGCC() +conf.CheckIntelC() +env = conf.Finish() -### MinGW32 -# PY_CCFLAGS=-I"C:\Program Files\Python25\include" -# PY_LDFLAGS=-L"C:\Program Files\Python25\libs" -lpython25 +if intelc: + cc = 'intelc' +elif gcc: + cc = 'gcc' + +cpu_flags = '' +if cc == 'gcc': + cpu_flags += '-ffast-math ' +if cpu == 'core2': + if (cc == 'intelc' or gccversion[:3] == '4.3'): + cpu_flags += '-march=core2 -mtune=core2 ' + if cc == 'intelc': + cpu_flags += '-xT ' + if cc == 'gcc': + cpu_flags += '-msse3 -mfpmath=sse ' +cpu_flags += env['flags'] + +if intelc: + env.Append(CCFLAGS="-O3 -w1 " + cpu_flags) +elif gcc: + env.Append(CCFLAGS="-O3 -Wall -pipe " + cpu_flags) + # CCFLAGS= -fno-strict-aliasing +else: + print "No supported compiler found." + Exit(1) + +print "Additional compiler flags: " + cpu_flags # pthread if env['PLATFORM'] == 'win32': - env.Append(LINKFLAGS="-lpthreadGC2 ") + env.Append(LIBS=["pthreadGC2"]) else: env.Append(CCFLAGS="-pthread ") -# CCFLAGS=-g -fno-strict-aliasing - # float: -fsingle-precision-constant # double: -DPYRIT_DOUBLE (lib, pymodule) = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, exports='env')