blob: 3a4ff9a3fac94a8314d247cffb7316b178e3772c [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'
34
José Fonseca94090432008-02-27 17:36:28 +090035if common.default_platform in ('linux', 'freebsd', 'darwin'):
Keith Whitwella5585cb2009-12-21 19:18:41 +000036 default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe'
José Fonseca58a3d7d2008-02-23 19:49:08 +090037 default_winsys = 'xlib'
José Fonseca94090432008-02-27 17:36:28 +090038elif common.default_platform in ('winddk',):
Keith Whitwella5585cb2009-12-21 19:18:41 +000039 default_drivers = 'softpipe,svga,i915,i965,trace,identity'
José Fonseca5a67df62008-06-03 00:04:19 +090040 default_winsys = 'all'
Alan Hourihanedea98eb2010-01-26 20:58:11 +000041elif common.default_platform in ('embedded',):
42 default_drivers = 'softpipe,llvmpipe'
43 default_winsys = 'xlib'
José Fonseca26c57d12008-02-23 00:46:40 +090044else:
José Fonseca58a3d7d2008-02-23 19:49:08 +090045 default_drivers = 'all'
46 default_winsys = 'all'
José Fonsecae70a4312008-02-24 16:43:07 +090047
José Fonsecae9fb90a2009-05-01 16:12:17 +010048opts = Variables('config.py')
José Fonseca13174c12008-03-03 18:52:37 +010049common.AddOptions(opts)
José Fonsecae9fb90a2009-05-01 16:12:17 +010050opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
Michel Dänzerd22bd142009-08-25 15:39:05 +020051 ['mesa', 'python', 'xorg']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010052opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
Vinson Leebd936702010-04-24 16:22:47 -070053 ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010054opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
Keith Whitwelldb5c2232010-03-28 09:53:58 -070055 ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib']))
José Fonsecac42e6252008-01-31 13:14:35 +090056
José Fonsecae9fb90a2009-05-01 16:12:17 +010057opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
Jonathan White3c819922008-08-29 11:30:32 -060058
José Fonseca81b6a802008-02-06 14:36:50 +090059env = Environment(
José Fonsecab04aa712008-06-06 14:48:57 +090060 options = opts,
61 tools = ['gallium'],
José Fonseca2c4349a2008-07-15 07:56:42 +090062 toolpath = ['#scons'],
José Fonsecab04aa712008-06-06 14:48:57 +090063 ENV = os.environ,
64)
65
Alan Hourihane6544be62010-01-26 19:14:16 +000066if os.environ.has_key('CC'):
67 env['CC'] = os.environ['CC']
68if os.environ.has_key('CFLAGS'):
69 env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
70if os.environ.has_key('CXX'):
71 env['CXX'] = os.environ['CXX']
72if os.environ.has_key('CXXFLAGS'):
73 env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
74if os.environ.has_key('LDFLAGS'):
75 env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
76
José Fonsecac42e6252008-01-31 13:14:35 +090077Help(opts.GenerateHelpText(env))
78
José Fonsecac42e6252008-01-31 13:14:35 +090079# replicate options values in local variables
80debug = env['debug']
81dri = env['dri']
82machine = env['machine']
José Fonsecad710a7c2008-02-19 18:53:16 +090083platform = env['platform']
José Fonsecac42e6252008-01-31 13:14:35 +090084
85# derived options
86x86 = machine == 'x86'
Michel Dänzer6b69e3c2008-10-23 10:28:48 +020087ppc = machine == 'ppc'
Alan Hourihanedea98eb2010-01-26 20:58:11 +000088gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
José Fonseca35460fc2008-04-25 18:16:25 +090089msvc = platform in ('windows', 'winddk')
José Fonsecac42e6252008-01-31 13:14:35 +090090
91Export([
92 'debug',
93 'x86',
Michel Dänzer6b69e3c2008-10-23 10:28:48 +020094 'ppc',
José Fonsecac42e6252008-01-31 13:14:35 +090095 'dri',
96 'platform',
97 'gcc',
98 'msvc',
99])
100
101
102#######################################################################
103# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +0900104
José Fonseca47a89e92010-04-10 03:01:30 +0100105# Always build trace, identity, softpipe, and llvmpipe (where possible)
José Fonsecadb2e1512010-02-25 17:02:52 +0000106if 'trace' not in env['drivers']:
107 env['drivers'].append('trace')
José Fonseca78d8e6c2010-03-09 17:08:16 +0000108if 'identity' not in env['drivers']:
109 env['drivers'].append('identity')
José Fonseca47a89e92010-04-10 03:01:30 +0100110if 'softpipe' not in env['drivers']:
111 env['drivers'].append('softpipe')
112if env['llvm'] and 'llvmpipe' not in env['drivers']:
113 env['drivers'].append('llvmpipe')
José Fonsecadb2e1512010-02-25 17:02:52 +0000114
José Fonsecac42e6252008-01-31 13:14:35 +0900115# Includes
Vinson Lee5fd97572010-04-26 01:08:34 -0700116env.Prepend(CPPPATH = [
José Fonsecac42e6252008-01-31 13:14:35 +0900117 '#/include',
Vinson Lee5fd97572010-04-26 01:08:34 -0700118])
119env.Append(CPPPATH = [
José Fonseca33ceb672008-02-18 10:52:44 +0000120 '#/src/gallium/include',
121 '#/src/gallium/auxiliary',
122 '#/src/gallium/drivers',
José Fonseca601bfb52010-03-10 10:34:29 +0000123 '#/src/gallium/winsys',
José Fonsecac42e6252008-01-31 13:14:35 +0900124])
125
José Fonsecadc6bcc92010-01-10 10:36:35 +0000126if env['msvc']:
127 env.Append(CPPPATH = ['#include/c99'])
128
Alan Hourihane32e60432010-01-28 17:26:05 +0000129# Embedded
130if platform == 'embedded':
José Fonseca00137962008-02-07 19:59:17 +0900131 env.Append(CPPDEFINES = [
132 '_POSIX_SOURCE',
133 ('_POSIX_C_SOURCE', '199309L'),
134 '_SVID_SOURCE',
135 '_BSD_SOURCE',
136 '_GNU_SOURCE',
137
138 'PTHREADS',
José Fonseca00137962008-02-07 19:59:17 +0900139 ])
Alan Hourihane32e60432010-01-28 17:26:05 +0000140 env.Append(LIBS = [
141 'm',
142 'pthread',
143 'dl',
144 ])
145
146# Posix
147if platform in ('posix', 'linux', 'freebsd', 'darwin'):
148 env.Append(CPPDEFINES = [
149 '_POSIX_SOURCE',
150 ('_POSIX_C_SOURCE', '199309L'),
151 '_SVID_SOURCE',
152 '_BSD_SOURCE',
153 '_GNU_SOURCE',
154
155 'PTHREADS',
156 'HAVE_POSIX_MEMALIGN',
157 ])
Vinson Leed57ba162010-01-23 21:05:58 -0800158 if platform == 'darwin':
159 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
José Fonseca00137962008-02-07 19:59:17 +0900160 env.Append(LIBS = [
161 'm',
162 'pthread',
José Fonseca00137962008-02-07 19:59:17 +0900163 'dl',
164 ])
José Fonsecac42e6252008-01-31 13:14:35 +0900165
José Fonseca4f17bd22008-03-12 13:34:30 +0000166# for debugging
167#print env.Dump()
168
José Fonsecac42e6252008-01-31 13:14:35 +0900169Export('env')
170
171
172#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900173# Invoke SConscripts
174
José Fonsecaf4192cb42008-01-31 14:21:49 +0900175# TODO: Build several variants at the same time?
176# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900177
José Fonseca491f3842009-12-10 16:29:04 +0000178if env['platform'] != common.default_platform:
179 # GLSL code has to be built twice -- one for the host OS, another for the target OS...
180
181 host_env = Environment(
182 # options are ignored
183 # default tool is used
José Fonseca97e2c5a2009-12-31 17:58:56 +0000184 tools = ['default', 'custom'],
José Fonseca491f3842009-12-10 16:29:04 +0000185 toolpath = ['#scons'],
186 ENV = os.environ,
187 )
188
189 host_env['platform'] = common.default_platform
José Fonseca97e2c5a2009-12-31 17:58:56 +0000190 host_env['machine'] = common.default_machine
191 host_env['debug'] = env['debug']
José Fonseca491f3842009-12-10 16:29:04 +0000192
193 SConscript(
194 'src/glsl/SConscript',
José Fonseca7bbf7f92009-12-31 21:10:25 +0000195 variant_dir = os.path.join(env['build'], 'host'),
José Fonseca491f3842009-12-10 16:29:04 +0000196 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
197 exports={'env':host_env},
198 )
199
José Fonsecac42e6252008-01-31 13:14:35 +0900200SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000201 'src/SConscript',
José Fonseca9bf83fb2009-01-24 15:56:28 +0000202 variant_dir = env['build'],
José Fonsecac42e6252008-01-31 13:14:35 +0900203 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
204)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000205
José Fonseca8c7d39c2010-02-15 20:48:24 +0000206env.Default('src')
207
208SConscript(
209 'progs/SConscript',
210 variant_dir = os.path.join('progs', env['build']),
211 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
212)