mesa: add ETC1 decoding routines
[mesa.git] / src / mesa / SConscript
1 #######################################################################
2 # SConscript for Mesa
3
4
5 Import('*')
6 import filecmp
7 import os
8 import subprocess
9
10 env = env.Clone()
11
12 env.Append(CPPPATH = [
13 '#/src/mapi',
14 '#/src/glsl',
15 '#/src/mesa',
16 ])
17
18 env.Append(CPPDEFINES = [
19 'FEATURE_GL=1',
20 ])
21
22 if env['platform'] == 'windows':
23 env.Append(CPPDEFINES = [
24 '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
25 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
26 ])
27 if not env['gles']:
28 # prevent _glapi_* from being declared __declspec(dllimport)
29 env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
30 else:
31 env.Append(CPPDEFINES = [
32 'IN_DRI_DRIVER', # enable the remap table (for DRI drivers)
33 ])
34
35 #
36 # Source files
37 #
38
39 main_sources = [
40 'main/api_arrayelt.c',
41 'main/api_exec.c',
42 'main/api_loopback.c',
43 'main/api_validate.c',
44 'main/accum.c',
45 'main/arbprogram.c',
46 'main/atifragshader.c',
47 'main/attrib.c',
48 'main/arrayobj.c',
49 'main/blend.c',
50 'main/bufferobj.c',
51 'main/buffers.c',
52 'main/clear.c',
53 'main/clip.c',
54 'main/colortab.c',
55 'main/condrender.c',
56 'main/context.c',
57 'main/convolve.c',
58 'main/cpuinfo.c',
59 'main/debug.c',
60 'main/depth.c',
61 'main/depthstencil.c',
62 'main/dlist.c',
63 'main/dlopen.c',
64 'main/drawpix.c',
65 'main/drawtex.c',
66 'main/enable.c',
67 'main/enums.c',
68 'main/eval.c',
69 'main/execmem.c',
70 'main/extensions.c',
71 'main/fbobject.c',
72 'main/feedback.c',
73 'main/ff_fragment_shader.cpp',
74 'main/ffvertex_prog.c',
75 'main/fog.c',
76 'main/formats.c',
77 'main/format_unpack.c',
78 'main/framebuffer.c',
79 'main/get.c',
80 'main/getstring.c',
81 'main/hash.c',
82 'main/hint.c',
83 'main/histogram.c',
84 'main/image.c',
85 'main/imports.c',
86 'main/light.c',
87 'main/lines.c',
88 'main/matrix.c',
89 'main/mipmap.c',
90 'main/mm.c',
91 'main/multisample.c',
92 'main/nvprogram.c',
93 'main/pack.c',
94 'main/pbo.c',
95 'main/pixel.c',
96 'main/pixelstore.c',
97 'main/pixeltransfer.c',
98 'main/points.c',
99 'main/polygon.c',
100 'main/querymatrix.c',
101 'main/queryobj.c',
102 'main/rastpos.c',
103 'main/readpix.c',
104 'main/remap.c',
105 'main/renderbuffer.c',
106 'main/samplerobj.c',
107 'main/scissor.c',
108 'main/shaderapi.c',
109 'main/shaderobj.c',
110 'main/shader_query.cpp',
111 'main/shared.c',
112 'main/state.c',
113 'main/stencil.c',
114 'main/syncobj.c',
115 'main/texcompress.c',
116 'main/texcompress_rgtc.c',
117 'main/texcompress_s3tc.c',
118 'main/texcompress_fxt1.c',
119 'main/texcompress_etc.c',
120 'main/texenv.c',
121 'main/texformat.c',
122 'main/texgen.c',
123 'main/texgetimage.c',
124 'main/teximage.c',
125 'main/texobj.c',
126 'main/texpal.c',
127 'main/texparam.c',
128 'main/texstate.c',
129 'main/texstorage.c',
130 'main/texstore.c',
131 'main/texturebarrier.c',
132 'main/transformfeedback.c',
133 'main/uniform_query.cpp',
134 'main/uniforms.c',
135 'main/varray.c',
136 'main/version.c',
137 'main/viewport.c',
138 'main/vtxfmt.c',
139 ]
140
141 math_sources = [
142 'math/m_debug_clip.c',
143 'math/m_debug_norm.c',
144 'math/m_debug_xform.c',
145 'math/m_eval.c',
146 'math/m_matrix.c',
147 'math/m_translate.c',
148 'math/m_vector.c',
149 'math/m_xform.c',
150 ]
151
152 swrast_sources = [
153 'swrast/s_aaline.c',
154 'swrast/s_aatriangle.c',
155 'swrast/s_accum.c',
156 'swrast/s_alpha.c',
157 'swrast/s_atifragshader.c',
158 'swrast/s_bitmap.c',
159 'swrast/s_blend.c',
160 'swrast/s_blit.c',
161 'swrast/s_clear.c',
162 'swrast/s_copypix.c',
163 'swrast/s_context.c',
164 'swrast/s_depth.c',
165 'swrast/s_drawpix.c',
166 'swrast/s_feedback.c',
167 'swrast/s_fog.c',
168 'swrast/s_fragprog.c',
169 'swrast/s_lines.c',
170 'swrast/s_logic.c',
171 'swrast/s_masking.c',
172 'swrast/s_points.c',
173 'swrast/s_span.c',
174 'swrast/s_stencil.c',
175 'swrast/s_texcombine.c',
176 'swrast/s_texfetch.c',
177 'swrast/s_texfilter.c',
178 'swrast/s_texrender.c',
179 'swrast/s_texture.c',
180 'swrast/s_triangle.c',
181 'swrast/s_zoom.c',
182 ]
183
184 swrast_setup_sources = [
185 'swrast_setup/ss_context.c',
186 'swrast_setup/ss_triangle.c',
187 ]
188
189 tnl_sources = [
190 'tnl/t_context.c',
191 'tnl/t_pipeline.c',
192 'tnl/t_draw.c',
193 'tnl/t_rasterpos.c',
194 'tnl/t_vb_program.c',
195 'tnl/t_vb_render.c',
196 'tnl/t_vb_texgen.c',
197 'tnl/t_vb_texmat.c',
198 'tnl/t_vb_vertex.c',
199 'tnl/t_vb_fog.c',
200 'tnl/t_vb_light.c',
201 'tnl/t_vb_normals.c',
202 'tnl/t_vb_points.c',
203 'tnl/t_vp_build.c',
204 'tnl/t_vertex.c',
205 'tnl/t_vertex_sse.c',
206 'tnl/t_vertex_generic.c',
207 ]
208
209 vbo_sources = [
210 'vbo/vbo_context.c',
211 'vbo/vbo_exec.c',
212 'vbo/vbo_exec_api.c',
213 'vbo/vbo_exec_array.c',
214 'vbo/vbo_exec_draw.c',
215 'vbo/vbo_exec_eval.c',
216 'vbo/vbo_noop.c',
217 'vbo/vbo_rebase.c',
218 'vbo/vbo_split.c',
219 'vbo/vbo_split_copy.c',
220 'vbo/vbo_split_inplace.c',
221 'vbo/vbo_save.c',
222 'vbo/vbo_save_api.c',
223 'vbo/vbo_save_draw.c',
224 'vbo/vbo_save_loopback.c',
225 ]
226
227 statetracker_sources = [
228 'state_tracker/st_atom.c',
229 'state_tracker/st_atom_blend.c',
230 'state_tracker/st_atom_clip.c',
231 'state_tracker/st_atom_constbuf.c',
232 'state_tracker/st_atom_depth.c',
233 'state_tracker/st_atom_framebuffer.c',
234 'state_tracker/st_atom_msaa.c',
235 'state_tracker/st_atom_pixeltransfer.c',
236 'state_tracker/st_atom_sampler.c',
237 'state_tracker/st_atom_scissor.c',
238 'state_tracker/st_atom_shader.c',
239 'state_tracker/st_atom_rasterizer.c',
240 'state_tracker/st_atom_stipple.c',
241 'state_tracker/st_atom_texture.c',
242 'state_tracker/st_atom_viewport.c',
243 'state_tracker/st_cb_accum.c',
244 'state_tracker/st_cb_bitmap.c',
245 'state_tracker/st_cb_blit.c',
246 'state_tracker/st_cb_bufferobjects.c',
247 'state_tracker/st_cb_clear.c',
248 'state_tracker/st_cb_condrender.c',
249 'state_tracker/st_cb_flush.c',
250 'state_tracker/st_cb_drawpixels.c',
251 'state_tracker/st_cb_drawtex.c',
252 'state_tracker/st_cb_eglimage.c',
253 'state_tracker/st_cb_fbo.c',
254 'state_tracker/st_cb_feedback.c',
255 'state_tracker/st_cb_program.c',
256 'state_tracker/st_cb_queryobj.c',
257 'state_tracker/st_cb_rasterpos.c',
258 'state_tracker/st_cb_readpixels.c',
259 'state_tracker/st_cb_syncobj.c',
260 'state_tracker/st_cb_strings.c',
261 'state_tracker/st_cb_texture.c',
262 'state_tracker/st_cb_texturebarrier.c',
263 'state_tracker/st_cb_viewport.c',
264 'state_tracker/st_cb_xformfb.c',
265 'state_tracker/st_context.c',
266 'state_tracker/st_debug.c',
267 'state_tracker/st_draw.c',
268 'state_tracker/st_draw_feedback.c',
269 'state_tracker/st_extensions.c',
270 'state_tracker/st_format.c',
271 'state_tracker/st_glsl_to_tgsi.cpp',
272 'state_tracker/st_gen_mipmap.c',
273 'state_tracker/st_manager.c',
274 'state_tracker/st_mesa_to_tgsi.c',
275 'state_tracker/st_program.c',
276 'state_tracker/st_texture.c',
277 ]
278
279 env.Append(YACCFLAGS = '-d')
280 program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
281 program_parse = env.CFile('program/program_parse.tab.c',
282 'program/program_parse.y')
283
284 # Make program/program_parse.tab.h reacheable from the include path
285 env.Append(CPPPATH = [Dir('.').abspath])
286
287 program_sources = [
288 'program/arbprogparse.c',
289 'program/hash_table.c',
290 'program/ir_to_mesa.cpp',
291 'program/nvfragparse.c',
292 'program/nvvertparse.c',
293 'program/program.c',
294 'program/program_parse_extra.c',
295 'program/prog_cache.c',
296 'program/prog_execute.c',
297 'program/prog_instruction.c',
298 'program/prog_noise.c',
299 'program/prog_optimize.c',
300 'program/prog_opt_constant_fold.c',
301 'program/prog_parameter.c',
302 'program/prog_parameter_layout.c',
303 'program/prog_print.c',
304 'program/prog_statevars.c',
305 'program/programopt.c',
306 'program/sampler.cpp',
307 'program/symbol_table.c',
308 'program/string_to_uint_map.cpp',
309 program_lex,
310 program_parse[0],
311 ]
312
313 common_driver_sources = [
314 'drivers/common/driverfuncs.c',
315 'drivers/common/meta.c',
316 ]
317
318 mesa_sources = (
319 main_sources +
320 math_sources +
321 program_sources +
322 vbo_sources +
323 tnl_sources +
324 swrast_sources +
325 swrast_setup_sources +
326 common_driver_sources +
327 statetracker_sources
328 )
329
330 if env['gles']:
331 from sys import executable as python_cmd
332
333 env.Append(CPPDEFINES = ['FEATURE_ES1=1', 'FEATURE_ES2=1'])
334
335 # generate GLES sources
336 gles_sources = []
337 gles_sources += env.CodeGenerate(
338 target = 'main/api_exec_es1.c',
339 script = 'main/es_generator.py',
340 source = 'main/APIspec.xml',
341 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES1.1 > $TARGET'
342 )
343 gles_sources += env.CodeGenerate(
344 target = 'main/api_exec_es2.c',
345 script = 'main/es_generator.py',
346 source = 'main/APIspec.xml',
347 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES2.0 > $TARGET'
348 )
349
350 # generate GLES headers
351 GLAPI = '#src/mapi/glapi/'
352 gles_headers = []
353 gles_headers += env.CodeGenerate(
354 target = 'main/api_exec_es1_dispatch.h',
355 script = GLAPI + 'gen/gl_table.py',
356 source = GLAPI + 'gen/gl_and_es_API.xml',
357 command = python_cmd + ' $SCRIPT -c es1 -m remap_table -f $SOURCE > $TARGET',
358 )
359 gles_headers += env.CodeGenerate(
360 target = 'main/api_exec_es1_remap_helper.h',
361 script = GLAPI + 'gen/remap_helper.py',
362 source = GLAPI + 'gen/gl_and_es_API.xml',
363 command = python_cmd + ' $SCRIPT -c es1 -f $SOURCE > $TARGET',
364 )
365 gles_headers += env.CodeGenerate(
366 target = 'main/api_exec_es2_dispatch.h',
367 script = GLAPI + 'gen/gl_table.py',
368 source = GLAPI + 'gen/gl_and_es_API.xml',
369 command = python_cmd + ' $SCRIPT -c es2 -m remap_table -f $SOURCE > $TARGET',
370 )
371 gles_headers += env.CodeGenerate(
372 target = 'main/api_exec_es2_remap_helper.h',
373 script = GLAPI + 'gen/remap_helper.py',
374 source = GLAPI + 'gen/gl_and_es_API.xml',
375 command = python_cmd + ' $SCRIPT -c es2 -f $SOURCE > $TARGET',
376 )
377
378 env.Depends(gles_sources, gles_headers)
379
380 # gles_sources #include gles_headers with full path
381 env.Append(CPPPATH = [gles_headers[0].dir.up().up()])
382
383 mesa_sources += gles_sources
384
385 #
386 # Assembly sources
387 #
388 if env['gcc'] and env['platform'] != 'windows':
389 if env['machine'] == 'x86':
390 env.Append(CPPDEFINES = [
391 'USE_X86_ASM',
392 'USE_MMX_ASM',
393 'USE_3DNOW_ASM',
394 'USE_SSE_ASM',
395 ])
396 mesa_sources += [
397 'x86/common_x86.c',
398 'x86/x86_xform.c',
399 'x86/3dnow.c',
400 'x86/sse.c',
401 'x86/common_x86_asm.S',
402 'x86/x86_xform2.S',
403 'x86/x86_xform3.S',
404 'x86/x86_xform4.S',
405 'x86/x86_cliptest.S',
406 'x86/mmx_blend.S',
407 'x86/3dnow_xform1.S',
408 'x86/3dnow_xform2.S',
409 'x86/3dnow_xform3.S',
410 'x86/3dnow_xform4.S',
411 'x86/3dnow_normal.S',
412 'x86/sse_xform1.S',
413 'x86/sse_xform2.S',
414 'x86/sse_xform3.S',
415 'x86/sse_xform4.S',
416 'x86/sse_normal.S',
417 'x86/read_rgba_span_x86.S',
418 ]
419 elif env['machine'] == 'x86_64':
420 env.Append(CPPDEFINES = [
421 'USE_X86_64_ASM',
422 ])
423 mesa_sources += [
424 'x86-64/x86-64.c',
425 'x86-64/xform4.S',
426 ]
427 elif env['machine'] == 'ppc':
428 env.Append(CPPDEFINES = [
429 'USE_PPC_ASM',
430 'USE_VMX_ASM',
431 ])
432 mesa_sources += [
433 'ppc/common_ppc.c',
434 ]
435 elif env['machine'] == 'sparc':
436 mesa_sources += [
437 'sparc/sparc.c',
438 'sparc/clip.S',
439 'sparc/norm.S',
440 'sparc/xform.S',
441 ]
442 else:
443 pass
444
445 # Generate matypes.h
446 if env['machine'] in ('x86', 'x86_64'):
447 # See http://www.scons.org/wiki/UsingCodeGenerators
448 gen_matypes = env.Program(
449 target = 'gen_matypes',
450 source = 'x86/gen_matypes.c',
451 )
452 matypes = env.Command(
453 'matypes.h',
454 gen_matypes,
455 gen_matypes[0].abspath + ' > $TARGET',
456 )
457 # Add the dir containing the generated header (somewhere inside the
458 # build dir) to the include path
459 env.Append(CPPPATH = [matypes[0].dir])
460
461
462
463
464 def write_git_sha1_h_file(filename):
465 """Mesa looks for a git_sha1.h file at compile time in order to display
466 the current git hash id in the GL_VERSION string. This function tries
467 to retrieve the git hashid and write the header file. An empty file
468 will be created if anything goes wrong."""
469
470 args = [ 'git', 'log', '-n', '1', '--oneline' ]
471 try:
472 (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
473 except:
474 # git log command didn't work
475 if not os.path.exists(filename):
476 # create an empty file if none already exists
477 f = open(filename, "w")
478 f.close()
479 return
480
481 commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
482 tempfile = "git_sha1.h.tmp"
483 f = open(tempfile, "w")
484 f.write(commit)
485 f.close()
486 if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
487 # The filename does not exist or it's different from the new file,
488 # so replace old file with new.
489 if os.path.exists(filename):
490 os.remove(filename)
491 os.rename(tempfile, filename)
492 return
493
494
495 # Create the git_sha1.h header file
496 write_git_sha1_h_file("main/git_sha1.h")
497 # and update CPPPATH so the git_sha1.h header can be found
498 env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
499
500
501 #
502 # Libraries
503 #
504
505 mesa = env.ConvenienceLibrary(
506 target = 'mesa',
507 source = mesa_sources,
508 )
509
510 env.Alias('mesa', mesa)
511
512 Export('mesa')
513
514 SConscript('drivers/SConscript')