blob: a187d8d1b6faba6e4cf77bb0a3f87880c1e73714 [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 Whitwell00fe54a2010-06-07 16:43:49 +010034default_targets = 'graw-null'
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',
Keith Whitwell00fe54a2010-06-07 16:43:49 +010072 'graw-null',
Keith Whitwell39087f62010-05-14 10:55:07 +010073 'libgl-gdi',
74 'libgl-xlib',
75 'xorg-i915',
76 'xorg-i965',
77 'xorg-nouveau',
78 'xorg-radeon',
79 'xorg-vmwgfx']))
80
José Fonsecae9fb90a2009-05-01 16:12:17 +010081opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
Jonathan White3c819922008-08-29 11:30:32 -060082
José Fonseca81b6a802008-02-06 14:36:50 +090083env = Environment(
José Fonsecab04aa712008-06-06 14:48:57 +090084 options = opts,
85 tools = ['gallium'],
José Fonseca2c4349a2008-07-15 07:56:42 +090086 toolpath = ['#scons'],
José Fonsecab04aa712008-06-06 14:48:57 +090087 ENV = os.environ,
88)
89
Alan Hourihane6544be62010-01-26 19:14:16 +000090if os.environ.has_key('CC'):
91 env['CC'] = os.environ['CC']
92if os.environ.has_key('CFLAGS'):
93 env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
94if os.environ.has_key('CXX'):
95 env['CXX'] = os.environ['CXX']
96if os.environ.has_key('CXXFLAGS'):
97 env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
98if os.environ.has_key('LDFLAGS'):
99 env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
100
José Fonsecac42e6252008-01-31 13:14:35 +0900101Help(opts.GenerateHelpText(env))
102
José Fonsecac42e6252008-01-31 13:14:35 +0900103# replicate options values in local variables
104debug = env['debug']
105dri = env['dri']
106machine = env['machine']
José Fonsecad710a7c2008-02-19 18:53:16 +0900107platform = env['platform']
José Fonsecac42e6252008-01-31 13:14:35 +0900108
109# derived options
110x86 = machine == 'x86'
Michel Dänzer6b69e3c2008-10-23 10:28:48 +0200111ppc = machine == 'ppc'
Alan Hourihanedea98eb2010-01-26 20:58:11 +0000112gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
José Fonseca35460fc2008-04-25 18:16:25 +0900113msvc = platform in ('windows', 'winddk')
José Fonsecac42e6252008-01-31 13:14:35 +0900114
115Export([
116 'debug',
117 'x86',
Michel Dänzer6b69e3c2008-10-23 10:28:48 +0200118 'ppc',
José Fonsecac42e6252008-01-31 13:14:35 +0900119 'dri',
120 'platform',
121 'gcc',
122 'msvc',
123])
124
125
126#######################################################################
127# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +0900128
Jakob Bornecrantz2c3fb4e2010-05-04 12:06:37 +0100129# Always build trace, rbug, identity, softpipe, and llvmpipe (where possible)
José Fonsecadb2e1512010-02-25 17:02:52 +0000130if 'trace' not in env['drivers']:
131 env['drivers'].append('trace')
Jakob Bornecrantz2c3fb4e2010-05-04 12:06:37 +0100132if 'rbug' not in env['drivers']:
133 env['drivers'].append('rbug')
Jakob Bornecrantz40d4b412010-06-28 22:22:53 +0200134if 'galahad' not in env['drivers']:
135 env['drivers'].append('galahad')
José Fonseca78d8e6c2010-03-09 17:08:16 +0000136if 'identity' not in env['drivers']:
137 env['drivers'].append('identity')
José Fonseca47a89e92010-04-10 03:01:30 +0100138if 'softpipe' not in env['drivers']:
139 env['drivers'].append('softpipe')
140if env['llvm'] and 'llvmpipe' not in env['drivers']:
141 env['drivers'].append('llvmpipe')
Joakim Sindholtfb08e032010-06-05 16:53:38 +0200142if 'sw' not in env['drivers']:
143 env['drivers'].append('sw')
José Fonsecadb2e1512010-02-25 17:02:52 +0000144
José Fonsecac42e6252008-01-31 13:14:35 +0900145# Includes
Vinson Lee5fd97572010-04-26 01:08:34 -0700146env.Prepend(CPPPATH = [
José Fonsecac42e6252008-01-31 13:14:35 +0900147 '#/include',
Vinson Lee5fd97572010-04-26 01:08:34 -0700148])
149env.Append(CPPPATH = [
José Fonseca33ceb672008-02-18 10:52:44 +0000150 '#/src/gallium/include',
151 '#/src/gallium/auxiliary',
152 '#/src/gallium/drivers',
José Fonseca601bfb52010-03-10 10:34:29 +0000153 '#/src/gallium/winsys',
José Fonsecac42e6252008-01-31 13:14:35 +0900154])
155
José Fonsecadc6bcc92010-01-10 10:36:35 +0000156if env['msvc']:
157 env.Append(CPPPATH = ['#include/c99'])
158
Alan Hourihane32e60432010-01-28 17:26:05 +0000159# Embedded
160if platform == 'embedded':
José Fonseca00137962008-02-07 19:59:17 +0900161 env.Append(CPPDEFINES = [
162 '_POSIX_SOURCE',
163 ('_POSIX_C_SOURCE', '199309L'),
164 '_SVID_SOURCE',
165 '_BSD_SOURCE',
166 '_GNU_SOURCE',
167
168 'PTHREADS',
José Fonseca00137962008-02-07 19:59:17 +0900169 ])
Alan Hourihane32e60432010-01-28 17:26:05 +0000170 env.Append(LIBS = [
171 'm',
172 'pthread',
173 'dl',
174 ])
175
176# Posix
177if platform in ('posix', 'linux', 'freebsd', 'darwin'):
178 env.Append(CPPDEFINES = [
179 '_POSIX_SOURCE',
180 ('_POSIX_C_SOURCE', '199309L'),
181 '_SVID_SOURCE',
182 '_BSD_SOURCE',
183 '_GNU_SOURCE',
Alan Hourihane32e60432010-01-28 17:26:05 +0000184 'PTHREADS',
185 'HAVE_POSIX_MEMALIGN',
186 ])
Jakob Bornecrantz2ebe0272010-05-12 22:48:32 +0100187 if gcc:
188 env.Append(CFLAGS = ['-fvisibility=hidden'])
Vinson Leed57ba162010-01-23 21:05:58 -0800189 if platform == 'darwin':
190 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
José Fonseca00137962008-02-07 19:59:17 +0900191 env.Append(LIBS = [
192 'm',
193 'pthread',
José Fonseca00137962008-02-07 19:59:17 +0900194 'dl',
195 ])
José Fonsecac42e6252008-01-31 13:14:35 +0900196
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