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