blob: 76ada41f55c28ba29376bcfaf80ec1924409fd43 [file] [log] [blame]
José Fonsecac42e6252008-01-31 13:14:35 +09001#######################################################################
2# Top-level SConstruct
José Fonsecac42e6252008-01-31 13:14:35 +09003#
4# For example, invoke scons as
5#
José Fonseca81b6a802008-02-06 14:36:50 +09006# scons debug=1 dri=0 machine=x86
José Fonsecac42e6252008-01-31 13:14:35 +09007#
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
José Fonseca81b6a802008-02-06 14:36:50 +090014# machine='x86'
José Fonsecac42e6252008-01-31 13:14:35 +090015#
16# Invoke
17#
18# scons -h
19#
20# to get the full list of options. See scons manpage for more info.
21#
22
José Fonseca94090432008-02-27 17:36:28 +090023import os
24import os.path
25import sys
Alan Hourihane550fc192010-01-26 19:57:34 +000026import SCons.Util
José Fonsecad710a7c2008-02-19 18:53:16 +090027
José Fonseca94090432008-02-27 17:36:28 +090028import common
José Fonseca58a3d7d2008-02-23 19:49:08 +090029
José Fonseca94090432008-02-27 17:36:28 +090030#######################################################################
31# Configuration options
32
José Fonseca6410e942008-07-13 23:36:59 +090033default_statetrackers = 'mesa'
Keith Whitwell39087f62010-05-14 10:55:07 +010034default_targets = 'none'
José Fonseca6410e942008-07-13 23:36:59 +090035
José Fonseca94090432008-02-27 17:36:28 +090036if common.default_platform in ('linux', 'freebsd', 'darwin'):
Jakob Bornecrantz9f7f7112010-05-12 21:11:39 +010037 default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe'
José Fonseca58a3d7d2008-02-23 19:49:08 +090038 default_winsys = 'xlib'
José Fonseca94090432008-02-27 17:36:28 +090039elif common.default_platform in ('winddk',):
Jakob Bornecrantz9f7f7112010-05-12 21:11:39 +010040 default_drivers = 'softpipe,svga,i915,i965,trace,identity'
José Fonseca5a67df62008-06-03 00:04:19 +090041 default_winsys = 'all'
Alan Hourihanedea98eb2010-01-26 20:58:11 +000042elif common.default_platform in ('embedded',):
43 default_drivers = 'softpipe,llvmpipe'
44 default_winsys = 'xlib'
José Fonseca26c57d12008-02-23 00:46:40 +090045else:
José Fonseca58a3d7d2008-02-23 19:49:08 +090046 default_drivers = 'all'
47 default_winsys = 'all'
José Fonsecae70a4312008-02-24 16:43:07 +090048
José Fonsecae9fb90a2009-05-01 16:12:17 +010049opts = Variables('config.py')
José Fonseca13174c12008-03-03 18:52:37 +010050common.AddOptions(opts)
José Fonsecae9fb90a2009-05-01 16:12:17 +010051opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
Chia-I Wu1e6c10f2010-05-31 11:47:58 +080052 ['mesa', 'python', 'xorg', 'egl']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010053opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
Jakob Bornecrantzaeee5262010-05-13 20:29:18 +010054 ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'r600', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010055opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
Jakob Bornecrantzaeee5262010-05-13 20:29:18 +010056 ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'r600', 'graw-xlib']))
José Fonsecac42e6252008-01-31 13:14:35 +090057
Keith Whitwell39087f62010-05-14 10:55:07 +010058opts.Add(ListVariable('targets', 'driver targets to build', default_targets,
59 ['dri-i915',
60 'dri-i965',
61 'dri-nouveau',
62 'dri-radeong',
63 'dri-swrast',
64 'dri-vmwgfx',
65 'egl-i915',
66 'egl-i965',
67 'egl-nouveau',
68 'egl-radeon',
69 'egl-swrast',
70 'egl-vmwgfx',
71 'graw-xlib',
72 'libgl-gdi',
73 'libgl-xlib',
74 'xorg-i915',
75 'xorg-i965',
76 'xorg-nouveau',
77 'xorg-radeon',
78 'xorg-vmwgfx']))
79
José Fonsecae9fb90a2009-05-01 16:12:17 +010080opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
Jonathan White3c819922008-08-29 11:30:32 -060081
José Fonseca81b6a802008-02-06 14:36:50 +090082env = Environment(
José Fonsecab04aa712008-06-06 14:48:57 +090083 options = opts,
84 tools = ['gallium'],
José Fonseca2c4349a2008-07-15 07:56:42 +090085 toolpath = ['#scons'],
José Fonsecab04aa712008-06-06 14:48:57 +090086 ENV = os.environ,
87)
88
Alan Hourihane6544be62010-01-26 19:14:16 +000089if os.environ.has_key('CC'):
90 env['CC'] = os.environ['CC']
91if os.environ.has_key('CFLAGS'):
92 env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
93if os.environ.has_key('CXX'):
94 env['CXX'] = os.environ['CXX']
95if os.environ.has_key('CXXFLAGS'):
96 env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
97if os.environ.has_key('LDFLAGS'):
98 env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
99
José Fonsecac42e6252008-01-31 13:14:35 +0900100Help(opts.GenerateHelpText(env))
101
José Fonsecac42e6252008-01-31 13:14:35 +0900102# replicate options values in local variables
103debug = env['debug']
104dri = env['dri']
105machine = env['machine']
José Fonsecad710a7c2008-02-19 18:53:16 +0900106platform = env['platform']
José Fonsecac42e6252008-01-31 13:14:35 +0900107
108# derived options
109x86 = machine == 'x86'
Michel Dänzer6b69e3c2008-10-23 10:28:48 +0200110ppc = machine == 'ppc'
Alan Hourihanedea98eb2010-01-26 20:58:11 +0000111gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
José Fonseca35460fc2008-04-25 18:16:25 +0900112msvc = platform in ('windows', 'winddk')
José Fonsecac42e6252008-01-31 13:14:35 +0900113
114Export([
115 'debug',
116 'x86',
Michel Dänzer6b69e3c2008-10-23 10:28:48 +0200117 'ppc',
José Fonsecac42e6252008-01-31 13:14:35 +0900118 'dri',
119 'platform',
120 'gcc',
121 'msvc',
122])
123
124
125#######################################################################
126# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +0900127
Jakob Bornecrantz2c3fb4e2010-05-04 12:06:37 +0100128# Always build trace, rbug, identity, softpipe, and llvmpipe (where possible)
José Fonsecadb2e1512010-02-25 17:02:52 +0000129if 'trace' not in env['drivers']:
130 env['drivers'].append('trace')
Jakob Bornecrantz2c3fb4e2010-05-04 12:06:37 +0100131if 'rbug' not in env['drivers']:
132 env['drivers'].append('rbug')
José Fonseca78d8e6c2010-03-09 17:08:16 +0000133if 'identity' not in env['drivers']:
134 env['drivers'].append('identity')
José Fonseca47a89e92010-04-10 03:01:30 +0100135if 'softpipe' not in env['drivers']:
136 env['drivers'].append('softpipe')
137if env['llvm'] and 'llvmpipe' not in env['drivers']:
138 env['drivers'].append('llvmpipe')
Joakim Sindholtfb08e032010-06-05 16:53:38 +0200139if 'sw' not in env['drivers']:
140 env['drivers'].append('sw')
José Fonsecadb2e1512010-02-25 17:02:52 +0000141
José Fonsecac42e6252008-01-31 13:14:35 +0900142# Includes
Vinson Lee5fd97572010-04-26 01:08:34 -0700143env.Prepend(CPPPATH = [
José Fonsecac42e6252008-01-31 13:14:35 +0900144 '#/include',
Vinson Lee5fd97572010-04-26 01:08:34 -0700145])
146env.Append(CPPPATH = [
José Fonseca33ceb672008-02-18 10:52:44 +0000147 '#/src/gallium/include',
148 '#/src/gallium/auxiliary',
149 '#/src/gallium/drivers',
José Fonseca601bfb52010-03-10 10:34:29 +0000150 '#/src/gallium/winsys',
José Fonsecac42e6252008-01-31 13:14:35 +0900151])
152
José Fonsecadc6bcc92010-01-10 10:36:35 +0000153if env['msvc']:
154 env.Append(CPPPATH = ['#include/c99'])
155
Alan Hourihane32e60432010-01-28 17:26:05 +0000156# Embedded
157if platform == 'embedded':
José Fonseca00137962008-02-07 19:59:17 +0900158 env.Append(CPPDEFINES = [
159 '_POSIX_SOURCE',
160 ('_POSIX_C_SOURCE', '199309L'),
161 '_SVID_SOURCE',
162 '_BSD_SOURCE',
163 '_GNU_SOURCE',
164
165 'PTHREADS',
José Fonseca00137962008-02-07 19:59:17 +0900166 ])
Alan Hourihane32e60432010-01-28 17:26:05 +0000167 env.Append(LIBS = [
168 'm',
169 'pthread',
170 'dl',
171 ])
172
173# Posix
174if platform in ('posix', 'linux', 'freebsd', 'darwin'):
175 env.Append(CPPDEFINES = [
176 '_POSIX_SOURCE',
177 ('_POSIX_C_SOURCE', '199309L'),
178 '_SVID_SOURCE',
179 '_BSD_SOURCE',
180 '_GNU_SOURCE',
Alan Hourihane32e60432010-01-28 17:26:05 +0000181 'PTHREADS',
182 'HAVE_POSIX_MEMALIGN',
183 ])
Jakob Bornecrantz2ebe0272010-05-12 22:48:32 +0100184 if gcc:
185 env.Append(CFLAGS = ['-fvisibility=hidden'])
Vinson Leed57ba162010-01-23 21:05:58 -0800186 if platform == 'darwin':
187 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
José Fonseca00137962008-02-07 19:59:17 +0900188 env.Append(LIBS = [
189 'm',
190 'pthread',
José Fonseca00137962008-02-07 19:59:17 +0900191 'dl',
192 ])
José Fonsecac42e6252008-01-31 13:14:35 +0900193
José Fonseca4f17bd22008-03-12 13:34:30 +0000194# for debugging
195#print env.Dump()
196
José Fonsecac42e6252008-01-31 13:14:35 +0900197Export('env')
198
199
200#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900201# Invoke SConscripts
202
José Fonsecaf4192cb42008-01-31 14:21:49 +0900203# TODO: Build several variants at the same time?
204# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900205
José Fonseca491f3842009-12-10 16:29:04 +0000206if env['platform'] != common.default_platform:
207 # GLSL code has to be built twice -- one for the host OS, another for the target OS...
208
209 host_env = Environment(
210 # options are ignored
211 # default tool is used
José Fonseca97e2c5a2009-12-31 17:58:56 +0000212 tools = ['default', 'custom'],
José Fonseca491f3842009-12-10 16:29:04 +0000213 toolpath = ['#scons'],
214 ENV = os.environ,
215 )
216
217 host_env['platform'] = common.default_platform
José Fonseca97e2c5a2009-12-31 17:58:56 +0000218 host_env['machine'] = common.default_machine
219 host_env['debug'] = env['debug']
José Fonseca491f3842009-12-10 16:29:04 +0000220
221 SConscript(
222 'src/glsl/SConscript',
José Fonseca7bbf7f92009-12-31 21:10:25 +0000223 variant_dir = os.path.join(env['build'], 'host'),
José Fonseca491f3842009-12-10 16:29:04 +0000224 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
225 exports={'env':host_env},
226 )
227
José Fonsecac42e6252008-01-31 13:14:35 +0900228SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000229 'src/SConscript',
José Fonseca9bf83fb2009-01-24 15:56:28 +0000230 variant_dir = env['build'],
José Fonsecac42e6252008-01-31 13:14:35 +0900231 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
232)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000233
José Fonseca8c7d39c2010-02-15 20:48:24 +0000234env.Default('src')
235