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
)
37 default_drivers
= 'all'
38 if default_platform
in ('linux', 'freebsd', 'darwin'):
43 # TODO: auto-detect defaults
44 opts
= Options('config.py')
45 opts
.Add(BoolOption('debug', 'build debug version', False))
46 opts
.Add(EnumOption('machine', 'use machine-specific assembly code', 'x86',
47 allowed_values
=('generic', 'x86', 'x86-64')))
48 opts
.Add(EnumOption('platform', 'target platform', default_platform
,
49 allowed_values
=('linux', 'cell', 'winddk')))
50 opts
.Add(ListOption('statetrackers', 'state_trackers to build', 'all',
55 #opts.Add(ListOption('drivers', 'pipe drivers to build', 'all',
64 opts
.Add(BoolOption('llvm', 'use llvm', False))
65 opts
.Add(BoolOption('dri', 'build dri drivers', False))
66 opts
.Add(BoolOption('x11', 'build x11 driver', default_x11
))
71 Help(opts
.GenerateHelpText(env
))
76 # replicate options values in local variables
80 machine
= env
['machine']
81 platform
= env
['platform']
84 x86
= machine
== 'x86'
85 gcc
= platform
in ('linux', 'freebsd', 'darwin')
86 msvc
= platform
in ('win32', 'winddk')
99 #######################################################################
102 # TODO: put the compiler specific settings in separate files
103 # TODO: auto-detect as much as possible
106 if platform
== 'winddk':
108 escape
= env
['ESCAPE']
110 if 'BASEDIR' in os
.environ
:
111 WINDDK
= os
.environ
['BASEDIR']
113 WINDDK
= "C:\\WINDDK\\3790.1830"
114 # NOTE: We need this elaborate construct to get the absolute paths and
115 # forward slashes to msvc unharmed when cross compiling from posix platforms
116 env
.Append(CPPFLAGS
= [
117 escape('/I' + ntpath
.join(WINDDK
, 'inc\\ddk\\wxp')),
118 escape('/I' + ntpath
.join(WINDDK
, 'inc\\ddk\\wdm\\wxp')),
119 escape('/I' + ntpath
.join(WINDDK
, 'inc\\crt')),
121 env
.Append(CPPDEFINES
= [
125 env
.Append(CPPDEFINES
= ['DBG'])
131 env
.Append(CFLAGS
= '-O0 -g3')
132 env
.Append(CXXFLAGS
= '-O0 -g3')
134 env
.Append(CFLAGS
= '-O3 -g3')
135 env
.Append(CXXFLAGS
= '-O3 -g3')
137 env
.Append(CFLAGS
= '-Wall -Wmissing-prototypes -Wno-long-long -ffast-math -pedantic')
138 env
.Append(CXXFLAGS
= '-Wall -pedantic')
141 env
.Append(CFLAGS
= '-fmessage-length=0')
142 env
.Append(CXXFLAGS
= '-fmessage-length=0')
147 env
.Append(CPPDEFINES
= ['DEBUG'])
149 env
.Append(CPPDEFINES
= ['NDEBUG'])
153 env
.Append(CPPPATH
= [
155 '#/src/gallium/include',
156 '#/src/gallium/auxiliary',
157 '#/src/gallium/drivers',
163 env
.Append(CPPDEFINES
= [
170 env
.Append(CFLAGS
= '-m32')
171 env
.Append(CXXFLAGS
= '-m32')
175 if platform
in ('posix', 'linux', 'freebsd', 'darwin'):
176 env
.Append(CPPDEFINES
= [
178 ('_POSIX_C_SOURCE', '199309L'),
184 'HAVE_POSIX_MEMALIGN',
186 env
.Append(CPPPATH
= ['/usr/X11R6/include'])
187 env
.Append(LIBPATH
= ['/usr/X11R6/lib'])
198 env
.ParseConfig('pkg-config --cflags --libs libdrm')
199 env
.Append(CPPDEFINES
= [
200 ('USE_EXTERNAL_DXTN_LIB', '1'),
202 'GLX_DIRECT_RENDERING',
203 'GLX_INDIRECT_RENDERING',
208 # See also http://www.scons.org/wiki/UsingPkgConfig
209 env
.ParseConfig('llvm-config --cflags --ldflags --libs')
210 env
.Append(CPPDEFINES
= ['MESA_LLVM'])
211 env
.Append(CXXFLAGS
= ['-Wno-long-long'])
227 #######################################################################
228 # Convenience Library Builder
229 # based on the stock StaticLibrary and SharedLibrary builders
231 def createConvenienceLibBuilder(env
):
232 """This is a utility function that creates the ConvenienceLibrary
233 Builder in an Environment if it is not there already.
235 If it is already there, we return the existing one.
239 convenience_lib
= env
['BUILDERS']['ConvenienceLibrary']
241 action_list
= [ Action("$ARCOM", "$ARCOMSTR") ]
242 if env
.Detect('ranlib'):
243 ranlib_action
= Action("$RANLIBCOM", "$RANLIBCOMSTR")
244 action_list
.append(ranlib_action
)
246 convenience_lib
= Builder(action
= action_list
,
247 emitter
= '$LIBEMITTER',
248 prefix
= '$LIBPREFIX',
249 suffix
= '$LIBSUFFIX',
250 src_suffix
= '$SHOBJSUFFIX',
251 src_builder
= 'SharedObject')
252 env
['BUILDERS']['ConvenienceLibrary'] = convenience_lib
253 env
['BUILDERS']['Library'] = convenience_lib
255 return convenience_lib
257 createConvenienceLibBuilder(env
)
260 #######################################################################
263 # Put build output in a separate dir, which depends on the current configuration
264 # See also http://www.scons.org/wiki/AdvancedBuildExample
265 build_topdir
= 'build'
266 build_subdir
= platform
268 build_subdir
+= "-dri"
270 build_subdir
+= "-llvm"
272 build_subdir
+= "-x86"
274 build_subdir
+= "-debug"
275 build_dir
= os
.path
.join(build_topdir
, build_subdir
)
277 # TODO: Build several variants at the same time?
278 # http://www.scons.org/wiki/SimultaneousVariantBuilds
282 build_dir
= build_dir
,
283 duplicate
= 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html