3908840086a126984da51b2d7e0b48c8fad19b8c
[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 Export('env')
125
126
127 #######################################################################
128 # Invoke host SConscripts
129 #
130 # For things that are meant to be run on the native host build machine, instead
131 # of the target machine.
132 #
133
134 # Create host environent
135 if env['crosscompile'] and env['platform'] != 'embedded':
136 host_env = Environment(
137 options = opts,
138 # no tool used
139 tools = [],
140 toolpath = ['#scons'],
141 ENV = os.environ,
142 )
143
144 # Override options
145 host_env['platform'] = common.host_platform
146 host_env['machine'] = common.host_machine
147 host_env['toolchain'] = 'default'
148 host_env['llvm'] = False
149
150 host_env.Tool('gallium')
151
152 SConscript(
153 'src/glsl/SConscript',
154 variant_dir = host_env['build_dir'],
155 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
156 exports={'env':host_env},
157 )
158
159
160 #######################################################################
161 # Invoke SConscripts
162
163 # TODO: Build several variants at the same time?
164 # http://www.scons.org/wiki/SimultaneousVariantBuilds
165
166 SConscript(
167 'src/SConscript',
168 variant_dir = env['build_dir'],
169 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
170 )
171