diff -r 9af5c039b678 -r 96d65f841791 SConstruct --- a/SConstruct Mon May 05 15:31:14 2008 +0200 +++ b/SConstruct Tue May 06 09:39:58 2008 +0200 @@ -42,7 +42,7 @@ else: tools = ['default'] -env = Environment(tools = tools) +env = Environment(tools = tools, CPPPATH = ['.','#include']) opt = Options(['build/.optioncache']) opt.AddOptions( @@ -84,6 +84,7 @@ context.Result(platform) return True +intelcversion = '' def CheckIntelC(context): global intelc, intelcversion context.Message('Checking for IntelC compiler... ') @@ -94,7 +95,6 @@ intelcversion = str(testenv['INTEL_C_COMPILER_VERSION']/10.) context.Result(intelcversion) else: - intelcversion = '' context.Result(intelc) return intelc @@ -185,8 +185,6 @@ if conf.env['precision'] == 'double': conf.Define("PYRIT_DOUBLE") -elif cc == 'gcc': - add_flags += '-fsingle-precision-constant ' if not conf.env['simd'] or conf.env['precision'] == 'double': conf.Define("NO_SIMD") @@ -195,6 +193,9 @@ conf.env.Append(CCFLAGS="-O3 -w1 " + add_flags) elif cc == 'gcc': conf.env.Append(CCFLAGS="-O3 -Wall -pipe " + add_flags) + # Other useful flags: + # -Wunsafe-loop-optimizations -Wpointer-arith -Wcast-align -Wconversion + # -Wmissing-noreturn -Winline -Wdisabled-optimization elif cc == 'msvc': conf.env.Append(CCFLAGS="/Ox /Ob2 /GS- /Gy /GF /GR- /Zp16 /MD /EHsc /vmb " + add_flags) else: @@ -204,16 +205,19 @@ print "Using compiler: " + cc print "Additional flags: " + add_flags +if conf.env['profile'] and cc == 'gcc': + conf.env.Append(CCFLAGS="-pg", LINKFLAGS="-pg") + + +# configure pthread pthread = True -if conf.env['PLATFORM'] == 'win32': +if platform == 'win32': if cc == 'msvc': if not conf.CheckLib('pthreadVC2'): pthread = False - conf.env.Append(LIBS=["pthreadVC2"]) elif cc == 'gcc': if not conf.CheckLib('pthreadGC2'): pthread = False - conf.env.Append(LIBS=["pthreadGC2"]) else: conf.env.Append(CCFLAGS="-pthread ") @@ -221,43 +225,73 @@ print 'Error: Cannot build without pthread.' Exit(1) + +# configure libpng if conf.CheckLibWithHeader('png', 'png.h', 'C'): conf.Define('HAVE_PNG') - conf.env.Append(LIBS=['png']) -elif conf.CheckLib('libpng13'): +elif conf.CheckLib('libpng'): conf.Define('HAVE_PNG') - conf.env.Append(LIBS=['libpng13']) - -if conf.env['profile'] and cc == 'gcc': - conf.env.Append(CCFLAGS="-pg", LINKFLAGS="-pg") env = conf.Finish() + +# configure Python +pyenv = env.Clone() +have_python = True +if platform == 'win32': + pythonver = '%c%c' % (sys.version[0], sys.version[2]) + pythonlib = 'python'+pythonver + pythonpath = [env['pythonpath'], + 'C:\\Program Files\\Python'+pythonver] + pyenv.Append(CPPPATH=[s+'\\include' for s in pythonpath]) + pyenv.Append(LIBPATH=[s+'\\libs' for s in pythonpath]) + pyenv.Replace(SHLIBSUFFIX='.pyd') + conf = Configure(pyenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h) + if not conf.CheckLib(pythonlib): + have_python = False + pyenv = conf.Finish() +else: + try: + pyenv.ParseConfig('python-config --includes --libs') + except: + have_python = False + +if not have_python: + print "Error: Python is required." + Exit(1) + # configure SDL sdlenv = env.Clone() -if cc != 'msvc': +if cc == 'msvc': + sdlenv.Append(LIBS=['SDL', 'SDLmain']) + sdlenv.Append(LINKFLAGS="/SUBSYSTEM:WINDOWS") +else: try: sdlenv.ParseConfig('sh sdl-config --cflags') sdlenv.ParseConfig('sh sdl-config --libs') except: pass -else: - sdlenv.Append(LIBS=['SDL', 'SDLmain']) -conf = Configure(sdlenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h) -have_sdl = False -if conf.CheckLib('SDL'): - have_sdl = True -else: - print "SDL not found, some demos will not built." +def CheckSDL(context): + global have_sdl + context.Message('Checking for SDL... ') + if context.TryLink("#include \n"+ + "int main(int argc,char **argv){return 0;}", '.cc'): + context.Result(1) + return True + else: + context.Result("no (some demos won't be built)") + return False + +conf = Configure(sdlenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h, + custom_tests = {'CheckSDL' : CheckSDL} ) +have_sdl = conf.CheckSDL() sdlenv = conf.Finish() -if cc == 'msvc': - sdlenv.Append(LINKFLAGS="/SUBSYSTEM:WINDOWS") ### build targets -Export('env sdlenv cc') +Export('env pyenv sdlenv cc') lib = SConscript('src/SConscript', build_dir='build/lib', duplicate=0, exports={'buildmodule':False}) pymodule = SConscript('src/SConscript', build_dir='build/pymodule', duplicate=0,