blob: 5c72323d839110ba9b726ba9d22de1d8fce66838 [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,
Michel Dänzerd22bd142009-08-25 15:39:05 +020052 ['mesa', 'python', 'xorg']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010053opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
Jakob Bornecrantz9f7f7112010-05-12 21:11:39 +010054 ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010055opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
Keith Whitwelldb5c2232010-03-28 09:53:58 -070056 ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', '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')
José Fonsecadb2e1512010-02-25 17:02:52 +0000139
José Fonsecac42e6252008-01-31 13:14:35 +0900140# Includes
Vinson Lee5fd97572010-04-26 01:08:34 -0700141env.Prepend(CPPPATH = [
José Fonsecac42e6252008-01-31 13:14:35 +0900142 '#/include',
Vinson Lee5fd97572010-04-26 01:08:34 -0700143])
144env.Append(CPPPATH = [
José Fonseca33ceb672008-02-18 10:52:44 +0000145 '#/src/gallium/include',
146 '#/src/gallium/auxiliary',
147 '#/src/gallium/drivers',
José Fonseca601bfb52010-03-10 10:34:29 +0000148 '#/src/gallium/winsys',
José Fonsecac42e6252008-01-31 13:14:35 +0900149])
150
José Fonsecadc6bcc92010-01-10 10:36:35 +0000151if env['msvc']:
152 env.Append(CPPPATH = ['#include/c99'])
153
Alan Hourihane32e60432010-01-28 17:26:05 +0000154# Embedded
155if platform == 'embedded':
José Fonseca00137962008-02-07 19:59:17 +0900156 env.Append(CPPDEFINES = [
157 '_POSIX_SOURCE',
158 ('_POSIX_C_SOURCE', '199309L'),
159 '_SVID_SOURCE',
160 '_BSD_SOURCE',
161 '_GNU_SOURCE',
162
163 'PTHREADS',
José Fonseca00137962008-02-07 19:59:17 +0900164 ])
Alan Hourihane32e60432010-01-28 17:26:05 +0000165 env.Append(LIBS = [
166 'm',
167 'pthread',
168 'dl',
169 ])
170
171# Posix
172if platform in ('posix', 'linux', 'freebsd', 'darwin'):
173 env.Append(CPPDEFINES = [
174 '_POSIX_SOURCE',
175 ('_POSIX_C_SOURCE', '199309L'),
176 '_SVID_SOURCE',
177 '_BSD_SOURCE',
178 '_GNU_SOURCE',
Alan Hourihane32e60432010-01-28 17:26:05 +0000179 'PTHREADS',
180 'HAVE_POSIX_MEMALIGN',
181 ])
Jakob Bornecrantz2ebe0272010-05-12 22:48:32 +0100182 if gcc:
183 env.Append(CFLAGS = ['-fvisibility=hidden'])
Vinson Leed57ba162010-01-23 21:05:58 -0800184 if platform == 'darwin':
185 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
José Fonseca00137962008-02-07 19:59:17 +0900186 env.Append(LIBS = [
187 'm',
188 'pthread',
José Fonseca00137962008-02-07 19:59:17 +0900189 'dl',
190 ])
José Fonsecac42e6252008-01-31 13:14:35 +0900191
José Fonseca4f17bd22008-03-12 13:34:30 +0000192# for debugging
193#print env.Dump()
194
José Fonsecac42e6252008-01-31 13:14:35 +0900195Export('env')
196
197
198#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900199# Invoke SConscripts
200
José Fonsecaf4192cb42008-01-31 14:21:49 +0900201# TODO: Build several variants at the same time?
202# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900203
José Fonseca491f3842009-12-10 16:29:04 +0000204if env['platform'] != common.default_platform:
205 # GLSL code has to be built twice -- one for the host OS, another for the target OS...
206
207 host_env = Environment(
208 # options are ignored
209 # default tool is used
José Fonseca97e2c5a2009-12-31 17:58:56 +0000210 tools = ['default', 'custom'],
José Fonseca491f3842009-12-10 16:29:04 +0000211 toolpath = ['#scons'],
212 ENV = os.environ,
213 )
214
215 host_env['platform'] = common.default_platform
José Fonseca97e2c5a2009-12-31 17:58:56 +0000216 host_env['machine'] = common.default_machine
217 host_env['debug'] = env['debug']
José Fonseca491f3842009-12-10 16:29:04 +0000218
219 SConscript(
220 'src/glsl/SConscript',
José Fonseca7bbf7f92009-12-31 21:10:25 +0000221 variant_dir = os.path.join(env['build'], 'host'),
José Fonseca491f3842009-12-10 16:29:04 +0000222 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
223 exports={'env':host_env},
224 )
225
José Fonsecac42e6252008-01-31 13:14:35 +0900226SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000227 'src/SConscript',
José Fonseca9bf83fb2009-01-24 15:56:28 +0000228 variant_dir = env['build'],
José Fonsecac42e6252008-01-31 13:14:35 +0900229 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
230)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000231
José Fonseca8c7d39c2010-02-15 20:48:24 +0000232env.Default('src')
233