blob: 3a40244d88714c68afd38fbeffb326b89047ca85 [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'
José Fonseca26c57d12008-02-23 00:46:40 +090041else:
José Fonseca58a3d7d2008-02-23 19:49:08 +090042 default_drivers = 'all'
43 default_winsys = 'all'
José Fonsecae70a4312008-02-24 16:43:07 +090044
José Fonsecae9fb90a2009-05-01 16:12:17 +010045opts = Variables('config.py')
José Fonseca13174c12008-03-03 18:52:37 +010046common.AddOptions(opts)
José Fonsecae9fb90a2009-05-01 16:12:17 +010047opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
Michel Dänzerd22bd142009-08-25 15:39:05 +020048 ['mesa', 'python', 'xorg']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010049opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
José Fonseca89d778f2010-01-01 00:22:48 +000050 ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010051opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
Keith Whitwella5585cb2009-12-21 19:18:41 +000052 ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon']))
José Fonsecac42e6252008-01-31 13:14:35 +090053
José Fonsecae9fb90a2009-05-01 16:12:17 +010054opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
Jonathan White3c819922008-08-29 11:30:32 -060055
José Fonseca81b6a802008-02-06 14:36:50 +090056env = Environment(
José Fonsecab04aa712008-06-06 14:48:57 +090057 options = opts,
58 tools = ['gallium'],
José Fonseca2c4349a2008-07-15 07:56:42 +090059 toolpath = ['#scons'],
José Fonsecab04aa712008-06-06 14:48:57 +090060 ENV = os.environ,
61)
62
Alan Hourihane6544be62010-01-26 19:14:16 +000063if os.environ.has_key('CC'):
64 env['CC'] = os.environ['CC']
65if os.environ.has_key('CFLAGS'):
66 env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
67if os.environ.has_key('CXX'):
68 env['CXX'] = os.environ['CXX']
69if os.environ.has_key('CXXFLAGS'):
70 env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
71if os.environ.has_key('LDFLAGS'):
72 env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
73
José Fonsecac42e6252008-01-31 13:14:35 +090074Help(opts.GenerateHelpText(env))
75
José Fonsecac42e6252008-01-31 13:14:35 +090076# replicate options values in local variables
77debug = env['debug']
78dri = env['dri']
José Fonsecae773a812008-02-19 10:50:39 +090079llvm = env['llvm']
José Fonsecac42e6252008-01-31 13:14:35 +090080machine = env['machine']
José Fonsecad710a7c2008-02-19 18:53:16 +090081platform = env['platform']
José Fonsecac42e6252008-01-31 13:14:35 +090082
83# derived options
84x86 = machine == 'x86'
Michel Dänzer6b69e3c2008-10-23 10:28:48 +020085ppc = machine == 'ppc'
José Fonsecad710a7c2008-02-19 18:53:16 +090086gcc = platform in ('linux', 'freebsd', 'darwin')
José Fonseca35460fc2008-04-25 18:16:25 +090087msvc = platform in ('windows', 'winddk')
José Fonsecac42e6252008-01-31 13:14:35 +090088
89Export([
90 'debug',
91 'x86',
Michel Dänzer6b69e3c2008-10-23 10:28:48 +020092 'ppc',
José Fonsecac42e6252008-01-31 13:14:35 +090093 'dri',
José Fonsecae773a812008-02-19 10:50:39 +090094 'llvm',
José Fonsecac42e6252008-01-31 13:14:35 +090095 'platform',
96 'gcc',
97 'msvc',
98])
99
100
101#######################################################################
102# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +0900103
104# Includes
105env.Append(CPPPATH = [
106 '#/include',
José Fonseca33ceb672008-02-18 10:52:44 +0000107 '#/src/gallium/include',
108 '#/src/gallium/auxiliary',
109 '#/src/gallium/drivers',
José Fonsecac42e6252008-01-31 13:14:35 +0900110])
111
José Fonsecadc6bcc92010-01-10 10:36:35 +0000112if env['msvc']:
113 env.Append(CPPPATH = ['#include/c99'])
114
José Fonsecac42e6252008-01-31 13:14:35 +0900115
José Fonseca00137962008-02-07 19:59:17 +0900116# Posix
117if platform in ('posix', 'linux', 'freebsd', 'darwin'):
118 env.Append(CPPDEFINES = [
119 '_POSIX_SOURCE',
120 ('_POSIX_C_SOURCE', '199309L'),
121 '_SVID_SOURCE',
122 '_BSD_SOURCE',
123 '_GNU_SOURCE',
124
125 'PTHREADS',
126 'HAVE_POSIX_MEMALIGN',
127 ])
Vinson Leed57ba162010-01-23 21:05:58 -0800128 if platform == 'darwin':
129 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
José Fonseca00137962008-02-07 19:59:17 +0900130 env.Append(CPPPATH = ['/usr/X11R6/include'])
131 env.Append(LIBPATH = ['/usr/X11R6/lib'])
132 env.Append(LIBS = [
133 'm',
134 'pthread',
135 'expat',
136 'dl',
137 ])
138
José Fonsecac42e6252008-01-31 13:14:35 +0900139
140# DRI
141if dri:
142 env.ParseConfig('pkg-config --cflags --libs libdrm')
143 env.Append(CPPDEFINES = [
144 ('USE_EXTERNAL_DXTN_LIB', '1'),
145 'IN_DRI_DRIVER',
146 'GLX_DIRECT_RENDERING',
147 'GLX_INDIRECT_RENDERING',
148 ])
149
José Fonsecae773a812008-02-19 10:50:39 +0900150# LLVM
151if llvm:
152 # See also http://www.scons.org/wiki/UsingPkgConfig
Michel Dänzer2b6235c2009-03-09 17:46:49 +0100153 env.ParseConfig('llvm-config --cflags --ldflags --libs backend bitreader engine instrumentation interpreter ipo')
José Fonsecae773a812008-02-19 10:50:39 +0900154 env.Append(CPPDEFINES = ['MESA_LLVM'])
Michel Dänzer72c9d4a2008-03-04 18:28:23 +0100155 # Force C++ linkage
José Fonseca9a767982008-03-04 12:40:18 +0100156 env['LINK'] = env['CXX']
José Fonsecae773a812008-02-19 10:50:39 +0900157
José Fonsecac42e6252008-01-31 13:14:35 +0900158# libGL
José Fonsecaa7ce6d32008-04-25 19:53:13 +0900159if platform in ('linux', 'freebsd', 'darwin'):
José Fonsecac42e6252008-01-31 13:14:35 +0900160 env.Append(LIBS = [
161 'X11',
162 'Xext',
163 'Xxf86vm',
164 'Xdamage',
165 'Xfixes',
166 ])
167
José Fonseca4f17bd22008-03-12 13:34:30 +0000168# for debugging
169#print env.Dump()
170
José Fonsecac42e6252008-01-31 13:14:35 +0900171Export('env')
172
173
174#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900175# Invoke SConscripts
176
José Fonsecaf4192cb42008-01-31 14:21:49 +0900177# TODO: Build several variants at the same time?
178# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900179
José Fonseca491f3842009-12-10 16:29:04 +0000180if env['platform'] != common.default_platform:
181 # GLSL code has to be built twice -- one for the host OS, another for the target OS...
182
183 host_env = Environment(
184 # options are ignored
185 # default tool is used
José Fonseca97e2c5a2009-12-31 17:58:56 +0000186 tools = ['default', 'custom'],
José Fonseca491f3842009-12-10 16:29:04 +0000187 toolpath = ['#scons'],
188 ENV = os.environ,
189 )
190
191 host_env['platform'] = common.default_platform
José Fonseca97e2c5a2009-12-31 17:58:56 +0000192 host_env['machine'] = common.default_machine
193 host_env['debug'] = env['debug']
José Fonseca491f3842009-12-10 16:29:04 +0000194
195 SConscript(
196 'src/glsl/SConscript',
José Fonseca7bbf7f92009-12-31 21:10:25 +0000197 variant_dir = os.path.join(env['build'], 'host'),
José Fonseca491f3842009-12-10 16:29:04 +0000198 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
199 exports={'env':host_env},
200 )
201
José Fonsecac42e6252008-01-31 13:14:35 +0900202SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000203 'src/SConscript',
José Fonseca9bf83fb2009-01-24 15:56:28 +0000204 variant_dir = env['build'],
José Fonsecac42e6252008-01-31 13:14:35 +0900205 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
206)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000207
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)