blob: e1c4a1898ce01aec5f97d8127eeee1f961a65861 [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,
José Fonseca89d778f2010-01-01 00:22:48 +000053 ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010054opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
Keith Whitwella5585cb2009-12-21 19:18:41 +000055 ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon']))
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']
Zack Rusinc61bf362010-02-08 18:05:22 -050084drawllvm = 'llvmpipe' in env['drivers']
85
Zack Rusin08e2eab2010-02-10 00:07:51 -050086# LLVM support in the Draw module
87if drawllvm:
88 env.Tool('llvm')
89 if not env.has_key('LLVM_VERSION'):
90 drawllvm = False
José Fonsecac42e6252008-01-31 13:14:35 +090091
92# derived options
93x86 = machine == 'x86'
Michel Dänzer6b69e3c2008-10-23 10:28:48 +020094ppc = machine == 'ppc'
Alan Hourihanedea98eb2010-01-26 20:58:11 +000095gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
José Fonseca35460fc2008-04-25 18:16:25 +090096msvc = platform in ('windows', 'winddk')
José Fonsecac42e6252008-01-31 13:14:35 +090097
98Export([
99 'debug',
100 'x86',
Michel Dänzer6b69e3c2008-10-23 10:28:48 +0200101 'ppc',
José Fonsecac42e6252008-01-31 13:14:35 +0900102 'dri',
Zack Rusinc61bf362010-02-08 18:05:22 -0500103 'drawllvm',
José Fonsecac42e6252008-01-31 13:14:35 +0900104 'platform',
105 'gcc',
106 'msvc',
107])
108
109
110#######################################################################
111# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +0900112
José Fonsecadb2e1512010-02-25 17:02:52 +0000113# Always build trace driver
114if 'trace' not in env['drivers']:
115 env['drivers'].append('trace')
116
José Fonsecac42e6252008-01-31 13:14:35 +0900117# Includes
118env.Append(CPPPATH = [
119 '#/include',
José Fonseca33ceb672008-02-18 10:52:44 +0000120 '#/src/gallium/include',
121 '#/src/gallium/auxiliary',
122 '#/src/gallium/drivers',
José Fonsecac42e6252008-01-31 13:14:35 +0900123])
124
José Fonsecadc6bcc92010-01-10 10:36:35 +0000125if env['msvc']:
126 env.Append(CPPPATH = ['#include/c99'])
127
Alan Hourihane32e60432010-01-28 17:26:05 +0000128# Embedded
129if platform == 'embedded':
José Fonseca00137962008-02-07 19:59:17 +0900130 env.Append(CPPDEFINES = [
131 '_POSIX_SOURCE',
132 ('_POSIX_C_SOURCE', '199309L'),
133 '_SVID_SOURCE',
134 '_BSD_SOURCE',
135 '_GNU_SOURCE',
136
137 'PTHREADS',
José Fonseca00137962008-02-07 19:59:17 +0900138 ])
Alan Hourihane32e60432010-01-28 17:26:05 +0000139 env.Append(LIBS = [
140 'm',
141 'pthread',
142 'dl',
143 ])
144
145# Posix
146if platform in ('posix', 'linux', 'freebsd', 'darwin'):
147 env.Append(CPPDEFINES = [
148 '_POSIX_SOURCE',
149 ('_POSIX_C_SOURCE', '199309L'),
150 '_SVID_SOURCE',
151 '_BSD_SOURCE',
152 '_GNU_SOURCE',
153
154 'PTHREADS',
155 'HAVE_POSIX_MEMALIGN',
156 ])
Vinson Leed57ba162010-01-23 21:05:58 -0800157 if platform == 'darwin':
158 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
José Fonseca00137962008-02-07 19:59:17 +0900159 env.Append(CPPPATH = ['/usr/X11R6/include'])
160 env.Append(LIBPATH = ['/usr/X11R6/lib'])
161 env.Append(LIBS = [
162 'm',
163 'pthread',
Alan Hourihane32e60432010-01-28 17:26:05 +0000164 'expat',
José Fonseca00137962008-02-07 19:59:17 +0900165 'dl',
166 ])
José Fonsecac42e6252008-01-31 13:14:35 +0900167
168# DRI
169if dri:
170 env.ParseConfig('pkg-config --cflags --libs libdrm')
171 env.Append(CPPDEFINES = [
172 ('USE_EXTERNAL_DXTN_LIB', '1'),
173 'IN_DRI_DRIVER',
174 'GLX_DIRECT_RENDERING',
175 'GLX_INDIRECT_RENDERING',
176 ])
177
Zack Rusinc61bf362010-02-08 18:05:22 -0500178# LLVM support in the Draw module
179if drawllvm:
Zack Rusin08e2eab2010-02-10 00:07:51 -0500180 env.Append(CPPDEFINES = ['DRAW_LLVM'])
José Fonsecae773a812008-02-19 10:50:39 +0900181
José Fonsecac42e6252008-01-31 13:14:35 +0900182# libGL
José Fonsecaa7ce6d32008-04-25 19:53:13 +0900183if platform in ('linux', 'freebsd', 'darwin'):
José Fonsecac42e6252008-01-31 13:14:35 +0900184 env.Append(LIBS = [
185 'X11',
186 'Xext',
187 'Xxf86vm',
188 'Xdamage',
189 'Xfixes',
190 ])
191
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
234SConscript(
235 'progs/SConscript',
236 variant_dir = os.path.join('progs', env['build']),
237 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
238)