|     28  |     28  | 
|     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 	BoolOption('simd', 'allow SSE intrinsics', True), | 
|     39 	('precision', 'floating point number precision (single/double)', "single"), |     40 	('precision', 'floating point number precision (single/double)', "single"), | 
|     40 	('flags', 'add additional compiler flags', ""), |     41 	('flags', 'add additional compiler flags', ""), | 
|         |     42 	BoolOption('force_flags', "use only flags specified by 'flags' option (do not autodetect arch/sse flags)", False), | 
|         |     43 	BoolOption('profile', "enable gcc's profiling support (-pg)", False), | 
|     41 ) |     44 ) | 
|     42 if env['PLATFORM'] == 'win32': |     45 if env['PLATFORM'] == 'win32': | 
|     43 	opt.AddOptions( |     46 	opt.AddOptions( | 
|     44 		('pythonpath', 'path to Python installation', |     47 		('pythonpath', 'path to Python installation', | 
|     45 			'C:\\Python%c%c' % (sys.version[0], sys.version[2])), |     48 			'C:\\Python%c%c' % (sys.version[0], sys.version[2])), | 
|    118 if cc == 'gcc': |    121 if cc == 'gcc': | 
|    119 	add_flags += cpuflags_gcc + ' -ffast-math ' |    122 	add_flags += cpuflags_gcc + ' -ffast-math ' | 
|    120 if cc == 'intelc': |    123 if cc == 'intelc': | 
|    121 	add_flags += cpuflags_intelc + ' ' |    124 	add_flags += cpuflags_intelc + ' ' | 
|    122  |    125  | 
|         |    126 if conf.env['force_flags']: | 
|         |    127 	add_flags = conf.env['flags'] + ' ' | 
|         |    128 else: | 
|         |    129 	add_flags += conf.env['flags'] + ' ' | 
|         |    130  | 
|    123 if conf.env['precision'] == 'double': |    131 if conf.env['precision'] == 'double': | 
|    124 	add_flags += '-DPYRIT_DOUBLE ' |    132 	add_flags += '-DPYRIT_DOUBLE ' | 
|    125 elif cc == 'gcc': |    133 elif cc == 'gcc': | 
|    126 	add_flags += '-fsingle-precision-constant ' |    134 	add_flags += '-fsingle-precision-constant ' | 
|    127  |    135  | 
|    128 add_flags += conf.env['flags'] |    136 if not conf.env['simd']: | 
|         |    137 	add_flags += '-DNO_SSE ' | 
|    129  |    138  | 
|    130 if cc == 'intelc': |    139 if cc == 'intelc': | 
|    131 	conf.env.Append(CCFLAGS="-O3 -w1 " + add_flags) |    140 	conf.env.Append(CCFLAGS="-O3 -w1 " + add_flags) | 
|    132 elif cc == 'gcc': |    141 elif cc == 'gcc': | 
|    133 	conf.env.Append(CCFLAGS="-O3 -Wall -pipe " + add_flags) |    142 	conf.env.Append(CCFLAGS="-O3 -Wall -pipe " + add_flags) | 
|    141  |    150  | 
|    142 if conf.CheckLibWithHeader('png', 'png.h', 'C'): |    151 if conf.CheckLibWithHeader('png', 'png.h', 'C'): | 
|    143 	conf.env.Append(CCFLAGS='-DHAVE_PNG') |    152 	conf.env.Append(CCFLAGS='-DHAVE_PNG') | 
|    144 	conf.env.Append(LIBS=['png']) |    153 	conf.env.Append(LIBS=['png']) | 
|    145  |    154  | 
|         |    155 if not conf.CheckCHeader('pthread.h'): | 
|         |    156 	print 'Error: Cannot build without pthread.' | 
|         |    157 	Exit(1) | 
|         |    158  | 
|    146 if conf.env['PLATFORM'] == 'win32': |    159 if conf.env['PLATFORM'] == 'win32': | 
|    147 	conf.env.Append(LIBS=["pthreadGC2"]) |    160 	conf.env.Append(LIBS=["pthreadGC2"]) | 
|    148 else: |    161 else: | 
|    149 	conf.env.Append(CCFLAGS="-pthread ") |    162 	conf.env.Append(CCFLAGS="-pthread ") | 
|         |    163  | 
|         |    164 if conf.env['profile'] and cc == 'gcc': | 
|         |    165 	conf.env.Append(CCFLAGS="-pg", LINKFLAGS="-pg") | 
|    150  |    166  | 
|    151 env = conf.Finish() |    167 env = conf.Finish() | 
|    152  |    168  | 
|    153  |    169  | 
|    154 ### build targets |    170 ### build targets | 
|    155  |    171  | 
|    156 (lib, pymodule) = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, exports='env') |    172 lib = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, exports={'env':env,'buildmodule':False}) | 
|         |    173 pymodule = SConscript('src/SConscript', build_dir='build/pymodule', duplicate=0, exports={'env':env,'buildmodule':True}) | 
|    157  |    174  | 
|    158 SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0, exports='env lib') |    175 SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0, exports='env lib') | 
|    159 SConscript('demos/SConscript', exports='pymodule') |    176 SConscript('demos/SConscript', exports='pymodule') | 
|    160 env.Alias('demos', ['cc-demos', 'python-demos']) |    177 env.Alias('demos', ['cc-demos', 'python-demos']) | 
|    161  |    178  | 
|    162 SConscript('tests/SConscript', build_dir='build/tests', duplicate=0, exports='env lib') |    179 SConscript('tests/SConscript', build_dir='build/tests', duplicate=0, exports='env lib') | 
|    163  |    180  | 
|    164 SConscript('models/SConscript') |    181 SConscript('models/SConscript') | 
|         |    182  | 
|         |    183 env.Alias('libs', ['static-lib', 'python-module']) | 
|    165  |    184  | 
|    166 env.Alias('docs', Command('docs/html', [], 'doxygen')) |    185 env.Alias('docs', Command('docs/html', [], 'doxygen')) | 
|    167 env.Clean('docs', ['docs/html']) |    186 env.Clean('docs', ['docs/html']) | 
|    168  |    187  | 
|    169 env.Alias('no-docs', ['libs', 'demos', 'models']) |    188 env.Alias('no-docs', ['libs', 'demos', 'models']) |