Merge branch 'mesa_7_7_branch'
[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
27 import common
28
29 #######################################################################
30 # Configuration options
31
32 default_statetrackers = 'mesa'
33
34 if common.default_platform in ('linux', 'freebsd', 'darwin'):
35 default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe'
36 default_winsys = 'xlib'
37 elif common.default_platform in ('winddk',):
38 default_drivers = 'softpipe,svga,i915,i965,trace,identity'
39 default_winsys = 'all'
40 else:
41 default_drivers = 'all'
42 default_winsys = 'all'
43
44 opts = Variables('config.py')
45 common.AddOptions(opts)
46 opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
47 ['mesa', 'python', 'xorg']))
48 opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
49 ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe']))
50 opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
51 ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon']))
52
53 opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
54
55 env = Environment(
56 options = opts,
57 tools = ['gallium'],
58 toolpath = ['#scons'],
59 ENV = os.environ,
60 )
61
62 Help(opts.GenerateHelpText(env))
63
64 # replicate options values in local variables
65 debug = env['debug']
66 dri = env['dri']
67 llvm = env['llvm']
68 machine = env['machine']
69 platform = env['platform']
70
71 # derived options
72 x86 = machine == 'x86'
73 ppc = machine == 'ppc'
74 gcc = platform in ('linux', 'freebsd', 'darwin')
75 msvc = platform in ('windows', 'winddk')
76
77 Export([
78 'debug',
79 'x86',
80 'ppc',
81 'dri',
82 'llvm',
83 'platform',
84 'gcc',
85 'msvc',
86 ])
87
88
89 #######################################################################
90 # Environment setup
91
92 # Includes
93 env.Append(CPPPATH = [
94 '#/include',
95 '#/src/gallium/include',
96 '#/src/gallium/auxiliary',
97 '#/src/gallium/drivers',
98 ])
99
100 if env['msvc']:
101 env.Append(CPPPATH = ['#include/c99'])
102
103
104 # Posix
105 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
106 env.Append(CPPDEFINES = [
107 '_POSIX_SOURCE',
108 ('_POSIX_C_SOURCE', '199309L'),
109 '_SVID_SOURCE',
110 '_BSD_SOURCE',
111 '_GNU_SOURCE',
112
113 'PTHREADS',
114 'HAVE_POSIX_MEMALIGN',
115 ])
116 if platform == 'darwin':
117 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
118 env.Append(CPPPATH = ['/usr/X11R6/include'])
119 env.Append(LIBPATH = ['/usr/X11R6/lib'])
120 env.Append(LIBS = [
121 'm',
122 'pthread',
123 'expat',
124 'dl',
125 ])
126
127
128 # DRI
129 if dri:
130 env.ParseConfig('pkg-config --cflags --libs libdrm')
131 env.Append(CPPDEFINES = [
132 ('USE_EXTERNAL_DXTN_LIB', '1'),
133 'IN_DRI_DRIVER',
134 'GLX_DIRECT_RENDERING',
135 'GLX_INDIRECT_RENDERING',
136 ])
137
138 # LLVM
139 if llvm:
140 # See also http://www.scons.org/wiki/UsingPkgConfig
141 env.ParseConfig('llvm-config --cflags --ldflags --libs backend bitreader engine instrumentation interpreter ipo')
142 env.Append(CPPDEFINES = ['MESA_LLVM'])
143 # Force C++ linkage
144 env['LINK'] = env['CXX']
145
146 # libGL
147 if platform in ('linux', 'freebsd', 'darwin'):
148 env.Append(LIBS = [
149 'X11',
150 'Xext',
151 'Xxf86vm',
152 'Xdamage',
153 'Xfixes',
154 ])
155
156 # for debugging
157 #print env.Dump()
158
159 Export('env')
160
161
162 #######################################################################
163 # Invoke SConscripts
164
165 # TODO: Build several variants at the same time?
166 # http://www.scons.org/wiki/SimultaneousVariantBuilds
167
168 if env['platform'] != common.default_platform:
169 # GLSL code has to be built twice -- one for the host OS, another for the target OS...
170
171 host_env = Environment(
172 # options are ignored
173 # default tool is used
174 tools = ['default', 'custom'],
175 toolpath = ['#scons'],
176 ENV = os.environ,
177 )
178
179 host_env['platform'] = common.default_platform
180 host_env['machine'] = common.default_machine
181 host_env['debug'] = env['debug']
182
183 SConscript(
184 'src/glsl/SConscript',
185 variant_dir = os.path.join(env['build'], 'host'),
186 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
187 exports={'env':host_env},
188 )
189
190 SConscript(
191 'src/SConscript',
192 variant_dir = env['build'],
193 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
194 )
195
196 SConscript(
197 'progs/SConscript',
198 variant_dir = os.path.join('progs', env['build']),
199 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
200 )