1 #######################################################################
9 #######################################################################
10 # Configuration options
12 # For example, invoke scons as
14 # scons debug=1 dri=0 machine=x86
16 # to set configuration variables. Or you can write those options to a file
28 # to get the full list of options. See scons manpage for more info.
36 default_platform
= platform_map
.get(sys
.platform
, sys
.platform
)
38 if default_platform
in ('linux', 'freebsd', 'darwin'):
39 default_statetrackers
= 'mesa'
40 default_drivers
= 'softpipe,failover,i915simple,i965simple'
41 default_winsys
= 'xlib'
43 elif default_platform
in ('winddk',):
44 default_statetrackers
= 'none'
45 default_drivers
= 'softpipe,i915simple'
46 default_winsys
= 'none'
49 default_drivers
= 'all'
50 default_winsys
= 'all'
54 # TODO: auto-detect defaults
55 opts
= Options('config.py')
56 opts
.Add(BoolOption('debug', 'build debug version', False))
57 opts
.Add(EnumOption('machine', 'use machine-specific assembly code', 'x86',
58 allowed_values
=('generic', 'x86', 'x86-64')))
59 opts
.Add(EnumOption('platform', 'target platform', default_platform
,
60 allowed_values
=('linux', 'cell', 'winddk')))
61 opts
.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers
,
66 opts
.Add(ListOption('drivers', 'pipe drivers to build', default_drivers
,
75 opts
.Add(ListOption('winsys', 'winsys drivers to build', default_winsys
,
81 opts
.Add(BoolOption('llvm', 'use LLVM', 'no'))
82 opts
.Add(BoolOption('dri', 'build DRI drivers', default_dri
))
87 Help(opts
.GenerateHelpText(env
))
92 # replicate options values in local variables
96 machine
= env
['machine']
97 platform
= env
['platform']
100 x86
= machine
== 'x86'
101 gcc
= platform
in ('linux', 'freebsd', 'darwin')
102 msvc
= platform
in ('win32', 'winddk')
115 #######################################################################
118 # TODO: put the compiler specific settings in separate files
119 # TODO: auto-detect as much as possible
122 if platform
== 'winddk':
123 env
.Tool('winddk', ['.'])
125 env
.Append(CPPPATH
= [
135 env
.Append(CFLAGS
= '-O0 -g3')
136 env
.Append(CXXFLAGS
= '-O0 -g3')
138 env
.Append(CFLAGS
= '-O3 -g3')
139 env
.Append(CXXFLAGS
= '-O3 -g3')
141 env
.Append(CFLAGS
= '-Wall -Wmissing-prototypes -Wno-long-long -ffast-math -pedantic')
142 env
.Append(CXXFLAGS
= '-Wall -pedantic')
145 env
.Append(CFLAGS
= '-fmessage-length=0')
146 env
.Append(CXXFLAGS
= '-fmessage-length=0')
149 # Force msvc 7.1 (visual studio 2003) for windows builds.
150 # Eventually a way to override this would be nice.
151 # See also http://www.scons.org/wiki/MsvsMultipleVersions
152 env
["MSVS"] = {"VERSION": "7.1"}
153 env
["MSVS_VERSION"] = "7.1"
156 env
.Append(CFLAGS
= '/W3')
159 '/Od', # disable optimizations
160 '/Oy-', # disable frame pointer omission
164 '/Ox', # maximum optimizations
165 '/Os', # favor code space
167 env
.Append(CFLAGS
= cflags
)
168 env
.Append(CXXFLAGS
= cflags
)
169 # Put debugging information in a separate .pdb file for each object file as
170 # descrived in the scons manpage
171 env
['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
176 env
.Append(CPPDEFINES
= ['DEBUG'])
178 env
.Append(CPPDEFINES
= [
184 env
.Append(CPPDEFINES
= ['NDEBUG'])
188 env
.Append(CPPPATH
= [
190 '#/src/gallium/include',
191 '#/src/gallium/auxiliary',
192 '#/src/gallium/drivers',
198 env
.Append(CPPDEFINES
= [
205 env
.Append(CFLAGS
= '-m32')
206 env
.Append(CXXFLAGS
= '-m32')
210 if platform
in ('posix', 'linux', 'freebsd', 'darwin'):
211 env
.Append(CPPDEFINES
= [
213 ('_POSIX_C_SOURCE', '199309L'),
219 'HAVE_POSIX_MEMALIGN',
221 env
.Append(CPPPATH
= ['/usr/X11R6/include'])
222 env
.Append(LIBPATH
= ['/usr/X11R6/lib'])
233 env
.ParseConfig('pkg-config --cflags --libs libdrm')
234 env
.Append(CPPDEFINES
= [
235 ('USE_EXTERNAL_DXTN_LIB', '1'),
237 'GLX_DIRECT_RENDERING',
238 'GLX_INDIRECT_RENDERING',
243 # See also http://www.scons.org/wiki/UsingPkgConfig
244 env
.ParseConfig('llvm-config --cflags --ldflags --libs')
245 env
.Append(CPPDEFINES
= ['MESA_LLVM'])
246 env
.Append(CXXFLAGS
= ['-Wno-long-long'])
250 if platform
not in ('winddk',):
262 #######################################################################
263 # Convenience Library Builder
264 # based on the stock StaticLibrary and SharedLibrary builders
266 def createConvenienceLibBuilder(env
):
267 """This is a utility function that creates the ConvenienceLibrary
268 Builder in an Environment if it is not there already.
270 If it is already there, we return the existing one.
274 convenience_lib
= env
['BUILDERS']['ConvenienceLibrary']
276 action_list
= [ Action("$ARCOM", "$ARCOMSTR") ]
277 if env
.Detect('ranlib'):
278 ranlib_action
= Action("$RANLIBCOM", "$RANLIBCOMSTR")
279 action_list
.append(ranlib_action
)
281 convenience_lib
= Builder(action
= action_list
,
282 emitter
= '$LIBEMITTER',
283 prefix
= '$LIBPREFIX',
284 suffix
= '$LIBSUFFIX',
285 src_suffix
= '$SHOBJSUFFIX',
286 src_builder
= 'SharedObject')
287 env
['BUILDERS']['ConvenienceLibrary'] = convenience_lib
288 env
['BUILDERS']['Library'] = convenience_lib
290 return convenience_lib
292 createConvenienceLibBuilder(env
)
295 #######################################################################
298 # Put build output in a separate dir, which depends on the current configuration
299 # See also http://www.scons.org/wiki/AdvancedBuildExample
300 build_topdir
= 'build'
301 build_subdir
= platform
303 build_subdir
+= "-dri"
305 build_subdir
+= "-llvm"
307 build_subdir
+= "-x86"
309 build_subdir
+= "-debug"
310 build_dir
= os
.path
.join(build_topdir
, build_subdir
)
312 # TODO: Build several variants at the same time?
313 # http://www.scons.org/wiki/SimultaneousVariantBuilds
317 build_dir
= build_dir
,
318 duplicate
= 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html