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 platform = platform_map.get(sys.platform, sys.platform)
38 # TODO: auto-detect defaults
39 opts = Options('config.py')
40 opts.Add(BoolOption('debug', 'build debug version', False))
41 opts.Add(BoolOption('dri', 'build dri drivers', False))
42 opts.Add(BoolOption('llvm', 'use llvm', False))
43 opts.Add(EnumOption('machine', 'use machine-specific assembly code', 'x86',
44 allowed_values=('generic', 'x86', 'x86-64')))
45 opts.Add(EnumOption('platform', 'target platform', platform,
46 allowed_values=('linux', 'cell', 'winddk')))
51 Help(opts.GenerateHelpText(env))
56 # replicate options values in local variables
60 machine = env['machine']
61 platform = env['platform']
64 x86 = machine == 'x86'
65 gcc = platform in ('linux', 'freebsd', 'darwin')
66 msvc = platform in ('win32', 'winddk')
79 #######################################################################
82 # TODO: put the compiler specific settings in separate files
83 # TODO: auto-detect as much as possible
86 if platform == 'winddk':
88 escape = env['ESCAPE']
90 if 'BASEDIR' in os.environ:
91 WINDDK = os.environ['BASEDIR']
93 WINDDK = "C:\\WINDDK\\3790.1830"
94 # NOTE: We need this elaborate construct to get the absolute paths and
95 # forward slashes to msvc unharmed when cross compiling from posix platforms
96 env.Append(CPPFLAGS = [
97 escape('/I' + ntpath.join(WINDDK, 'inc\\ddk\\wxp')),
98 escape('/I' + ntpath.join(WINDDK, 'inc\\ddk\\wdm\\wxp')),
99 escape('/I' + ntpath.join(WINDDK, 'inc\\crt')),
101 env.Append(CPPDEFINES = [
105 env.Append(CPPDEFINES = ['DBG'])
111 env.Append(CFLAGS = '-O0 -g3')
112 env.Append(CXXFLAGS = '-O0 -g3')
114 env.Append(CFLAGS = '-O3 -g3')
115 env.Append(CXXFLAGS = '-O3 -g3')
117 env.Append(CFLAGS = '-Wall -Wmissing-prototypes -std=c99 -ffast-math -pedantic')
118 env.Append(CXXFLAGS = '-Wall -pedantic')
121 env.Append(CFLAGS = '-fmessage-length=0')
122 env.Append(CXXFLAGS = '-fmessage-length=0')
127 env.Append(CPPDEFINES = ['DEBUG'])
129 env.Append(CPPDEFINES = ['NDEBUG'])
133 env.Append(CPPPATH = [
135 '#/src/gallium/include',
136 '#/src/gallium/auxiliary',
137 '#/src/gallium/drivers',
143 env.Append(CPPDEFINES = [
150 env.Append(CFLAGS = '-m32')
151 env.Append(CXXFLAGS = '-m32')
155 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
156 env.Append(CPPDEFINES = [
158 ('_POSIX_C_SOURCE', '199309L'),
164 'HAVE_POSIX_MEMALIGN',
166 env.Append(CPPPATH = ['/usr/X11R6/include'])
167 env.Append(LIBPATH = ['/usr/X11R6/lib'])
178 env.ParseConfig('pkg-config --cflags --libs libdrm')
179 env.Append(CPPDEFINES = [
180 ('USE_EXTERNAL_DXTN_LIB', '1'),
182 'GLX_DIRECT_RENDERING',
183 'GLX_INDIRECT_RENDERING',
188 # See also http://www.scons.org/wiki/UsingPkgConfig
189 env.ParseConfig('llvm-config --cflags --ldflags --libs')
190 env.Append(CPPDEFINES = ['MESA_LLVM'])
191 env.Append(CXXFLAGS = ['-Wno-long-long'])
207 #######################################################################
208 # Convenience Library Builder
209 # based on the stock StaticLibrary and SharedLibrary builders
211 def createConvenienceLibBuilder(env):
212 """This is a utility function that creates the ConvenienceLibrary
213 Builder in an Environment if it is not there already.
215 If it is already there, we return the existing one.
219 convenience_lib = env['BUILDERS']['ConvenienceLibrary']
221 action_list = [ Action("$ARCOM", "$ARCOMSTR") ]
222 if env.Detect('ranlib'):
223 ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR")
224 action_list.append(ranlib_action)
226 convenience_lib = Builder(action = action_list,
227 emitter = '$LIBEMITTER',
228 prefix = '$LIBPREFIX',
229 suffix = '$LIBSUFFIX',
230 src_suffix = '$SHOBJSUFFIX',
231 src_builder = 'SharedObject')
232 env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
233 env['BUILDERS']['Library'] = convenience_lib
235 return convenience_lib
237 createConvenienceLibBuilder(env)
240 #######################################################################
243 # Put build output in a separate dir, which depends on the current configuration
244 # See also http://www.scons.org/wiki/AdvancedBuildExample
245 build_topdir = 'build'
246 build_subdir = platform
248 build_subdir += "-dri"
250 build_subdir += "-llvm"
252 build_subdir += "-x86"
254 build_subdir += "-debug"
255 build_dir = os.path.join(build_topdir, build_subdir)
257 # TODO: Build several variants at the same time?
258 # http://www.scons.org/wiki/SimultaneousVariantBuilds
262 build_dir = build_dir,
263 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html