OSDN Git Service

Merge remote branch 'origin/master' into lp-binning
[android-x86/external-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
57 opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
58
59 env = Environment(
60         options = opts,
61         tools = ['gallium'],
62         toolpath = ['#scons'],  
63         ENV = os.environ,
64 )
65
66 if os.environ.has_key('CC'):
67         env['CC'] = os.environ['CC']
68 if os.environ.has_key('CFLAGS'):
69         env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
70 if os.environ.has_key('CXX'):
71         env['CXX'] = os.environ['CXX']
72 if os.environ.has_key('CXXFLAGS'):
73         env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
74 if os.environ.has_key('LDFLAGS'):
75         env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
76
77 Help(opts.GenerateHelpText(env))
78
79 # replicate options values in local variables
80 debug = env['debug']
81 dri = env['dri']
82 llvm = env['llvm']
83 machine = env['machine']
84 platform = env['platform']
85
86 # derived options
87 x86 = machine == 'x86'
88 ppc = machine == 'ppc'
89 gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
90 msvc = platform in ('windows', 'winddk')
91
92 Export([
93         'debug', 
94         'x86', 
95         'ppc', 
96         'dri', 
97         'llvm',
98         'platform',
99         'gcc',
100         'msvc',
101 ])
102
103
104 #######################################################################
105 # Environment setup
106
107 # Includes
108 env.Append(CPPPATH = [
109         '#/include',
110         '#/src/gallium/include',
111         '#/src/gallium/auxiliary',
112         '#/src/gallium/drivers',
113 ])
114
115 if env['msvc']:
116     env.Append(CPPPATH = ['#include/c99'])
117
118 # Embedded
119 if platform == 'embedded':
120         env.Append(CPPDEFINES = [
121                 '_POSIX_SOURCE',
122                 ('_POSIX_C_SOURCE', '199309L'), 
123                 '_SVID_SOURCE',
124                 '_BSD_SOURCE', 
125                 '_GNU_SOURCE',
126                 
127                 'PTHREADS',
128         ])
129         env.Append(LIBS = [
130                 'm',
131                 'pthread',
132                 'dl',
133         ])
134
135 # Posix
136 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
137         env.Append(CPPDEFINES = [
138                 '_POSIX_SOURCE',
139                 ('_POSIX_C_SOURCE', '199309L'), 
140                 '_SVID_SOURCE',
141                 '_BSD_SOURCE', 
142                 '_GNU_SOURCE',
143                 
144                 'PTHREADS',
145                 'HAVE_POSIX_MEMALIGN',
146         ])
147         if platform == 'darwin':
148                 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
149         env.Append(CPPPATH = ['/usr/X11R6/include'])
150         env.Append(LIBPATH = ['/usr/X11R6/lib'])
151         env.Append(LIBS = [
152                 'm',
153                 'pthread',
154                 'expat',
155                 'dl',
156         ])
157
158 # DRI
159 if dri:
160         env.ParseConfig('pkg-config --cflags --libs libdrm')
161         env.Append(CPPDEFINES = [
162                 ('USE_EXTERNAL_DXTN_LIB', '1'), 
163                 'IN_DRI_DRIVER',
164                 'GLX_DIRECT_RENDERING',
165                 'GLX_INDIRECT_RENDERING',
166         ])
167
168 # LLVM
169 if llvm:
170         # See also http://www.scons.org/wiki/UsingPkgConfig
171         env.ParseConfig('llvm-config --cflags --ldflags --libs backend bitreader engine instrumentation interpreter ipo')
172         env.Append(CPPDEFINES = ['MESA_LLVM'])
173         # Force C++ linkage
174         env['LINK'] = env['CXX']
175
176 # libGL
177 if platform in ('linux', 'freebsd', 'darwin'):
178         env.Append(LIBS = [
179                 'X11',
180                 'Xext',
181                 'Xxf86vm',
182                 'Xdamage',
183                 'Xfixes',
184         ])
185
186 # for debugging
187 #print env.Dump()
188
189 Export('env')
190
191
192 #######################################################################
193 # Invoke SConscripts
194
195 # TODO: Build several variants at the same time?
196 # http://www.scons.org/wiki/SimultaneousVariantBuilds
197
198 if env['platform'] != common.default_platform:
199     # GLSL code has to be built twice -- one for the host OS, another for the target OS...
200
201     host_env = Environment(
202         # options are ignored
203         # default tool is used
204         tools = ['default', 'custom'],
205         toolpath = ['#scons'],  
206         ENV = os.environ,
207     )
208
209     host_env['platform'] = common.default_platform
210     host_env['machine'] = common.default_machine
211     host_env['debug'] = env['debug']
212
213     SConscript(
214         'src/glsl/SConscript',
215         variant_dir = os.path.join(env['build'], 'host'),
216         duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
217         exports={'env':host_env},
218     )
219
220 SConscript(
221         'src/SConscript',
222         variant_dir = env['build'],
223         duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
224 )
225
226 SConscript(
227         'progs/SConscript',
228         variant_dir = os.path.join('progs', env['build']),
229         duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
230 )