|     29 Options: |     29 Options: | 
|     30 """) |     30 """) | 
|     31  |     31  | 
|     32 import os, sys |     32 import os, sys | 
|     33 env = Environment(ENV = {'PATH' : os.environ['PATH']}) |     33 env = Environment(ENV = {'PATH' : os.environ['PATH']}) | 
|     34 Decider('MD5-timestamp') |     34 #Decider('MD5-timestamp') | 
|     35  |     35  | 
|     36 opt = Options(['.optioncache']) |     36 opt = Options(['.optioncache']) | 
|     37 opt.AddOptions( |     37 opt.AddOptions( | 
|     38 	BoolOption('intelc', 'use Intel C++ Compiler, if available', True), |     38 	BoolOption('intelc', 'use Intel C++ Compiler, if available', True), | 
|         |     39 	('precision', 'floating point number precision (single/double)', "single"), | 
|     39 	('flags', 'add additional compiler flags', ""), |     40 	('flags', 'add additional compiler flags', ""), | 
|     40 ) |     41 ) | 
|     41 if env['PLATFORM'] == 'win32': |     42 if env['PLATFORM'] == 'win32': | 
|     42 	opt.AddOptions( |     43 	opt.AddOptions( | 
|     43 		('pythonpath', 'path to Python installation', |     44 		('pythonpath', 'path to Python installation', | 
|     68 		if (os.system("cat /proc/cpuinfo | grep 'Core(TM)2 CPU' >/dev/null") == 0): |     69 		if (os.system("cat /proc/cpuinfo | grep 'Core(TM)2 CPU' >/dev/null") == 0): | 
|     69 			cpu = 'core2' |     70 			cpu = 'core2' | 
|     70 	context.Result(cpu) |     71 	context.Result(cpu) | 
|     71 	return True |     72 	return True | 
|     72  |     73  | 
|     73 intelc = Tool("intelc").exists(env) |     74 intelc = Tool("intelc").exists(env) == True | 
|     74 def CheckIntelC(context): |     75 def CheckIntelC(context): | 
|     75 	global intelc |     76 	global intelc | 
|     76 	context.Message('Checking for Intel C++ Compiler... ') |     77 	context.Message('Checking for Intel C++ Compiler... ') | 
|     77 	if intelc: |     78 	if intelc: | 
|     78 		testenv = Environment() |     79 		testenv = Environment() | 
|    108 	Tool("intelc").generate(env) |    109 	Tool("intelc").generate(env) | 
|    109 	cc = 'intelc' |    110 	cc = 'intelc' | 
|    110 elif gcc: |    111 elif gcc: | 
|    111 	cc = 'gcc' |    112 	cc = 'gcc' | 
|    112  |    113  | 
|    113 cpu_flags = '' |    114 add_flags = '' | 
|    114 if cc == 'gcc': |    115 if cc == 'gcc': | 
|    115 	cpu_flags += '-ffast-math ' |    116 	add_flags += '-ffast-math ' | 
|    116 if cpu == 'core2': |    117 if cpu == 'core2': | 
|    117 	if (cc == 'intelc' or gccversion[:3] == '4.3'): |    118 	if (cc == 'intelc' or gccversion[:3] == '4.3'): | 
|    118 		cpu_flags += '-march=core2 -mtune=core2 ' |    119 		add_flags += '-march=core2 -mtune=core2 ' | 
|    119 	if cc == 'intelc': |    120 	if cc == 'intelc': | 
|    120 		cpu_flags += '-xT ' |    121 		add_flags += '-xT ' | 
|    121 	if cc == 'gcc': |    122 	if cc == 'gcc': | 
|    122 		cpu_flags += '-msse3 -mfpmath=sse ' |    123 		add_flags += '-msse3 -mfpmath=sse ' | 
|    123 cpu_flags += env['flags'] |    124  | 
|         |    125 if env['precision'] == 'double': | 
|         |    126 	add_flags += '-DPYRIT_DOUBLE ' | 
|         |    127 elif cc == 'gcc': | 
|         |    128 	add_flags += '-fsingle-precision-constant ' | 
|         |    129  | 
|         |    130 add_flags += env['flags'] | 
|    124  |    131  | 
|    125 if cc == 'intelc': |    132 if cc == 'intelc': | 
|    126 	env.Append(CCFLAGS="-O3 -w1 " + cpu_flags) |    133 	env.Append(CCFLAGS="-O3 -w1 " + add_flags) | 
|    127 elif cc == 'gcc': |    134 elif cc == 'gcc': | 
|    128 	env.Append(CCFLAGS="-O3 -Wall -pipe " + cpu_flags) |    135 	env.Append(CCFLAGS="-O3 -Wall -pipe " + add_flags) | 
|    129 	# CCFLAGS= -fno-strict-aliasing |    136 	# CCFLAGS= -fno-strict-aliasing | 
|    130 else: |    137 else: | 
|    131 	print "No supported compiler found." |    138 	print "No supported compiler found." | 
|    132 	Exit(1) |    139 	Exit(1) | 
|    133  |    140  | 
|    134 print "Using compiler: " + cc |    141 print "Using compiler: " + cc | 
|    135 print "Additional flags: " + cpu_flags |    142 print "Additional flags: " + add_flags | 
|    136  |    143  | 
|    137 # pthread |    144 # pthread | 
|    138 if env['PLATFORM'] == 'win32': |    145 if env['PLATFORM'] == 'win32': | 
|    139 	env.Append(LIBS=["pthreadGC2"]) |    146 	env.Append(LIBS=["pthreadGC2"]) | 
|    140 else: |    147 else: | 
|    141 	env.Append(CCFLAGS="-pthread ") |    148 	env.Append(CCFLAGS="-pthread ") | 
|    142  |    149  | 
|    143 # float: -fsingle-precision-constant |         | 
|    144 # double: -DPYRIT_DOUBLE |         | 
|    145 (lib, pymodule) = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, exports='env') |    150 (lib, pymodule) = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, exports='env') | 
|    146  |    151  | 
|    147 SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0, exports='env lib') |    152 SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0, exports='env lib') | 
|    148 SConscript('demos/SConscript', exports='pymodule') |    153 SConscript('demos/SConscript', exports='pymodule') | 
|    149 env.Alias('demos', ['cc-demos', 'python-demos']) |    154 env.Alias('demos', ['cc-demos', 'python-demos']) |