1 #######################################################################
8 #######################################################################
9 # Configuration options
11 # For example, invoke scons as
13 # scons debug=1 dri=0 x86=1
15 # to set configuration variables. Or you can write those options to a file
27 # to get the full list of options. See scons manpage for more info.
30 # TODO: auto-detect defaults
31 opts = Options('config.py')
32 opts.Add(BoolOption('debug', 'build debug version', False))
33 opts.Add(BoolOption('dri', 'build dri drivers', False))
34 opts.Add(EnumOption('machine', 'use machine-specific assembly code', 'x86',
35 allowed_values=('generic', 'x86', 'x86-64')))
37 env = Environment(options = opts)
38 Help(opts.GenerateHelpText(env))
44 # platform will be typically 'posix' or 'win32'
45 platform = env['PLATFORM']
47 # platform will be one of 'linux', 'freebsd', 'win32', 'darwin', etc.
48 platform = sys.platform
49 if platform == 'linux2':
52 # replicate options values in local variables
55 machine = env['machine']
58 x86 = machine == 'x86'
59 gcc = platform == 'posix'
60 msvc = platform == 'win32'
72 #######################################################################
75 # TODO: put the compiler specific settings in seperate files
76 # TODO: auto-detect as much as possible
82 env.Append(CFLAGS = '-O0 -g3')
83 env.Append(CXXFLAGS = '-O0 -g3')
85 env.Append(CFLAGS = '-O3 -g3')
86 env.Append(CXXFLAGS = '-O3 -g3')
88 env.Append(CFLAGS = '-Wall -Wmissing-prototypes -std=c99 -ffast-math -pedantic')
89 env.Append(CXXFLAGS = '-Wall -pedantic')
92 env.Append(CFLAGS = '-fmessage-length=0')
93 env.Append(CXXFLAGS = '-fmessage-length=0')
96 env.Append(CPPDEFINES = [
98 ('_POSIX_C_SOURCE', '199309L'),
105 'HAVE_POSIX_MEMALIGN',
109 env.Append(CPPDEFINES = ['DEBUG'])
111 env.Append(CPPDEFINES = ['NDEBUG'])
115 env.Append(CPPPATH = [
121 '/usr/X11R6/include',
127 env.Append(CPPDEFINES = [
134 env.Append(CFLAGS = '-m32')
135 env.Append(CXXFLAGS = '-m32')
137 env.Append(LIBPATH = ['/usr/X11R6/lib'])
148 env.ParseConfig('pkg-config --cflags --libs libdrm')
149 env.Append(CPPDEFINES = [
150 ('USE_EXTERNAL_DXTN_LIB', '1'),
152 'GLX_DIRECT_RENDERING',
153 'GLX_INDIRECT_RENDERING',
169 #######################################################################
170 # Convenience Library Builder
171 # based on the stock StaticLibrary and SharedLibrary builders
173 def createConvenienceLibBuilder(env):
174 """This is a utility function that creates the ConvenienceLibrary
175 Builder in an Environment if it is not there already.
177 If it is already there, we return the existing one.
181 convenience_lib = env['BUILDERS']['ConvenienceLibrary']
183 action_list = [ Action("$ARCOM", "$ARCOMSTR") ]
184 if env.Detect('ranlib'):
185 ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR")
186 action_list.append(ranlib_action)
188 convenience_lib = Builder(action = action_list,
189 emitter = '$LIBEMITTER',
190 prefix = '$LIBPREFIX',
191 suffix = '$LIBSUFFIX',
192 src_suffix = '$SHOBJSUFFIX',
193 src_builder = 'SharedObject')
194 env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
195 env['BUILDERS']['Library'] = convenience_lib
197 return convenience_lib
199 createConvenienceLibBuilder(env)
202 #######################################################################
205 # Put build output in a separate dir
206 # TODO: make build_dir depend on platform and build type (check
207 # http://www.scons.org/wiki/AdvancedBuildExample for an example)
211 'src/mesa/SConscript',
212 build_dir = build_dir,
213 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html