OSDN Git Service

scons: Use libdrm options only where needed.
[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', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib']))
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 machine = env['machine']
83 platform = env['platform']
84 drawllvm = 'llvmpipe' in env['drivers']
85
86 # LLVM support in the Draw module
87 if drawllvm:
88         env.Tool('llvm')
89         if not env.has_key('LLVM_VERSION'):
90            drawllvm = False
91 if drawllvm:
92         env.Append(CFLAGS = ['-DDRAW_LLVM=1'])
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         '#/src/gallium/winsys',
128 ])
129
130 if env['msvc']:
131     env.Append(CPPPATH = ['#include/c99'])
132
133 # Embedded
134 if platform == 'embedded':
135         env.Append(CPPDEFINES = [
136                 '_POSIX_SOURCE',
137                 ('_POSIX_C_SOURCE', '199309L'), 
138                 '_SVID_SOURCE',
139                 '_BSD_SOURCE', 
140                 '_GNU_SOURCE',
141                 
142                 'PTHREADS',
143         ])
144         env.Append(LIBS = [
145                 'm',
146                 'pthread',
147                 'dl',
148         ])
149
150 # Posix
151 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
152         env.Append(CPPDEFINES = [
153                 '_POSIX_SOURCE',
154                 ('_POSIX_C_SOURCE', '199309L'), 
155                 '_SVID_SOURCE',
156                 '_BSD_SOURCE', 
157                 '_GNU_SOURCE',
158                 
159                 'PTHREADS',
160                 'HAVE_POSIX_MEMALIGN',
161         ])
162         if platform == 'darwin':
163                 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
164         env.Append(LIBS = [
165                 'm',
166                 'pthread',
167                 'dl',
168         ])
169
170 # LLVM support in the Draw module
171 if drawllvm:
172     env.Append(CPPDEFINES = ['DRAW_LLVM'])
173
174 # for debugging
175 #print env.Dump()
176
177 Export('env')
178
179
180 #######################################################################
181 # Invoke SConscripts
182
183 # TODO: Build several variants at the same time?
184 # http://www.scons.org/wiki/SimultaneousVariantBuilds
185
186 if env['platform'] != common.default_platform:
187     # GLSL code has to be built twice -- one for the host OS, another for the target OS...
188
189     host_env = Environment(
190         # options are ignored
191         # default tool is used
192         tools = ['default', 'custom'],
193         toolpath = ['#scons'],  
194         ENV = os.environ,
195     )
196
197     host_env['platform'] = common.default_platform
198     host_env['machine'] = common.default_machine
199     host_env['debug'] = env['debug']
200
201     SConscript(
202         'src/glsl/SConscript',
203         variant_dir = os.path.join(env['build'], 'host'),
204         duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
205         exports={'env':host_env},
206     )
207
208 SConscript(
209         'src/SConscript',
210         variant_dir = env['build'],
211         duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
212 )
213
214 env.Default('src')
215
216 SConscript(
217     'progs/SConscript',
218     variant_dir = os.path.join('progs', env['build']),
219     duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
220 )