SConstruct revision 5a67df6d7cc8c74bfb71a8f19b8f6fdfb525091b
1#######################################################################
2# Top-level SConstruct
3#
4# For example, invoke scons as 
5#
6#   scons debug=1 dri=0 machine=x86
7#
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
14#   machine='x86'
15# 
16# Invoke
17#
18#   scons -h
19#
20# to get the full list of options. See scons manpage for more info.
21#  
22
23import os
24import os.path
25import sys
26
27import common
28
29#######################################################################
30# Configuration options
31
32if common.default_platform in ('linux', 'freebsd', 'darwin'):
33	default_statetrackers = 'all'
34	default_drivers = 'softpipe,failover,i915simple,i965simple'
35	default_winsys = 'xlib'
36elif common.default_platform in ('winddk',):
37	default_statetrackers = 'all'
38	default_drivers = 'softpipe,i915simple'
39	default_winsys = 'all'
40else:
41	default_statetrackers = 'all'
42	default_drivers = 'all'
43	default_winsys = 'all'
44
45opts = Options('config.py')
46common.AddOptions(opts)
47opts.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers,
48                     ['mesa']))
49opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers,
50                     ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell']))
51opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys,
52                     ['xlib', 'intel', 'gdi'])) 
53
54env = Environment(
55	options = opts, 
56	ENV = os.environ)
57Help(opts.GenerateHelpText(env))
58
59# replicate options values in local variables
60debug = env['debug']
61dri = env['dri']
62llvm = env['llvm']
63machine = env['machine']
64platform = env['platform']
65
66# derived options
67x86 = machine == 'x86'
68gcc = platform in ('linux', 'freebsd', 'darwin')
69msvc = platform in ('windows', 'winddk')
70
71Export([
72	'debug', 
73	'x86', 
74	'dri', 
75	'llvm',
76	'platform',
77	'gcc',
78	'msvc',
79])
80
81
82#######################################################################
83# Environment setup
84#
85# TODO: put the compiler specific settings in separate files
86# TODO: auto-detect as much as possible
87
88if platform == 'winddk':
89	env.Tool('winddk', ['scons'])
90	
91	env.Append(CPPPATH = [
92		env['SDK_INC_PATH'],
93		env['DDK_INC_PATH'],
94		env['WDM_INC_PATH'],
95		env['CRT_INC_PATH'],
96	])
97
98if platform == 'wince':
99	env.Tool('evc', ['scons'])
100
101common.generate(env)
102
103
104# Includes
105env.Append(CPPPATH = [
106	'#/include',
107	'#/src/gallium/include',
108	'#/src/gallium/auxiliary',
109	'#/src/gallium/drivers',
110])
111
112
113# x86 assembly
114if x86:
115	if gcc:	
116		env.Append(CFLAGS = '-m32')
117		env.Append(CXXFLAGS = '-m32')
118
119
120# Posix
121if platform in ('posix', 'linux', 'freebsd', 'darwin'):
122	env.Append(CPPDEFINES = [
123		'_POSIX_SOURCE',
124		('_POSIX_C_SOURCE', '199309L'), 
125		'_SVID_SOURCE',
126		'_BSD_SOURCE', 
127		'_GNU_SOURCE',
128		
129		'PTHREADS',
130		'HAVE_POSIX_MEMALIGN',
131	])
132	env.Append(CPPPATH = ['/usr/X11R6/include'])
133	env.Append(LIBPATH = ['/usr/X11R6/lib'])
134	env.Append(LIBS = [
135		'm',
136		'pthread',
137		'expat',
138		'dl',
139	])
140
141
142# DRI
143if dri:
144	env.ParseConfig('pkg-config --cflags --libs libdrm')
145	env.Append(CPPDEFINES = [
146		('USE_EXTERNAL_DXTN_LIB', '1'), 
147		'IN_DRI_DRIVER',
148		'GLX_DIRECT_RENDERING',
149		'GLX_INDIRECT_RENDERING',
150	])
151
152# LLVM
153if llvm:
154	# See also http://www.scons.org/wiki/UsingPkgConfig
155	env.ParseConfig('llvm-config --cflags --ldflags --libs')
156	env.Append(CPPDEFINES = ['MESA_LLVM'])
157        # Force C++ linkage
158	env['LINK'] = env['CXX']
159
160# libGL
161if platform in ('linux', 'freebsd', 'darwin'):
162	env.Append(LIBS = [
163		'X11',
164		'Xext',
165		'Xxf86vm',
166		'Xdamage',
167		'Xfixes',
168	])
169
170# for debugging
171#print env.Dump()
172
173Export('env')
174
175
176#######################################################################
177# Invoke SConscripts
178
179# TODO: Build several variants at the same time?
180# http://www.scons.org/wiki/SimultaneousVariantBuilds
181
182SConscript(
183	'src/SConscript',
184	build_dir = common.make_build_dir(env),
185	duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
186)
187