diff -r 249553e1d4fe -r 2c154aad7f33 SConstruct --- a/SConstruct Fri Apr 11 12:46:36 2008 +0200 +++ b/SConstruct Sat Apr 12 02:02:45 2008 +0200 @@ -31,7 +31,7 @@ import os, sys env = Environment(ENV = {'PATH' : os.environ['PATH']}) -#Decider('MD5-timestamp') +Decider('MD5-timestamp') opt = Options(['.optioncache']) opt.AddOptions( @@ -61,24 +61,15 @@ 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 - -intelc = Tool("intelc").exists(env) == True def CheckIntelC(context): - global intelc + global intelc, intelcversion context.Message('Checking for Intel C++ Compiler... ') + intelc = Tool("intelc").exists(env) == True if intelc: testenv = Environment() Tool("intelc").generate(testenv) - context.Result(str(testenv['INTEL_C_COMPILER_VERSION']/10.)) + intelcversion = str(testenv['INTEL_C_COMPILER_VERSION']/10.) + context.Result(intelcversion) else: context.Result(intelc) return intelc @@ -88,20 +79,29 @@ context.Message('Checking for GCC... ') gcc = "g++" in env['TOOLS'] if gcc: - gccversion = os.popen("g++ --version").read().split()[2] + gccversion = env['CCVERSION'] context.Result(gccversion) else: context.Result(False) return gcc +def CheckCPUFlags(context): + global cpu, cpuflags_gcc, cpuflags_intelc + context.Message('Checking CPU arch and flags... ') + env.Execute('@$CC tools/cpuflags.c -o tools/cpuflags') + (cpu, cpuflags_gcc, cpuflags_intelc) = os.popen('tools/cpuflags %s %s' + % (''.join(gccversion.rsplit('.',1)), intelcversion) ).read().split('\n')[:3] + context.Result(cpu) + return True + conf = Configure(env, custom_tests = { - 'CheckPlatform' : CheckPlatform, 'CheckCPU' : CheckCPU, + 'CheckPlatform' : CheckPlatform, 'CheckCPUFlags' : CheckCPUFlags, 'CheckIntelC' : CheckIntelC, 'CheckGCC' : CheckGCC}) conf.CheckPlatform() -conf.CheckCPU() conf.CheckGCC() conf.CheckIntelC() +conf.CheckCPUFlags() env = conf.Finish() @@ -113,14 +113,9 @@ add_flags = '' if cc == 'gcc': - add_flags += '-ffast-math ' -if cpu == 'core2': - if (cc == 'intelc' or gccversion[:3] == '4.3'): - add_flags += '-march=core2 -mtune=core2 ' - if cc == 'intelc': - add_flags += '-xT ' - if cc == 'gcc': - add_flags += '-msse3 -mfpmath=sse ' + add_flags += cpuflags_gcc + ' -ffast-math ' +if cc == 'intelc': + add_flags += cpuflags_intelc + ' ' if env['precision'] == 'double': add_flags += '-DPYRIT_DOUBLE '