mesa: Fix remap_table setup.
[mesa.git] / SConstruct
1 #######################################################################
2 # Top-level SConstruct
3 #
4 # For example, invoke scons as
5 #
6 # scons build=debug llvm=yes 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 # build='debug'
13 # llvm=True
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
23 import os
24 import os.path
25 import sys
26 import SCons.Util
27
28 import common
29
30 #######################################################################
31 # Configuration options
32
33 opts = Variables('config.py')
34 common.AddOptions(opts)
35
36 env = Environment(
37 options = opts,
38 tools = ['gallium'],
39 toolpath = ['#scons'],
40 ENV = os.environ,
41 )
42
43 # Backwards compatability with old target configuration variable
44 try:
45 targets = ARGUMENTS['targets']
46 except KeyError:
47 pass
48 else:
49 targets = targets.split(',')
50 print 'scons: warning: targets option is deprecated; pass the targets on their own such as'
51 print
52 print ' scons %s' % ' '.join(targets)
53 print
54 COMMAND_LINE_TARGETS.append(targets)
55
56
57 Help(opts.GenerateHelpText(env))
58
59 # fail early for a common error on windows
60 if env['gles']:
61 try:
62 import libxml2
63 except ImportError:
64 raise SCons.Errors.UserError, "GLES requires libxml2-python to build"
65
66 #######################################################################
67 # Environment setup
68
69 # Includes
70 env.Prepend(CPPPATH = [
71 '#/include',
72 ])
73 env.Append(CPPPATH = [
74 '#/src/gallium/include',
75 '#/src/gallium/auxiliary',
76 '#/src/gallium/drivers',
77 '#/src/gallium/winsys',
78 ])
79
80 if env['msvc']:
81 env.Append(CPPPATH = ['#include/c99'])
82
83 # Embedded
84 if env['platform'] == 'embedded':
85 env.Append(CPPDEFINES = [
86 '_POSIX_SOURCE',
87 ('_POSIX_C_SOURCE', '199309L'),
88 '_SVID_SOURCE',
89 '_BSD_SOURCE',
90 '_GNU_SOURCE',
91
92 'PTHREADS',
93 ])
94 env.Append(LIBS = [
95 'm',
96 'pthread',
97 'dl',
98 ])
99
100 # Posix
101 if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
102 env.Append(CPPDEFINES = [
103 '_POSIX_SOURCE',
104 ('_POSIX_C_SOURCE', '199309L'),
105 '_SVID_SOURCE',
106 '_BSD_SOURCE',
107 '_GNU_SOURCE',
108 'PTHREADS',
109 'HAVE_POSIX_MEMALIGN',
110 ])
111 if env['gcc']:
112 env.Append(CFLAGS = ['-fvisibility=hidden'])
113 if env['platform'] == 'darwin':
114 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
115 env.Append(LIBS = [
116 'm',
117 'pthread',
118 'dl',
119 ])
120
121 # for debugging
122 #print env.Dump()
123
124
125 #######################################################################
126 # Invoke host SConscripts
127 #
128 # For things that are meant to be run on the native host build machine, instead
129 # of the target machine.
130 #
131
132 # Create host environent
133 if env['crosscompile'] and env['platform'] != 'embedded':
134 host_env = Environment(
135 options = opts,
136 # no tool used
137 tools = [],
138 toolpath = ['#scons'],
139 ENV = os.environ,
140 )
141
142 # Override options
143 host_env['platform'] = common.host_platform
144 host_env['machine'] = common.host_machine
145 host_env['toolchain'] = 'default'
146 host_env['llvm'] = False
147
148 host_env.Tool('gallium')
149
150 host_env['hostonly'] = True
151 assert host_env['crosscompile'] == False
152
153 if host_env['msvc']:
154 host_env.Append(CPPPATH = ['#include/c99'])
155
156 target_env = env
157 env = host_env
158 Export('env')
159
160 SConscript(
161 'src/SConscript',
162 variant_dir = host_env['build_dir'],
163 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
164 )
165
166 env = target_env
167
168 Export('env')
169
170 #######################################################################
171 # Invoke SConscripts
172
173 # TODO: Build several variants at the same time?
174 # http://www.scons.org/wiki/SimultaneousVariantBuilds
175
176 SConscript(
177 'src/SConscript',
178 variant_dir = env['build_dir'],
179 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
180 )
181