1 #######################################################################
7 import platform as _platform
10 #######################################################################
11 # Configuration options
13 # For example, invoke scons as
15 # scons debug=1 dri=0 machine=x86
17 # to set configuration variables. Or you can write those options to a file
29 # to get the full list of options. See scons manpage for more info.
36 default_platform = sys.platform
37 default_platform = platform_map.get(default_platform, default_platform)
47 if 'PROCESSOR_ARCHITECTURE' in os.environ:
48 default_machine = os.environ['PROCESSOR_ARCHITECTURE']
50 default_machine = _platform.machine()
51 default_machine = machine_map.get(default_machine, 'generic')
53 if default_platform in ('linux', 'freebsd', 'darwin'):
54 default_statetrackers = 'mesa'
55 default_drivers = 'softpipe,failover,i915simple,i965simple'
56 default_winsys = 'xlib'
58 elif default_platform in ('winddk',):
59 default_statetrackers = 'none'
60 default_drivers = 'softpipe,i915simple'
61 default_winsys = 'none'
64 default_drivers = 'all'
65 default_winsys = 'all'
69 # TODO: auto-detect defaults
70 opts = Options('config.py')
71 opts.Add(BoolOption('debug', 'build debug version', 'no'))
72 opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
73 allowed_values=('generic', 'x86', 'x86_64')))
74 opts.Add(EnumOption('platform', 'target platform', default_platform,
75 allowed_values=('linux', 'cell', 'winddk')))
76 opts.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers,
81 opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers,
90 opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys,
96 opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
97 opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
102 Help(opts.GenerateHelpText(env))
107 # replicate options values in local variables
111 machine = env['machine']
112 platform = env['platform']
115 x86 = machine == 'x86'
116 gcc = platform in ('linux', 'freebsd', 'darwin')
117 msvc = platform in ('win32', 'winddk')
130 #######################################################################
133 # TODO: put the compiler specific settings in separate files
134 # TODO: auto-detect as much as possible
137 if platform == 'winddk':
138 env.Tool('winddk', ['.'])
140 env.Append(CPPPATH = [
150 env.Append(CFLAGS = '-O0 -g3')
151 env.Append(CXXFLAGS = '-O0 -g3')
153 env.Append(CFLAGS = '-O3 -g3')
154 env.Append(CXXFLAGS = '-O3 -g3')
156 env.Append(CFLAGS = '-Wall -Wmissing-prototypes -Wno-long-long -ffast-math -pedantic')
157 env.Append(CXXFLAGS = '-Wall -pedantic')
160 env.Append(CFLAGS = '-fmessage-length=0')
161 env.Append(CXXFLAGS = '-fmessage-length=0')
164 env.Append(CFLAGS = '/W3')
167 '/Od', # disable optimizations
168 '/Oy-', # disable frame pointer omission
172 '/Ox', # maximum optimizations
173 '/Os', # favor code space
175 env.Append(CFLAGS = cflags)
176 env.Append(CXXFLAGS = cflags)
177 # Put debugging information in a separate .pdb file for each object file as
178 # descrived in the scons manpage
179 env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
184 env.Append(CPPDEFINES = ['DEBUG'])
186 env.Append(CPPDEFINES = [
192 env.Append(CPPDEFINES = ['NDEBUG'])
196 env.Append(CPPPATH = [
198 '#/src/gallium/include',
199 '#/src/gallium/auxiliary',
200 '#/src/gallium/drivers',
206 env.Append(CPPDEFINES = [
213 env.Append(CFLAGS = '-m32')
214 env.Append(CXXFLAGS = '-m32')
218 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
219 env.Append(CPPDEFINES = [
221 ('_POSIX_C_SOURCE', '199309L'),
227 'HAVE_POSIX_MEMALIGN',
229 env.Append(CPPPATH = ['/usr/X11R6/include'])
230 env.Append(LIBPATH = ['/usr/X11R6/lib'])
241 env.ParseConfig('pkg-config --cflags --libs libdrm')
242 env.Append(CPPDEFINES = [
243 ('USE_EXTERNAL_DXTN_LIB', '1'),
245 'GLX_DIRECT_RENDERING',
246 'GLX_INDIRECT_RENDERING',
251 # See also http://www.scons.org/wiki/UsingPkgConfig
252 env.ParseConfig('llvm-config --cflags --ldflags --libs')
253 env.Append(CPPDEFINES = ['MESA_LLVM'])
254 env.Append(CXXFLAGS = ['-Wno-long-long'])
258 if platform not in ('winddk',):
270 #######################################################################
271 # Convenience Library Builder
272 # based on the stock StaticLibrary and SharedLibrary builders
274 def createConvenienceLibBuilder(env):
275 """This is a utility function that creates the ConvenienceLibrary
276 Builder in an Environment if it is not there already.
278 If it is already there, we return the existing one.
282 convenience_lib = env['BUILDERS']['ConvenienceLibrary']
284 action_list = [ Action("$ARCOM", "$ARCOMSTR") ]
285 if env.Detect('ranlib'):
286 ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR")
287 action_list.append(ranlib_action)
289 convenience_lib = Builder(action = action_list,
290 emitter = '$LIBEMITTER',
291 prefix = '$LIBPREFIX',
292 suffix = '$LIBSUFFIX',
293 src_suffix = '$SHOBJSUFFIX',
294 src_builder = 'SharedObject')
295 env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
296 env['BUILDERS']['Library'] = convenience_lib
298 return convenience_lib
300 createConvenienceLibBuilder(env)
303 #######################################################################
306 # Put build output in a separate dir, which depends on the current configuration
307 # See also http://www.scons.org/wiki/AdvancedBuildExample
308 build_topdir = 'build'
309 build_subdir = platform
311 build_subdir += "-dri"
313 build_subdir += "-llvm"
314 if env['machine'] != 'generic':
315 build_subdir += '-' + env['machine']
317 build_subdir += "-debug"
318 build_dir = os.path.join(build_topdir, build_subdir)
320 # TODO: Build several variants at the same time?
321 # http://www.scons.org/wiki/SimultaneousVariantBuilds
325 build_dir = build_dir,
326 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html