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