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