blob: 13a2e6a7a2c91715f3f43138b917f33ad91a3b5e [file] [log] [blame]
José Fonsecac42e6252008-01-31 13:14:35 +09001#######################################################################
José Fonseca33ceb672008-02-18 10:52:44 +00002# SConscript for Mesa
José Fonsecac42e6252008-01-31 13:14:35 +09003
4
5Import('*')
Brian Pauldff36e92012-05-30 10:08:11 -06006from sys import executable as python_cmd
José Fonsecac42e6252008-01-31 13:14:35 +09007
José Fonseca601498a2010-11-01 13:30:22 +00008env = env.Clone()
José Fonsecab9da3792008-02-19 15:07:53 +09009
Jose Fonseca00faf9f2015-03-04 14:23:52 +000010env.MSVC2013Compat()
11
José Fonseca601498a2010-11-01 13:30:22 +000012env.Append(CPPPATH = [
Rob Clark1e93b0c2015-12-21 21:34:11 -050013 '../compiler/nir', # for generated nir_opcodes.h, etc
Kenneth Graunke1e0da622014-02-24 23:39:14 -080014 '#/src',
Emil Velikov1c7c0d72016-07-18 19:23:02 +010015 Dir('../mapi'), # src/mapi build path
José Fonseca601498a2010-11-01 13:30:22 +000016 '#/src/mapi',
Emil Velikov1c7c0d72016-07-18 19:23:02 +010017 Dir('.'), # src/mesa build path
José Fonseca601498a2010-11-01 13:30:22 +000018 '#/src/mesa',
Emil Velikov1c7c0d72016-07-18 19:23:02 +010019 Dir('main'), # src/mesa/main/ build path
Brian Paulace31242016-06-15 10:42:34 -060020 '#/src/mesa/main',
Eric Anholte8c5cbf2015-02-11 14:18:50 -080021 '#/src/gallium/include',
22 '#/src/gallium/auxiliary',
José Fonseca601498a2010-11-01 13:30:22 +000023])
José Fonseca2105b612009-01-06 16:20:12 +000024
José Fonseca601498a2010-11-01 13:30:22 +000025if env['platform'] == 'windows':
26 env.Append(CPPDEFINES = [
27 '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
28 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
José Fonseca601498a2010-11-01 13:30:22 +000029 ])
Chia-I Wubb770af2011-01-14 17:50:29 +080030 if not env['gles']:
31 # prevent _glapi_* from being declared __declspec(dllimport)
32 env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
Chia-I Wubb045d32010-11-20 17:47:11 -080033else:
34 env.Append(CPPDEFINES = [
Tapani Pälli91214602012-08-28 14:01:51 +030035 ('HAVE_DLOPEN', '1'),
Chia-I Wubb045d32010-11-20 17:47:11 -080036 ])
José Fonseca5c9c6b02008-06-04 23:56:57 +090037
Jason Ekstranddcc29c12014-07-23 17:20:12 -070038# parse Makefile.sources
39source_lists = env.ParseSourceList('Makefile.sources')
José Fonseca601498a2010-11-01 13:30:22 +000040
Jose Fonseca31e47a52015-03-19 13:35:18 +000041env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_'])
Jose Fonsecad3e9aa82015-03-18 14:22:41 +000042env.CFile('program/lex.yy.c', 'program/program_lexer.l')
43env.CFile('program/program_parse.tab.c', 'program/program_parse.y')
José Fonseca601498a2010-11-01 13:30:22 +000044
45mesa_sources = (
Jason Ekstranddcc29c12014-07-23 17:20:12 -070046 source_lists['MESA_FILES'] +
Jose Fonsecad3e9aa82015-03-18 14:22:41 +000047 source_lists['PROGRAM_FILES'] +
Jason Ekstranddcc29c12014-07-23 17:20:12 -070048 source_lists['STATETRACKER_FILES']
José Fonseca601498a2010-11-01 13:30:22 +000049)
50
Brian Pauldff36e92012-05-30 10:08:11 -060051GLAPI = '#src/mapi/glapi/'
52
Imre Deak98f880e2012-09-10 08:46:13 +030053get_hash_header = env.CodeGenerate(
54 target = 'main/get_hash.h',
55 script = 'main/get_hash_generator.py',
Jose Fonseca09dafb92016-08-27 21:30:38 +010056 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
Brian Paul815ca0b2013-04-17 09:49:39 -060057 command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET'
Imre Deak98f880e2012-09-10 08:46:13 +030058)
59
Jason Ekstrand12610ff2014-06-20 15:52:10 -070060format_info = env.CodeGenerate(
Emil Velikov3f6c28f2015-03-02 15:58:17 +000061 target = 'main/format_info.h',
Jason Ekstrand12610ff2014-06-20 15:52:10 -070062 script = 'main/format_info.py',
63 source = 'main/formats.csv',
64 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
65)
66
Jason Ekstrande0439f72014-08-21 12:38:05 -070067format_pack = env.CodeGenerate(
68 target = 'main/format_pack.c',
69 script = 'main/format_pack.py',
70 source = 'main/formats.csv',
71 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
72)
73
Jason Ekstrande1fdcdd2014-08-22 09:49:09 -070074format_unpack = env.CodeGenerate(
75 target = 'main/format_unpack.c',
76 script = 'main/format_unpack.py',
77 source = 'main/formats.csv',
78 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
79)
80
José Fonseca601498a2010-11-01 13:30:22 +000081#
82# Assembly sources
83#
Jose Fonseca9a25c8a2016-04-18 11:47:07 +010084if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
José Fonsecaf9156eb2010-11-01 13:56:16 +000085 if env['machine'] == 'x86':
86 env.Append(CPPDEFINES = [
87 'USE_X86_ASM',
88 'USE_MMX_ASM',
89 'USE_3DNOW_ASM',
90 'USE_SSE_ASM',
91 ])
Jason Ekstranddcc29c12014-07-23 17:20:12 -070092 mesa_sources += source_lists['X86_FILES']
José Fonsecaf9156eb2010-11-01 13:56:16 +000093 elif env['machine'] == 'x86_64':
94 env.Append(CPPDEFINES = [
95 'USE_X86_64_ASM',
96 ])
Jason Ekstranddcc29c12014-07-23 17:20:12 -070097 mesa_sources += source_lists['X86_64_FILES']
José Fonsecaf9156eb2010-11-01 13:56:16 +000098 elif env['machine'] == 'sparc':
Jason Ekstranddcc29c12014-07-23 17:20:12 -070099 mesa_sources += source_lists['SPARC_FILES']
José Fonsecaf9156eb2010-11-01 13:56:16 +0000100 else:
101 pass
José Fonseca601498a2010-11-01 13:30:22 +0000102
José Fonsecaf9156eb2010-11-01 13:56:16 +0000103 # Generate matypes.h
104 if env['machine'] in ('x86', 'x86_64'):
105 # See http://www.scons.org/wiki/UsingCodeGenerators
106 gen_matypes = env.Program(
107 target = 'gen_matypes',
108 source = 'x86/gen_matypes.c',
109 )
110 matypes = env.Command(
111 'matypes.h',
112 gen_matypes,
113 gen_matypes[0].abspath + ' > $TARGET',
114 )
115 # Add the dir containing the generated header (somewhere inside the
116 # build dir) to the include path
Emil Velikov1c7c0d72016-07-18 19:23:02 +0100117 env.Prepend(CPPPATH = [matypes[0].dir])
José Fonseca601498a2010-11-01 13:30:22 +0000118
Brian Paul0c245502011-04-05 14:07:41 -0600119
José Fonseca601498a2010-11-01 13:30:22 +0000120#
121# Libraries
122#
123
124mesa = env.ConvenienceLibrary(
125 target = 'mesa',
126 source = mesa_sources,
127)
128
129env.Alias('mesa', mesa)
130
131Export('mesa')
José Fonseca8e8a56e2011-04-23 12:22:59 +0100132
133SConscript('drivers/SConscript')