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.
31 # TODO: auto-detect defaults
32 opts = Options('config.py')
33 opts.Add(BoolOption('debug', 'build debug version', False))
34 opts.Add(BoolOption('dri', 'build dri drivers', False))
35 opts.Add(BoolOption('llvm', 'use llvm', False))
36 opts.Add(EnumOption('machine', 'use machine-specific assembly code', 'x86',
37 allowed_values=('generic', 'x86', 'x86-64')))
42 Help(opts.GenerateHelpText(env))
48 # platform will be typically 'posix' or 'win32'
49 platform = env['PLATFORM']
51 # platform will be one of 'linux', 'freebsd', 'win32', 'darwin', etc.
52 platform = sys.platform
53 if platform == 'linux2':
56 # replicate options values in local variables
60 machine = env['machine']
63 x86 = machine == 'x86'
64 gcc = platform in ('posix', 'linux', 'freebsd', 'darwin')
65 msvc = platform == 'win32'
78 #######################################################################
81 # TODO: put the compiler specific settings in seperate files
82 # TODO: auto-detect as much as possible
88 env.Append(CFLAGS = '-O0 -g3')
89 env.Append(CXXFLAGS = '-O0 -g3')
91 env.Append(CFLAGS = '-O3 -g3')
92 env.Append(CXXFLAGS = '-O3 -g3')
94 env.Append(CFLAGS = '-Wall -Wmissing-prototypes -std=c99 -ffast-math -pedantic')
95 env.Append(CXXFLAGS = '-Wall -pedantic')
98 env.Append(CFLAGS = '-fmessage-length=0')
99 env.Append(CXXFLAGS = '-fmessage-length=0')
104 env.Append(CPPDEFINES = ['DEBUG'])
106 env.Append(CPPDEFINES = ['NDEBUG'])
110 env.Append(CPPPATH = [
114 '#/src/gallium/include',
115 '#/src/gallium/auxiliary',
116 '#/src/gallium/drivers',
122 env.Append(CPPDEFINES = [
129 env.Append(CFLAGS = '-m32')
130 env.Append(CXXFLAGS = '-m32')
134 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
135 env.Append(CPPDEFINES = [
137 ('_POSIX_C_SOURCE', '199309L'),
143 'HAVE_POSIX_MEMALIGN',
145 env.Append(CPPPATH = ['/usr/X11R6/include'])
146 env.Append(LIBPATH = ['/usr/X11R6/lib'])
157 env.ParseConfig('pkg-config --cflags --libs libdrm')
158 env.Append(CPPDEFINES = [
159 ('USE_EXTERNAL_DXTN_LIB', '1'),
161 'GLX_DIRECT_RENDERING',
162 'GLX_INDIRECT_RENDERING',
167 # See also http://www.scons.org/wiki/UsingPkgConfig
168 env.ParseConfig('llvm-config --cflags --ldflags --libs')
169 env.Append(CPPDEFINES = ['MESA_LLVM'])
170 env.Append(CXXFLAGS = ['-Wno-long-long'])
186 #######################################################################
187 # Convenience Library Builder
188 # based on the stock StaticLibrary and SharedLibrary builders
190 def createConvenienceLibBuilder(env):
191 """This is a utility function that creates the ConvenienceLibrary
192 Builder in an Environment if it is not there already.
194 If it is already there, we return the existing one.
198 convenience_lib = env['BUILDERS']['ConvenienceLibrary']
200 action_list = [ Action("$ARCOM", "$ARCOMSTR") ]
201 if env.Detect('ranlib'):
202 ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR")
203 action_list.append(ranlib_action)
205 convenience_lib = Builder(action = action_list,
206 emitter = '$LIBEMITTER',
207 prefix = '$LIBPREFIX',
208 suffix = '$LIBSUFFIX',
209 src_suffix = '$SHOBJSUFFIX',
210 src_builder = 'SharedObject')
211 env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
212 env['BUILDERS']['Library'] = convenience_lib
214 return convenience_lib
216 createConvenienceLibBuilder(env)
219 #######################################################################
222 # Put build output in a separate dir, which depends on the current configuration
223 # See also http://www.scons.org/wiki/AdvancedBuildExample
224 build_topdir = 'build'
225 build_subdir = platform
227 build_subdir += "-dri"
229 build_subdir += "-llvm"
231 build_subdir += "-x86"
233 build_subdir += "-debug"
234 build_dir = os.path.join(build_topdir, build_subdir)
236 # TODO: Build several variants at the same time?
237 # http://www.scons.org/wiki/SimultaneousVariantBuilds
241 build_dir = build_dir,
242 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html