SConstruct revision a7ce6d399221fbb59d96d56c853de9781bbf2547
1####################################################################### 2# Top-level SConstruct 3# 4# For example, invoke scons as 5# 6# scons debug=1 dri=0 machine=x86 7# 8# to set configuration variables. Or you can write those options to a file 9# named config.py: 10# 11# # config.py 12# debug=1 13# dri=0 14# machine='x86' 15# 16# Invoke 17# 18# scons -h 19# 20# to get the full list of options. See scons manpage for more info. 21# 22 23import os 24import os.path 25import sys 26 27import common 28 29####################################################################### 30# Configuration options 31 32if common.default_platform in ('linux', 'freebsd', 'darwin'): 33 default_statetrackers = 'mesa' 34 default_drivers = 'softpipe,failover,i915simple,i965simple' 35 default_winsys = 'xlib' 36elif common.default_platform in ('winddk',): 37 default_statetrackers = 'none' 38 default_drivers = 'softpipe,i915simple' 39 default_winsys = 'none' 40else: 41 default_drivers = 'all' 42 default_winsys = 'all' 43 44opts = Options('config.py') 45common.AddOptions(opts) 46opts.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers, 47 ['mesa'])) 48opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers, 49 ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell'])) 50opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys, 51 ['xlib', 'intel'])) 52 53env = Environment( 54 options = opts, 55 ENV = os.environ) 56Help(opts.GenerateHelpText(env)) 57 58# replicate options values in local variables 59debug = env['debug'] 60dri = env['dri'] 61llvm = env['llvm'] 62machine = env['machine'] 63platform = env['platform'] 64 65# derived options 66x86 = machine == 'x86' 67gcc = platform in ('linux', 'freebsd', 'darwin') 68msvc = platform in ('windows', 'winddk') 69 70Export([ 71 'debug', 72 'x86', 73 'dri', 74 'llvm', 75 'platform', 76 'gcc', 77 'msvc', 78]) 79 80 81####################################################################### 82# Environment setup 83# 84# TODO: put the compiler specific settings in separate files 85# TODO: auto-detect as much as possible 86 87if platform == 'winddk': 88 env.Tool('winddk', ['.']) 89 90 env.Append(CPPPATH = [ 91 env['SDK_INC_PATH'], 92 env['DDK_INC_PATH'], 93 env['WDM_INC_PATH'], 94 env['CRT_INC_PATH'], 95 ]) 96 97common.generate(env) 98 99 100# Includes 101env.Append(CPPPATH = [ 102 '#/include', 103 '#/src/gallium/include', 104 '#/src/gallium/auxiliary', 105 '#/src/gallium/drivers', 106]) 107 108 109# x86 assembly 110if x86: 111 env.Append(CPPDEFINES = [ 112 'USE_X86_ASM', 113 'USE_MMX_ASM', 114 'USE_3DNOW_ASM', 115 'USE_SSE_ASM', 116 ]) 117 if gcc: 118 env.Append(CFLAGS = '-m32') 119 env.Append(CXXFLAGS = '-m32') 120 121 122# Posix 123if platform in ('posix', 'linux', 'freebsd', 'darwin'): 124 env.Append(CPPDEFINES = [ 125 '_POSIX_SOURCE', 126 ('_POSIX_C_SOURCE', '199309L'), 127 '_SVID_SOURCE', 128 '_BSD_SOURCE', 129 '_GNU_SOURCE', 130 131 'PTHREADS', 132 'HAVE_POSIX_MEMALIGN', 133 ]) 134 env.Append(CPPPATH = ['/usr/X11R6/include']) 135 env.Append(LIBPATH = ['/usr/X11R6/lib']) 136 env.Append(LIBS = [ 137 'm', 138 'pthread', 139 'expat', 140 'dl', 141 ]) 142 143 144# DRI 145if dri: 146 env.ParseConfig('pkg-config --cflags --libs libdrm') 147 env.Append(CPPDEFINES = [ 148 ('USE_EXTERNAL_DXTN_LIB', '1'), 149 'IN_DRI_DRIVER', 150 'GLX_DIRECT_RENDERING', 151 'GLX_INDIRECT_RENDERING', 152 ]) 153 154# LLVM 155if llvm: 156 # See also http://www.scons.org/wiki/UsingPkgConfig 157 env.ParseConfig('llvm-config --cflags --ldflags --libs') 158 env.Append(CPPDEFINES = ['MESA_LLVM']) 159 # Force C++ linkage 160 env['LINK'] = env['CXX'] 161 162# libGL 163if platform in ('linux', 'freebsd', 'darwin'): 164 env.Append(LIBS = [ 165 'X11', 166 'Xext', 167 'Xxf86vm', 168 'Xdamage', 169 'Xfixes', 170 ]) 171 172# for debugging 173#print env.Dump() 174 175Export('env') 176 177 178####################################################################### 179# Invoke SConscripts 180 181# TODO: Build several variants at the same time? 182# http://www.scons.org/wiki/SimultaneousVariantBuilds 183 184SConscript( 185 'src/SConscript', 186 build_dir = common.make_build_dir(env), 187 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html 188) 189