SConstruct
branchpyrit
changeset 95 ca7d4c665531
parent 94 4c8abb8977dc
child 99 f3abdaa2e8fb
equal deleted inserted replaced
94:4c8abb8977dc 95:ca7d4c665531
    48 opt.AddOptions(
    48 opt.AddOptions(
    49 	BoolOption('simd', 'allow SSE intrinsics', True),
    49 	BoolOption('simd', 'allow SSE intrinsics', True),
    50 	('precision', 'floating point number precision (single/double)', "single"),
    50 	('precision', 'floating point number precision (single/double)', "single"),
    51 	('flags', 'add additional compiler flags', ""),
    51 	('flags', 'add additional compiler flags', ""),
    52 	BoolOption('force_flags', "use only flags specified by 'flags' option (do not autodetect arch/sse flags)", False),
    52 	BoolOption('force_flags', "use only flags specified by 'flags' option (do not autodetect arch/sse flags)", False),
       
    53 	('ldflags', 'add additional linker flags', ""),
    53 	BoolOption('profile', "enable gcc's profiling support (-pg)", False),
    54 	BoolOption('profile', "enable gcc's profiling support (-pg)", False),
    54 )
    55 )
    55 if env['PLATFORM'] == 'win32':
    56 if env['PLATFORM'] == 'win32':
    56 	opt.AddOptions(
    57 	opt.AddOptions(
    57 		BoolOption('mingw', 'use Mingw and GCC compiler, if available', False),
    58 		BoolOption('mingw', 'use Mingw and GCC compiler, if available', False),
   147 	intelc = False
   148 	intelc = False
   148 else:
   149 else:
   149 	conf.CheckIntelC()
   150 	conf.CheckIntelC()
   150 	msvc=False
   151 	msvc=False
   151 
   152 
   152 if intelc or gcc:
       
   153 	conf.CheckCPUFlags()
       
   154 
       
   155 if intelc and (not gcc or conf.env['intelc']):
   153 if intelc and (not gcc or conf.env['intelc']):
   156 	Tool('intelc').generate(conf.env)
   154 	Tool('intelc').generate(conf.env)
   157 	cc = 'intelc'
   155 	cc = 'intelc'
   158 elif msvc and (not gcc or not conf.env['mingw']):
   156 elif msvc and (not gcc or not conf.env['mingw']):
   159 	Tool('default').generate(conf.env)
   157 	Tool('default').generate(conf.env)
   162 elif gcc:
   160 elif gcc:
   163 	cc = 'gcc'
   161 	cc = 'gcc'
   164 else:
   162 else:
   165 	cc = 'none'
   163 	cc = 'none'
   166 
   164 
       
   165 if cc == 'intelc' or cc == 'gcc':
       
   166 	conf.CheckCPUFlags()
       
   167 
   167 if platform == 'win32' and cc == 'gcc':
   168 if platform == 'win32' and cc == 'gcc':
   168 	conf.env.Append(LIBPATH=["C:/mingw/lib", "C:/msys/mingw/lib"])
   169 	conf.env.Append(LIBPATH=["C:/mingw/lib", "C:/msys/mingw/lib"])
   169 	conf.env.Append(CPPPATH=["C:/mingw/include", "C:/msys/mingw/include"])
   170 	conf.env.Append(CPPPATH=["C:/mingw/include", "C:/msys/mingw/include"])
   170 
   171 
   171 add_flags = ''
   172 add_flags = ''
   206 print "Additional flags: " + add_flags
   207 print "Additional flags: " + add_flags
   207 
   208 
   208 if conf.env['profile'] and cc == 'gcc':
   209 if conf.env['profile'] and cc == 'gcc':
   209 	conf.env.Append(CCFLAGS="-pg", LINKFLAGS="-pg")
   210 	conf.env.Append(CCFLAGS="-pg", LINKFLAGS="-pg")
   210 
   211 
       
   212 if conf.env['ldflags']:
       
   213 	conf.env.Append(LINKFLAGS=conf.env['ldflags'])
       
   214 
   211 
   215 
   212 # configure pthread
   216 # configure pthread
   213 pthread = True
   217 pthread = True
   214 if platform == 'win32':
   218 if platform == 'win32':
   215 	if cc == 'msvc':
   219 	if cc == 'msvc':
   225 	print 'Error: Cannot build without pthread.'
   229 	print 'Error: Cannot build without pthread.'
   226 	Exit(1)
   230 	Exit(1)
   227 
   231 
   228 
   232 
   229 # configure libpng
   233 # configure libpng
   230 if conf.CheckLibWithHeader('png', 'png.h', 'C'):
   234 if conf.CheckLibWithHeader('libpng', 'png.h', 'C'):
   231 	conf.Define('HAVE_PNG')
       
   232 elif conf.CheckLib('libpng'):
       
   233 	conf.Define('HAVE_PNG')
   235 	conf.Define('HAVE_PNG')
   234 
   236 
   235 env = conf.Finish()
   237 env = conf.Finish()
   236 
   238 
   237 
   239 
   289 sdlenv = conf.Finish()
   291 sdlenv = conf.Finish()
   290 
   292 
   291 
   293 
   292 ### build targets
   294 ### build targets
   293 
   295 
   294 Export('env pyenv sdlenv cc')
   296 Export('env pyenv sdlenv have_sdl cc')
   295 lib = SConscript('src/SConscript', build_dir='build/lib', duplicate=0,
   297 lib = SConscript('src/SConscript', build_dir='build/lib', duplicate=0,
   296 	exports={'buildmodule':False})
   298 	exports={'buildmodule':False})
   297 pymodule = SConscript('src/SConscript', build_dir='build/pymodule', duplicate=0,
   299 pymodule = SConscript('src/SConscript', build_dir='build/pymodule', duplicate=0,
   298 	exports={'buildmodule':True})
   300 	exports={'buildmodule':True})
   299 
   301 
   300 if have_sdl:
   302 SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0, exports='lib')
   301 	SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0,
       
   302 		exports='lib')
       
   303 
       
   304 SConscript('demos/SConscript', exports='pymodule')
   303 SConscript('demos/SConscript', exports='pymodule')
   305 SConscript('tests/SConscript', build_dir='build/tests', duplicate=0, exports='lib')
   304 SConscript('tests/SConscript', build_dir='build/tests', duplicate=0, exports='lib')
   306 SConscript('models/SConscript')
   305 SConscript('models/SConscript')
   307 
   306 
   308 env.Alias('demos', ['cc-demos', 'python-demos'])
   307 env.Alias('demos', ['cc-demos', 'python-demos'])