82 elif env['PLATFORM'] == 'win32': |
82 elif env['PLATFORM'] == 'win32': |
83 platform = 'win32' |
83 platform = 'win32' |
84 context.Result(platform) |
84 context.Result(platform) |
85 return True |
85 return True |
86 |
86 |
|
87 intelcversion = '' |
87 def CheckIntelC(context): |
88 def CheckIntelC(context): |
88 global intelc, intelcversion |
89 global intelc, intelcversion |
89 context.Message('Checking for IntelC compiler... ') |
90 context.Message('Checking for IntelC compiler... ') |
90 intelc = Tool("intelc").exists(env) == True |
91 intelc = Tool("intelc").exists(env) == True |
91 if intelc: |
92 if intelc: |
92 testenv = Environment() |
93 testenv = Environment() |
93 Tool("intelc").generate(testenv) |
94 Tool("intelc").generate(testenv) |
94 intelcversion = str(testenv['INTEL_C_COMPILER_VERSION']/10.) |
95 intelcversion = str(testenv['INTEL_C_COMPILER_VERSION']/10.) |
95 context.Result(intelcversion) |
96 context.Result(intelcversion) |
96 else: |
97 else: |
97 intelcversion = '' |
|
98 context.Result(intelc) |
98 context.Result(intelc) |
99 return intelc |
99 return intelc |
100 |
100 |
101 def CheckGCC(context): |
101 def CheckGCC(context): |
102 global gcc, gccversion |
102 global gcc, gccversion |
183 else: |
183 else: |
184 add_flags += conf.env['flags'] + ' ' |
184 add_flags += conf.env['flags'] + ' ' |
185 |
185 |
186 if conf.env['precision'] == 'double': |
186 if conf.env['precision'] == 'double': |
187 conf.Define("PYRIT_DOUBLE") |
187 conf.Define("PYRIT_DOUBLE") |
188 elif cc == 'gcc': |
|
189 add_flags += '-fsingle-precision-constant ' |
|
190 |
188 |
191 if not conf.env['simd'] or conf.env['precision'] == 'double': |
189 if not conf.env['simd'] or conf.env['precision'] == 'double': |
192 conf.Define("NO_SIMD") |
190 conf.Define("NO_SIMD") |
193 |
191 |
194 if cc == 'intelc': |
192 if cc == 'intelc': |
195 conf.env.Append(CCFLAGS="-O3 -w1 " + add_flags) |
193 conf.env.Append(CCFLAGS="-O3 -w1 " + add_flags) |
196 elif cc == 'gcc': |
194 elif cc == 'gcc': |
197 conf.env.Append(CCFLAGS="-O3 -Wall -pipe " + add_flags) |
195 conf.env.Append(CCFLAGS="-O3 -Wall -pipe " + add_flags) |
|
196 # Other useful flags: |
|
197 # -Wunsafe-loop-optimizations -Wpointer-arith -Wcast-align -Wconversion |
|
198 # -Wmissing-noreturn -Winline -Wdisabled-optimization |
198 elif cc == 'msvc': |
199 elif cc == 'msvc': |
199 conf.env.Append(CCFLAGS="/Ox /Ob2 /GS- /Gy /GF /GR- /Zp16 /MD /EHsc /vmb " + add_flags) |
200 conf.env.Append(CCFLAGS="/Ox /Ob2 /GS- /Gy /GF /GR- /Zp16 /MD /EHsc /vmb " + add_flags) |
200 else: |
201 else: |
201 print "No supported compiler found." |
202 print "No supported compiler found." |
202 Exit(1) |
203 Exit(1) |
203 |
204 |
204 print "Using compiler: " + cc |
205 print "Using compiler: " + cc |
205 print "Additional flags: " + add_flags |
206 print "Additional flags: " + add_flags |
206 |
207 |
|
208 if conf.env['profile'] and cc == 'gcc': |
|
209 conf.env.Append(CCFLAGS="-pg", LINKFLAGS="-pg") |
|
210 |
|
211 |
|
212 # configure pthread |
207 pthread = True |
213 pthread = True |
208 if conf.env['PLATFORM'] == 'win32': |
214 if platform == 'win32': |
209 if cc == 'msvc': |
215 if cc == 'msvc': |
210 if not conf.CheckLib('pthreadVC2'): |
216 if not conf.CheckLib('pthreadVC2'): |
211 pthread = False |
217 pthread = False |
212 conf.env.Append(LIBS=["pthreadVC2"]) |
|
213 elif cc == 'gcc': |
218 elif cc == 'gcc': |
214 if not conf.CheckLib('pthreadGC2'): |
219 if not conf.CheckLib('pthreadGC2'): |
215 pthread = False |
220 pthread = False |
216 conf.env.Append(LIBS=["pthreadGC2"]) |
|
217 else: |
221 else: |
218 conf.env.Append(CCFLAGS="-pthread ") |
222 conf.env.Append(CCFLAGS="-pthread ") |
219 |
223 |
220 if not pthread: |
224 if not pthread: |
221 print 'Error: Cannot build without pthread.' |
225 print 'Error: Cannot build without pthread.' |
222 Exit(1) |
226 Exit(1) |
223 |
227 |
|
228 |
|
229 # configure libpng |
224 if conf.CheckLibWithHeader('png', 'png.h', 'C'): |
230 if conf.CheckLibWithHeader('png', 'png.h', 'C'): |
225 conf.Define('HAVE_PNG') |
231 conf.Define('HAVE_PNG') |
226 conf.env.Append(LIBS=['png']) |
232 elif conf.CheckLib('libpng'): |
227 elif conf.CheckLib('libpng13'): |
|
228 conf.Define('HAVE_PNG') |
233 conf.Define('HAVE_PNG') |
229 conf.env.Append(LIBS=['libpng13']) |
|
230 |
|
231 if conf.env['profile'] and cc == 'gcc': |
|
232 conf.env.Append(CCFLAGS="-pg", LINKFLAGS="-pg") |
|
233 |
234 |
234 env = conf.Finish() |
235 env = conf.Finish() |
|
236 |
|
237 |
|
238 # configure Python |
|
239 pyenv = env.Clone() |
|
240 have_python = True |
|
241 if platform == 'win32': |
|
242 pythonver = '%c%c' % (sys.version[0], sys.version[2]) |
|
243 pythonlib = 'python'+pythonver |
|
244 pythonpath = [env['pythonpath'], |
|
245 'C:\\Program Files\\Python'+pythonver] |
|
246 pyenv.Append(CPPPATH=[s+'\\include' for s in pythonpath]) |
|
247 pyenv.Append(LIBPATH=[s+'\\libs' for s in pythonpath]) |
|
248 pyenv.Replace(SHLIBSUFFIX='.pyd') |
|
249 conf = Configure(pyenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h) |
|
250 if not conf.CheckLib(pythonlib): |
|
251 have_python = False |
|
252 pyenv = conf.Finish() |
|
253 else: |
|
254 try: |
|
255 pyenv.ParseConfig('python-config --includes --libs') |
|
256 except: |
|
257 have_python = False |
|
258 |
|
259 if not have_python: |
|
260 print "Error: Python is required." |
|
261 Exit(1) |
235 |
262 |
236 # configure SDL |
263 # configure SDL |
237 sdlenv = env.Clone() |
264 sdlenv = env.Clone() |
238 if cc != 'msvc': |
265 if cc == 'msvc': |
|
266 sdlenv.Append(LIBS=['SDL', 'SDLmain']) |
|
267 sdlenv.Append(LINKFLAGS="/SUBSYSTEM:WINDOWS") |
|
268 else: |
239 try: |
269 try: |
240 sdlenv.ParseConfig('sh sdl-config --cflags') |
270 sdlenv.ParseConfig('sh sdl-config --cflags') |
241 sdlenv.ParseConfig('sh sdl-config --libs') |
271 sdlenv.ParseConfig('sh sdl-config --libs') |
242 except: |
272 except: |
243 pass |
273 pass |
244 else: |
274 |
245 sdlenv.Append(LIBS=['SDL', 'SDLmain']) |
275 def CheckSDL(context): |
246 |
276 global have_sdl |
247 conf = Configure(sdlenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h) |
277 context.Message('Checking for SDL... ') |
248 have_sdl = False |
278 if context.TryLink("#include <SDL.h>\n"+ |
249 if conf.CheckLib('SDL'): |
279 "int main(int argc,char **argv){return 0;}", '.cc'): |
250 have_sdl = True |
280 context.Result(1) |
251 else: |
281 return True |
252 print "SDL not found, some demos will not built." |
282 else: |
|
283 context.Result("no (some demos won't be built)") |
|
284 return False |
|
285 |
|
286 conf = Configure(sdlenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h, |
|
287 custom_tests = {'CheckSDL' : CheckSDL} ) |
|
288 have_sdl = conf.CheckSDL() |
253 sdlenv = conf.Finish() |
289 sdlenv = conf.Finish() |
254 |
290 |
255 if cc == 'msvc': |
|
256 sdlenv.Append(LINKFLAGS="/SUBSYSTEM:WINDOWS") |
|
257 |
291 |
258 ### build targets |
292 ### build targets |
259 |
293 |
260 Export('env sdlenv cc') |
294 Export('env pyenv sdlenv cc') |
261 lib = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, |
295 lib = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, |
262 exports={'buildmodule':False}) |
296 exports={'buildmodule':False}) |
263 pymodule = SConscript('src/SConscript', build_dir='build/pymodule', duplicate=0, |
297 pymodule = SConscript('src/SConscript', build_dir='build/pymodule', duplicate=0, |
264 exports={'buildmodule':True}) |
298 exports={'buildmodule':True}) |
265 |
299 |