blob: 606be015c06307250932162788f69a2281cf757f [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é Fonseca706eda32010-03-09 15:07:57 +000056opts.Add(ListVariable('targets', 'target drivers to build', 'all',
57 ['xlib']))
José Fonsecac42e6252008-01-31 13:14:35 +090058
José Fonsecae9fb90a2009-05-01 16:12:17 +010059opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
Jonathan White3c819922008-08-29 11:30:32 -060060
José Fonseca81b6a802008-02-06 14:36:50 +090061env = Environment(
José Fonsecab04aa712008-06-06 14:48:57 +090062 options = opts,
63 tools = ['gallium'],
José Fonseca2c4349a2008-07-15 07:56:42 +090064 toolpath = ['#scons'],
José Fonsecab04aa712008-06-06 14:48:57 +090065 ENV = os.environ,
66)
67
Alan Hourihane6544be62010-01-26 19:14:16 +000068if os.environ.has_key('CC'):
69 env['CC'] = os.environ['CC']
70if os.environ.has_key('CFLAGS'):
71 env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
72if os.environ.has_key('CXX'):
73 env['CXX'] = os.environ['CXX']
74if os.environ.has_key('CXXFLAGS'):
75 env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
76if os.environ.has_key('LDFLAGS'):
77 env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
78
José Fonsecac42e6252008-01-31 13:14:35 +090079Help(opts.GenerateHelpText(env))
80
José Fonsecac42e6252008-01-31 13:14:35 +090081# replicate options values in local variables
82debug = env['debug']
83dri = env['dri']
84machine = env['machine']
José Fonsecad710a7c2008-02-19 18:53:16 +090085platform = env['platform']
Zack Rusinc61bf362010-02-08 18:05:22 -050086drawllvm = 'llvmpipe' in env['drivers']
87
Zack Rusin08e2eab2010-02-10 00:07:51 -050088# LLVM support in the Draw module
89if drawllvm:
90 env.Tool('llvm')
91 if not env.has_key('LLVM_VERSION'):
92 drawllvm = False
José Fonsecac42e6252008-01-31 13:14:35 +090093
94# derived options
95x86 = machine == 'x86'
Michel Dänzer6b69e3c2008-10-23 10:28:48 +020096ppc = machine == 'ppc'
Alan Hourihanedea98eb2010-01-26 20:58:11 +000097gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
José Fonseca35460fc2008-04-25 18:16:25 +090098msvc = platform in ('windows', 'winddk')
José Fonsecac42e6252008-01-31 13:14:35 +090099
100Export([
101 'debug',
102 'x86',
Michel Dänzer6b69e3c2008-10-23 10:28:48 +0200103 'ppc',
José Fonsecac42e6252008-01-31 13:14:35 +0900104 'dri',
Zack Rusinc61bf362010-02-08 18:05:22 -0500105 'drawllvm',
José Fonsecac42e6252008-01-31 13:14:35 +0900106 'platform',
107 'gcc',
108 'msvc',
109])
110
111
112#######################################################################
113# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +0900114
José Fonseca78d8e6c2010-03-09 17:08:16 +0000115# Always build trace and identity drivers
José Fonsecadb2e1512010-02-25 17:02:52 +0000116if 'trace' not in env['drivers']:
117 env['drivers'].append('trace')
José Fonseca78d8e6c2010-03-09 17:08:16 +0000118if 'identity' not in env['drivers']:
119 env['drivers'].append('identity')
José Fonsecadb2e1512010-02-25 17:02:52 +0000120
José Fonsecac42e6252008-01-31 13:14:35 +0900121# Includes
122env.Append(CPPPATH = [
123 '#/include',
José Fonseca33ceb672008-02-18 10:52:44 +0000124 '#/src/gallium/include',
125 '#/src/gallium/auxiliary',
126 '#/src/gallium/drivers',
José Fonseca601bfb52010-03-10 10:34:29 +0000127 '#/src/gallium/winsys',
José Fonsecac42e6252008-01-31 13:14:35 +0900128])
129
José Fonsecadc6bcc92010-01-10 10:36:35 +0000130if env['msvc']:
131 env.Append(CPPPATH = ['#include/c99'])
132
Alan Hourihane32e60432010-01-28 17:26:05 +0000133# Embedded
134if platform == 'embedded':
José Fonseca00137962008-02-07 19:59:17 +0900135 env.Append(CPPDEFINES = [
136 '_POSIX_SOURCE',
137 ('_POSIX_C_SOURCE', '199309L'),
138 '_SVID_SOURCE',
139 '_BSD_SOURCE',
140 '_GNU_SOURCE',
141
142 'PTHREADS',
José Fonseca00137962008-02-07 19:59:17 +0900143 ])
Alan Hourihane32e60432010-01-28 17:26:05 +0000144 env.Append(LIBS = [
145 'm',
146 'pthread',
147 'dl',
148 ])
149
150# Posix
151if 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 ])
Vinson Leed57ba162010-01-23 21:05:58 -0800162 if platform == 'darwin':
163 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
José Fonseca00137962008-02-07 19:59:17 +0900164 env.Append(CPPPATH = ['/usr/X11R6/include'])
165 env.Append(LIBPATH = ['/usr/X11R6/lib'])
166 env.Append(LIBS = [
167 'm',
168 'pthread',
Alan Hourihane32e60432010-01-28 17:26:05 +0000169 'expat',
José Fonseca00137962008-02-07 19:59:17 +0900170 'dl',
171 ])
José Fonsecac42e6252008-01-31 13:14:35 +0900172
173# DRI
174if dri:
175 env.ParseConfig('pkg-config --cflags --libs libdrm')
176 env.Append(CPPDEFINES = [
177 ('USE_EXTERNAL_DXTN_LIB', '1'),
178 'IN_DRI_DRIVER',
179 'GLX_DIRECT_RENDERING',
180 'GLX_INDIRECT_RENDERING',
181 ])
182
Zack Rusinc61bf362010-02-08 18:05:22 -0500183# LLVM support in the Draw module
184if drawllvm:
Zack Rusin08e2eab2010-02-10 00:07:51 -0500185 env.Append(CPPDEFINES = ['DRAW_LLVM'])
José Fonsecae773a812008-02-19 10:50:39 +0900186
José Fonsecac42e6252008-01-31 13:14:35 +0900187# libGL
José Fonsecaa7ce6d32008-04-25 19:53:13 +0900188if platform in ('linux', 'freebsd', 'darwin'):
José Fonsecac42e6252008-01-31 13:14:35 +0900189 env.Append(LIBS = [
190 'X11',
191 'Xext',
192 'Xxf86vm',
193 'Xdamage',
194 'Xfixes',
195 ])
196
José Fonseca4f17bd22008-03-12 13:34:30 +0000197# for debugging
198#print env.Dump()
199
José Fonsecac42e6252008-01-31 13:14:35 +0900200Export('env')
201
202
203#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900204# Invoke SConscripts
205
José Fonsecaf4192cb42008-01-31 14:21:49 +0900206# TODO: Build several variants at the same time?
207# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900208
José Fonseca491f3842009-12-10 16:29:04 +0000209if env['platform'] != common.default_platform:
210 # GLSL code has to be built twice -- one for the host OS, another for the target OS...
211
212 host_env = Environment(
213 # options are ignored
214 # default tool is used
José Fonseca97e2c5a2009-12-31 17:58:56 +0000215 tools = ['default', 'custom'],
José Fonseca491f3842009-12-10 16:29:04 +0000216 toolpath = ['#scons'],
217 ENV = os.environ,
218 )
219
220 host_env['platform'] = common.default_platform
José Fonseca97e2c5a2009-12-31 17:58:56 +0000221 host_env['machine'] = common.default_machine
222 host_env['debug'] = env['debug']
José Fonseca491f3842009-12-10 16:29:04 +0000223
224 SConscript(
225 'src/glsl/SConscript',
José Fonseca7bbf7f92009-12-31 21:10:25 +0000226 variant_dir = os.path.join(env['build'], 'host'),
José Fonseca491f3842009-12-10 16:29:04 +0000227 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
228 exports={'env':host_env},
229 )
230
José Fonsecac42e6252008-01-31 13:14:35 +0900231SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000232 'src/SConscript',
José Fonseca9bf83fb2009-01-24 15:56:28 +0000233 variant_dir = env['build'],
José Fonsecac42e6252008-01-31 13:14:35 +0900234 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
235)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000236
José Fonseca8c7d39c2010-02-15 20:48:24 +0000237env.Default('src')
238
239SConscript(
240 'progs/SConscript',
241 variant_dir = os.path.join('progs', env['build']),
242 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
243)