import os, string, sys, commands, fnmatch import SCons import SCons.Errors # # Set configuration options # opts = Options('quake3.conf') opts.Add('CC', 'C compiler') opts.Add('CCFLAGS', 'C compiler flags', Split('')) opts.Add('CPPPATH', 'Compiler include path', Split('')) opts.Add('LIBPATH', 'Linker library path', Split('')) opts.Add(EnumOption('warnings', 'Choose warnings level', '1', allowed_values=('0', '1', '2'))) opts.Add(EnumOption('debug', 'Set to >= 1 to build for debug', '0', allowed_values=('0', '1', '2', '3'))) opts.Add(EnumOption('optimize', 'Set to >= 1 to build with general optimizations', '2', allowed_values=('0', '1', '2', '3', '4', '5', '6'))) opts.Add(EnumOption('simd', 'Choose special CPU register optimizations', 'none', allowed_values=('none', 'sse', '3dnow'))) opts.Add(EnumOption('sound', 'Choose sound api', 'sdl', allowed_values=('oss', 'sdl'))) opts.Add(BoolOption('lua', 'Set to 1 to compile qagame with Lua scripting support', 0)) opts.Add(BoolOption('vm', 'Set to 1 to compile engine with virtual machine support', 1)) opts.Add(BoolOption('smp', 'Set to 1 to compile engine with symetric multiprocessor support', 0)) opts.Add(BoolOption('gamelibs', 'Set to 1 to compile .so game libraries (cgame, game and ui) when they are not needed (i.e. when "vm" is 1 and supported for current arch)', 0)) # # Initialize compiler environment base # if sys.platform == 'win32': env = Environment(ENV = {'PATH' : os.environ['PATH']}, options = opts, tools = ['mingw']) else: env = Environment(ENV = {'PATH' : os.environ['PATH']}, options = opts) # Some values need to be splitten env['CCFLAGS'] = Split(env['CCFLAGS']) env['CPPPATH'] = Split(env['CPPPATH']) env['LIBPATH'] = Split(env['LIBPATH']) # Supported VM architectures (Linux) env['vm_archs'] = ['x86', 'x86_64', 'ppc'] env['arch'] = commands.getoutput('uname -m') # Equivalent arch names in FreeBSD if fnmatch.fnmatch(sys.platform, 'freebsd*'): vm_archs_freebsd = {'i386' : 'x86', 'amd64' : 'x86_64', 'powerpc' : 'ppc'} if vm_archs_freebsd.has_key(env['arch']): env['arch'] = vm_archs_freebsd[env['arch']] # Build game libraries if VM is not supported in current arch if env['vm_archs'].count(env['arch']) == 0 or env['vm'] == 0: env['gamelibs'] = 1 Help(opts.GenerateHelpText(env)) # # Set common compiler flags # print 'compiling for architecture ', env['arch'] env.Append(CCFLAGS = Split('-pipe -fsigned-char')) if env['warnings'] == '1': env.Append(CCFLAGS = '-Wall') elif env['warnings'] == '2': env.Append(CCFLAGS = '-Wall -Werror') if env['debug'] != '0': env.Append(CCFLAGS = '-ggdb${debug} -DDEBUG=${debug}') else: env.Append(CCFLAGS = '-DNDEBUG') if env['optimize'] != '0': env.Append(CCFLAGS = Split('-O${optimize} -ffast-math -fno-strict-aliasing -funroll-loops')) if env['simd'] == 'sse': env.Append(CCFLAGS = '-DSIMD_SSE') elif env['simd'] == '3dnow': env.Append(CCFLAGS = '-DSIMD_3DNOW') conf = Configure(env) # The "dl" library is needed on Linux if fnmatch.fnmatch(sys.platform, 'linux*'): if not conf.CheckLib('dl', autoadd=0): print 'Did not find libdl.a, exiting!' Exit(1) env = conf.Finish() # Save options opts.Save('quake3.conf', env) Export('env') SConscript('SConscript_quake3', build_dir='build/quake3', duplicate=0) SConscript('SConscript_quake3-server', build_dir='build/quake3-server', duplicate=0) if env['gamelibs'] != 0: SConscript('SConscript_cgame', build_dir='build/cgame', duplicate=0) SConscript('SConscript_game', build_dir='build/game', duplicate=0) SConscript('SConscript_ui', build_dir='build/ui', duplicate=0)