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(EnumOption('machine', 'use machine-specific assembly code', 'x86',
36 allowed_values=('generic', 'x86', 'x86-64')))
41 Help(opts.GenerateHelpText(env))
47 # platform will be typically 'posix' or 'win32'
48 platform = env['PLATFORM']
50 # platform will be one of 'linux', 'freebsd', 'win32', 'darwin', etc.
51 platform = sys.platform
52 if platform == 'linux2':
55 # replicate options values in local variables
58 machine = env['machine']
61 x86 = machine == 'x86'
62 gcc = platform in ('posix', 'linux', 'freebsd', 'darwin')
63 msvc = platform == 'win32'
75 #######################################################################
78 # TODO: put the compiler specific settings in seperate files
79 # TODO: auto-detect as much as possible
85 env.Append(CFLAGS = '-O0 -g3')
86 env.Append(CXXFLAGS = '-O0 -g3')
88 env.Append(CFLAGS = '-O3 -g3')
89 env.Append(CXXFLAGS = '-O3 -g3')
91 env.Append(CFLAGS = '-Wall -Wmissing-prototypes -std=c99 -ffast-math -pedantic')
92 env.Append(CXXFLAGS = '-Wall -pedantic')
95 env.Append(CFLAGS = '-fmessage-length=0')
96 env.Append(CXXFLAGS = '-fmessage-length=0')
99 env.Append(CPPDEFINES = [
101 ('_POSIX_C_SOURCE', '199309L'),
108 'HAVE_POSIX_MEMALIGN',
112 env.Append(CPPDEFINES = ['DEBUG'])
114 env.Append(CPPDEFINES = ['NDEBUG'])
118 env.Append(CPPPATH = [
124 '/usr/X11R6/include',
130 env.Append(CPPDEFINES = [
137 env.Append(CFLAGS = '-m32')
138 env.Append(CXXFLAGS = '-m32')
140 env.Append(LIBPATH = ['/usr/X11R6/lib'])
151 env.ParseConfig('pkg-config --cflags --libs libdrm')
152 env.Append(CPPDEFINES = [
153 ('USE_EXTERNAL_DXTN_LIB', '1'),
155 'GLX_DIRECT_RENDERING',
156 'GLX_INDIRECT_RENDERING',
172 #######################################################################
173 # Convenience Library Builder
174 # based on the stock StaticLibrary and SharedLibrary builders
176 def createConvenienceLibBuilder(env):
177 """This is a utility function that creates the ConvenienceLibrary
178 Builder in an Environment if it is not there already.
180 If it is already there, we return the existing one.
184 convenience_lib = env['BUILDERS']['ConvenienceLibrary']
186 action_list = [ Action("$ARCOM", "$ARCOMSTR") ]
187 if env.Detect('ranlib'):
188 ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR")
189 action_list.append(ranlib_action)
191 convenience_lib = Builder(action = action_list,
192 emitter = '$LIBEMITTER',
193 prefix = '$LIBPREFIX',
194 suffix = '$LIBSUFFIX',
195 src_suffix = '$SHOBJSUFFIX',
196 src_builder = 'SharedObject')
197 env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
198 env['BUILDERS']['Library'] = convenience_lib
200 return convenience_lib
202 createConvenienceLibBuilder(env)
205 #######################################################################
208 # Put build output in a separate dir, which depends on the current configuration
209 # See also http://www.scons.org/wiki/AdvancedBuildExample
210 build_topdir = 'build'
211 build_subdir = platform
213 build_subdir += "-dri"
215 build_subdir += "-x86"
217 build_subdir += "-debug"
218 build_dir = os.path.join(build_topdir, build_subdir)
220 # TODO: Build several variants at the same time?
221 # http://www.scons.org/wiki/SimultaneousVariantBuilds
224 'src/mesa/SConscript',
225 build_dir = build_dir,
226 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html