gallium: added EMIT_HEADER case
[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 ('win32', '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 common.generate(env)
88
89 if platform == 'winddk':
90 env.Tool('winddk', ['.'])
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 # Optimization flags
100 if gcc:
101 if debug:
102 env.Append(CFLAGS = '-O0 -g3')
103 env.Append(CXXFLAGS = '-O0 -g3')
104 else:
105 env.Append(CFLAGS = '-O3 -g3')
106 env.Append(CXXFLAGS = '-O3 -g3')
107
108 env.Append(CFLAGS = '-Wall -Wmissing-prototypes -Wno-long-long -ffast-math -pedantic')
109 env.Append(CXXFLAGS = '-Wall -pedantic')
110
111 # Be nice to Eclipse
112 env.Append(CFLAGS = '-fmessage-length=0')
113 env.Append(CXXFLAGS = '-fmessage-length=0')
114
115 if msvc:
116 cflags = [
117 #'/Wp64', # enable 64 bit porting warnings
118 ]
119 env.Append(CFLAGS = cflags)
120 env.Append(CXXFLAGS = cflags)
121 # Put debugging information in a separate .pdb file for each object file as
122 # descrived in the scons manpage
123 env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
124
125 # Defines
126 if debug:
127 env.Append(CPPDEFINES = ['DEBUG'])
128 else:
129 env.Append(CPPDEFINES = ['NDEBUG'])
130
131
132 # Includes
133 env.Append(CPPPATH = [
134 '#/include',
135 '#/src/gallium/include',
136 '#/src/gallium/auxiliary',
137 '#/src/gallium/drivers',
138 ])
139
140
141 # x86 assembly
142 if x86:
143 env.Append(CPPDEFINES = [
144 'USE_X86_ASM',
145 'USE_MMX_ASM',
146 'USE_3DNOW_ASM',
147 'USE_SSE_ASM',
148 ])
149 if gcc:
150 env.Append(CFLAGS = '-m32')
151 env.Append(CXXFLAGS = '-m32')
152
153
154 # Posix
155 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
156 env.Append(CPPDEFINES = [
157 '_POSIX_SOURCE',
158 ('_POSIX_C_SOURCE', '199309L'),
159 '_SVID_SOURCE',
160 '_BSD_SOURCE',
161 '_GNU_SOURCE',
162
163 'PTHREADS',
164 'HAVE_POSIX_MEMALIGN',
165 ])
166 env.Append(CPPPATH = ['/usr/X11R6/include'])
167 env.Append(LIBPATH = ['/usr/X11R6/lib'])
168 env.Append(LIBS = [
169 'm',
170 'pthread',
171 'expat',
172 'dl',
173 ])
174
175
176 # DRI
177 if dri:
178 env.ParseConfig('pkg-config --cflags --libs libdrm')
179 env.Append(CPPDEFINES = [
180 ('USE_EXTERNAL_DXTN_LIB', '1'),
181 'IN_DRI_DRIVER',
182 'GLX_DIRECT_RENDERING',
183 'GLX_INDIRECT_RENDERING',
184 ])
185
186 # LLVM
187 if llvm:
188 # See also http://www.scons.org/wiki/UsingPkgConfig
189 env.ParseConfig('llvm-config --cflags --ldflags --libs')
190 env.Append(CPPDEFINES = ['MESA_LLVM'])
191 env.Append(CXXFLAGS = ['-Wno-long-long'])
192 # Force C++ linkage
193 env['LINK'] = env['CXX']
194
195 # libGL
196 if platform not in ('winddk',):
197 env.Append(LIBS = [
198 'X11',
199 'Xext',
200 'Xxf86vm',
201 'Xdamage',
202 'Xfixes',
203 ])
204
205 # for debugging
206 #print env.Dump()
207
208 Export('env')
209
210
211 #######################################################################
212 # Invoke SConscripts
213
214 # TODO: Build several variants at the same time?
215 # http://www.scons.org/wiki/SimultaneousVariantBuilds
216
217 SConscript(
218 'src/SConscript',
219 build_dir = common.make_build_dir(env),
220 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
221 )