scons: Always build the identity driver.
[mesa.git] / SConstruct
1 #######################################################################
2 # Top-level SConstruct
3 #
4 # For example, invoke scons as
5 #
6 # scons debug=1 dri=0 machine=x86
7 #
8 # to set configuration variables. Or you can write those options to a file
9 # named config.py:
10 #
11 # # config.py
12 # debug=1
13 # dri=0
14 # machine='x86'
15 #
16 # Invoke
17 #
18 # scons -h
19 #
20 # to get the full list of options. See scons manpage for more info.
21 #
22
23 import os
24 import os.path
25 import sys
26 import SCons.Util
27
28 import common
29
30 #######################################################################
31 # Configuration options
32
33 default_statetrackers = 'mesa'
34
35 if common.default_platform in ('linux', 'freebsd', 'darwin'):
36 default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe'
37 default_winsys = 'xlib'
38 elif common.default_platform in ('winddk',):
39 default_drivers = 'softpipe,svga,i915,i965,trace,identity'
40 default_winsys = 'all'
41 elif common.default_platform in ('embedded',):
42 default_drivers = 'softpipe,llvmpipe'
43 default_winsys = 'xlib'
44 else:
45 default_drivers = 'all'
46 default_winsys = 'all'
47
48 opts = Variables('config.py')
49 common.AddOptions(opts)
50 opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
51 ['mesa', 'python', 'xorg']))
52 opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
53 ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe']))
54 opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
55 ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon']))
56 opts.Add(ListVariable('targets', 'target drivers to build', 'all',
57 ['xlib']))
58
59 opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
60
61 env = Environment(
62 options = opts,
63 tools = ['gallium'],
64 toolpath = ['#scons'],
65 ENV = os.environ,
66 )
67
68 if os.environ.has_key('CC'):
69 env['CC'] = os.environ['CC']
70 if os.environ.has_key('CFLAGS'):
71 env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
72 if os.environ.has_key('CXX'):
73 env['CXX'] = os.environ['CXX']
74 if os.environ.has_key('CXXFLAGS'):
75 env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
76 if os.environ.has_key('LDFLAGS'):
77 env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
78
79 Help(opts.GenerateHelpText(env))
80
81 # replicate options values in local variables
82 debug = env['debug']
83 dri = env['dri']
84 machine = env['machine']
85 platform = env['platform']
86 drawllvm = 'llvmpipe' in env['drivers']
87
88 # LLVM support in the Draw module
89 if drawllvm:
90 env.Tool('llvm')
91 if not env.has_key('LLVM_VERSION'):
92 drawllvm = False
93
94 # derived options
95 x86 = machine == 'x86'
96 ppc = machine == 'ppc'
97 gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
98 msvc = platform in ('windows', 'winddk')
99
100 Export([
101 'debug',
102 'x86',
103 'ppc',
104 'dri',
105 'drawllvm',
106 'platform',
107 'gcc',
108 'msvc',
109 ])
110
111
112 #######################################################################
113 # Environment setup
114
115 # Always build trace and identity drivers
116 if 'trace' not in env['drivers']:
117 env['drivers'].append('trace')
118 if 'identity' not in env['drivers']:
119 env['drivers'].append('identity')
120
121 # Includes
122 env.Append(CPPPATH = [
123 '#/include',
124 '#/src/gallium/include',
125 '#/src/gallium/auxiliary',
126 '#/src/gallium/drivers',
127 ])
128
129 if env['msvc']:
130 env.Append(CPPPATH = ['#include/c99'])
131
132 # Embedded
133 if platform == 'embedded':
134 env.Append(CPPDEFINES = [
135 '_POSIX_SOURCE',
136 ('_POSIX_C_SOURCE', '199309L'),
137 '_SVID_SOURCE',
138 '_BSD_SOURCE',
139 '_GNU_SOURCE',
140
141 'PTHREADS',
142 ])
143 env.Append(LIBS = [
144 'm',
145 'pthread',
146 'dl',
147 ])
148
149 # Posix
150 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
151 env.Append(CPPDEFINES = [
152 '_POSIX_SOURCE',
153 ('_POSIX_C_SOURCE', '199309L'),
154 '_SVID_SOURCE',
155 '_BSD_SOURCE',
156 '_GNU_SOURCE',
157
158 'PTHREADS',
159 'HAVE_POSIX_MEMALIGN',
160 ])
161 if platform == 'darwin':
162 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
163 env.Append(CPPPATH = ['/usr/X11R6/include'])
164 env.Append(LIBPATH = ['/usr/X11R6/lib'])
165 env.Append(LIBS = [
166 'm',
167 'pthread',
168 'expat',
169 'dl',
170 ])
171
172 # DRI
173 if dri:
174 env.ParseConfig('pkg-config --cflags --libs libdrm')
175 env.Append(CPPDEFINES = [
176 ('USE_EXTERNAL_DXTN_LIB', '1'),
177 'IN_DRI_DRIVER',
178 'GLX_DIRECT_RENDERING',
179 'GLX_INDIRECT_RENDERING',
180 ])
181
182 # LLVM support in the Draw module
183 if drawllvm:
184 env.Append(CPPDEFINES = ['DRAW_LLVM'])
185
186 # libGL
187 if platform in ('linux', 'freebsd', 'darwin'):
188 env.Append(LIBS = [
189 'X11',
190 'Xext',
191 'Xxf86vm',
192 'Xdamage',
193 'Xfixes',
194 ])
195
196 # for debugging
197 #print env.Dump()
198
199 Export('env')
200
201
202 #######################################################################
203 # Invoke SConscripts
204
205 # TODO: Build several variants at the same time?
206 # http://www.scons.org/wiki/SimultaneousVariantBuilds
207
208 if env['platform'] != common.default_platform:
209 # GLSL code has to be built twice -- one for the host OS, another for the target OS...
210
211 host_env = Environment(
212 # options are ignored
213 # default tool is used
214 tools = ['default', 'custom'],
215 toolpath = ['#scons'],
216 ENV = os.environ,
217 )
218
219 host_env['platform'] = common.default_platform
220 host_env['machine'] = common.default_machine
221 host_env['debug'] = env['debug']
222
223 SConscript(
224 'src/glsl/SConscript',
225 variant_dir = os.path.join(env['build'], 'host'),
226 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
227 exports={'env':host_env},
228 )
229
230 SConscript(
231 'src/SConscript',
232 variant_dir = env['build'],
233 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
234 )
235
236 env.Default('src')
237
238 SConscript(
239 'progs/SConscript',
240 variant_dir = os.path.join('progs', env['build']),
241 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
242 )