OSDN Git Service

scons: Add -fvisibility=hidden to CFLAGS for gcc builds
[android-x86/external-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 import SCons.Util
27
28 import common
29
30 #######################################################################
31 # Configuration options
32
33 default_statetrackers = 'mesa'
34
35 if common.default_platform in ('linux', 'freebsd', 'darwin'):
36         default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe'
37         default_winsys = 'xlib'
38 elif common.default_platform in ('winddk',):
39         default_drivers = 'softpipe,svga,i915,i965,trace,identity'
40         default_winsys = 'all'
41 elif common.default_platform in ('embedded',):
42         default_drivers = 'softpipe,llvmpipe'
43         default_winsys = 'xlib'
44 else:
45         default_drivers = 'all'
46         default_winsys = 'all'
47
48 opts = Variables('config.py')
49 common.AddOptions(opts)
50 opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
51                      ['mesa', 'python', 'xorg']))
52 opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
53                      ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx']))
54 opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
55                      ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib']))
56
57 opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
58
59 env = Environment(
60         options = opts,
61         tools = ['gallium'],
62         toolpath = ['#scons'],  
63         ENV = os.environ,
64 )
65
66 if os.environ.has_key('CC'):
67         env['CC'] = os.environ['CC']
68 if os.environ.has_key('CFLAGS'):
69         env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
70 if os.environ.has_key('CXX'):
71         env['CXX'] = os.environ['CXX']
72 if os.environ.has_key('CXXFLAGS'):
73         env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
74 if os.environ.has_key('LDFLAGS'):
75         env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
76
77 Help(opts.GenerateHelpText(env))
78
79 # replicate options values in local variables
80 debug = env['debug']
81 dri = env['dri']
82 machine = env['machine']
83 platform = env['platform']
84
85 # derived options
86 x86 = machine == 'x86'
87 ppc = machine == 'ppc'
88 gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
89 msvc = platform in ('windows', 'winddk')
90
91 Export([
92         'debug', 
93         'x86', 
94         'ppc', 
95         'dri', 
96         'platform',
97         'gcc',
98         'msvc',
99 ])
100
101
102 #######################################################################
103 # Environment setup
104
105 # Always build trace, rbug, identity, softpipe, and llvmpipe (where possible)
106 if 'trace' not in env['drivers']:
107     env['drivers'].append('trace')
108 if 'rbug' not in env['drivers']:
109     env['drivers'].append('rbug')
110 if 'identity' not in env['drivers']:
111     env['drivers'].append('identity')
112 if 'softpipe' not in env['drivers']:
113     env['drivers'].append('softpipe')
114 if env['llvm'] and 'llvmpipe' not in env['drivers']:
115     env['drivers'].append('llvmpipe')
116
117 # Includes
118 env.Prepend(CPPPATH = [
119         '#/include',
120 ])
121 env.Append(CPPPATH = [
122         '#/src/gallium/include',
123         '#/src/gallium/auxiliary',
124         '#/src/gallium/drivers',
125         '#/src/gallium/winsys',
126 ])
127
128 if env['msvc']:
129     env.Append(CPPPATH = ['#include/c99'])
130
131 # Embedded
132 if platform == 'embedded':
133         env.Append(CPPDEFINES = [
134                 '_POSIX_SOURCE',
135                 ('_POSIX_C_SOURCE', '199309L'), 
136                 '_SVID_SOURCE',
137                 '_BSD_SOURCE', 
138                 '_GNU_SOURCE',
139                 
140                 'PTHREADS',
141         ])
142         env.Append(LIBS = [
143                 'm',
144                 'pthread',
145                 'dl',
146         ])
147
148 # Posix
149 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
150         env.Append(CPPDEFINES = [
151                 '_POSIX_SOURCE',
152                 ('_POSIX_C_SOURCE', '199309L'), 
153                 '_SVID_SOURCE',
154                 '_BSD_SOURCE', 
155                 '_GNU_SOURCE',
156                 'PTHREADS',
157                 'HAVE_POSIX_MEMALIGN',
158         ])
159         if gcc:
160                 env.Append(CFLAGS = ['-fvisibility=hidden'])
161         if platform == 'darwin':
162                 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
163         env.Append(LIBS = [
164                 'm',
165                 'pthread',
166                 'dl',
167         ])
168
169 # for debugging
170 #print env.Dump()
171
172 Export('env')
173
174
175 #######################################################################
176 # Invoke SConscripts
177
178 # TODO: Build several variants at the same time?
179 # http://www.scons.org/wiki/SimultaneousVariantBuilds
180
181 if env['platform'] != common.default_platform:
182     # GLSL code has to be built twice -- one for the host OS, another for the target OS...
183
184     host_env = Environment(
185         # options are ignored
186         # default tool is used
187         tools = ['default', 'custom'],
188         toolpath = ['#scons'],  
189         ENV = os.environ,
190     )
191
192     host_env['platform'] = common.default_platform
193     host_env['machine'] = common.default_machine
194     host_env['debug'] = env['debug']
195
196     SConscript(
197         'src/glsl/SConscript',
198         variant_dir = os.path.join(env['build'], 'host'),
199         duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
200         exports={'env':host_env},
201     )
202
203 SConscript(
204         'src/SConscript',
205         variant_dir = env['build'],
206         duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
207 )
208
209 env.Default('src')
210
211 SConscript(
212     'progs/SConscript',
213     variant_dir = os.path.join('progs', env['build']),
214     duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
215 )