SConstruct
branchpyrit
changeset 65 242839c6d27d
parent 64 5785cca4cdb9
child 66 c5b89d16497a
equal deleted inserted replaced
64:5785cca4cdb9 65:242839c6d27d
    23                      - everything but docs
    23                      - everything but docs
    24     no-download = (libs, demos, local-models)
    24     no-download = (libs, demos, local-models)
    25                      - everything but docs and downloadable models
    25                      - everything but docs and downloadable models
    26 
    26 
    27 Default target is no-download.
    27 Default target is no-download.
       
    28 
       
    29 Options:
    28 """)
    30 """)
    29 
    31 
       
    32 import os, sys
       
    33 env = Environment(ENV = {'PATH' : os.environ['PATH']})
    30 Decider('MD5-timestamp')
    34 Decider('MD5-timestamp')
    31 import os
       
    32 env = Environment(ENV = {'PATH' : os.environ['PATH']})
       
    33 
    35 
    34 ### GNU C++ Compiler
    36 opt = Options(['.optioncache'])
    35 #env.Replace(CXX="g++")
    37 opt.AddOptions(
    36 #env.Append(CCFLAGS="-O3 -Wall -pipe -ffast-math -msse3 ")
    38 	BoolOption('intelc', 'use Intel C++ Compiler, if available', True),
       
    39 	('flags', 'add additional compiler flags', ""),
       
    40 )
       
    41 if env['PLATFORM'] == 'win32':
       
    42 	opt.AddOptions(
       
    43 		('pythonpath', 'path to Python installation',
       
    44 			'C:\\Python%c%c' % (sys.version[0], sys.version[2])),
       
    45 		)
       
    46 opt.Update(env)
       
    47 opt.Save('.optioncache', env)
       
    48 Help(opt.GenerateHelpText(env))
    37 
    49 
    38 ### Intel C++ Compiler
    50 if env['intelc']:
    39 env.Replace(CXX="icpc")
    51 	Tool("intelc")(env)
    40 env.Append(CCFLAGS="-O3 -w1 -mtune=core2 -xT ")
       
    41 
    52 
    42 ### MinGW32
    53 platform = 'unknown'
    43 #  PY_CCFLAGS=-I"C:\Program Files\Python25\include"
    54 def CheckPlatform(context):
    44 #  PY_LDFLAGS=-L"C:\Program Files\Python25\libs" -lpython25
    55 	global platform
       
    56 	context.Message('Platform is... ')
       
    57 	if sys.platform[:5] == 'linux':
       
    58 		platform = 'linux'
       
    59 	elif env['PLATFORM'] == 'posix':
       
    60 		platform = 'posix'
       
    61 	elif env['PLATFORM'] == 'win32':
       
    62 		platform = 'win32'
       
    63 	context.Result(platform)
       
    64 	return True
       
    65 
       
    66 cpu = 'unknown'
       
    67 def CheckCPU(context):
       
    68 	global cpu, platform
       
    69 	context.Message('Checking CPU model... ')
       
    70 	if (platform == 'linux'):
       
    71 		if (os.system("cat /proc/cpuinfo | grep 'Core(TM)2 CPU' >/dev/null") == 0):
       
    72 			cpu = 'core2'
       
    73 	context.Result(cpu)
       
    74 	return True
       
    75 
       
    76 def CheckIntelC(context):
       
    77 	global intelc
       
    78 	context.Message('Checking for Intel C++ Compiler... ')
       
    79 	intelc = "intelc" in env['TOOLS']
       
    80 	context.Result(intelc)
       
    81 	return intelc
       
    82 
       
    83 def CheckGCC(context):
       
    84 	global gcc, gccversion
       
    85 	context.Message('Checking for GCC... ')
       
    86 	gcc = "g++" in env['TOOLS']
       
    87 	if gcc:
       
    88 		gccversion = os.popen("g++ --version").read().split()[2]
       
    89 		context.Result(gccversion)
       
    90 	else:
       
    91 		context.Result(False)
       
    92 	return gcc
       
    93 
       
    94 conf = Configure(env,
       
    95 	custom_tests = {
       
    96 		'CheckPlatform' : CheckPlatform, 'CheckCPU' : CheckCPU,
       
    97 		'CheckIntelC' : CheckIntelC, 'CheckGCC' : CheckGCC})
       
    98 conf.CheckPlatform()
       
    99 conf.CheckCPU()
       
   100 conf.CheckGCC()
       
   101 conf.CheckIntelC()
       
   102 env = conf.Finish()
       
   103 
       
   104 if intelc:
       
   105 	cc = 'intelc'
       
   106 elif gcc:
       
   107 	cc = 'gcc'
       
   108 
       
   109 cpu_flags = ''
       
   110 if cc == 'gcc':
       
   111 	cpu_flags += '-ffast-math '
       
   112 if cpu == 'core2':
       
   113 	if (cc == 'intelc' or gccversion[:3] == '4.3'):
       
   114 		cpu_flags += '-march=core2 -mtune=core2 '
       
   115 	if cc == 'intelc':
       
   116 		cpu_flags += '-xT '
       
   117 	if cc == 'gcc':
       
   118 		cpu_flags += '-msse3 -mfpmath=sse '
       
   119 cpu_flags += env['flags']
       
   120 
       
   121 if intelc:
       
   122 	env.Append(CCFLAGS="-O3 -w1 " + cpu_flags)
       
   123 elif gcc:
       
   124 	env.Append(CCFLAGS="-O3 -Wall -pipe " + cpu_flags)
       
   125 	# CCFLAGS= -fno-strict-aliasing
       
   126 else:
       
   127 	print "No supported compiler found."
       
   128 	Exit(1)
       
   129 
       
   130 print "Additional compiler flags: " + cpu_flags
    45 
   131 
    46 # pthread
   132 # pthread
    47 if env['PLATFORM'] == 'win32':
   133 if env['PLATFORM'] == 'win32':
    48 	env.Append(LINKFLAGS="-lpthreadGC2 ")
   134 	env.Append(LIBS=["pthreadGC2"])
    49 else:
   135 else:
    50 	env.Append(CCFLAGS="-pthread ")
   136 	env.Append(CCFLAGS="-pthread ")
    51 
       
    52 # CCFLAGS=-g -fno-strict-aliasing
       
    53 
   137 
    54 # float: -fsingle-precision-constant
   138 # float: -fsingle-precision-constant
    55 # double: -DPYRIT_DOUBLE
   139 # double: -DPYRIT_DOUBLE
    56 (lib, pymodule) = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, exports='env')
   140 (lib, pymodule) = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, exports='env')
    57 
   141