Merge branch 'gallium-0.1' into gallium-tex-surfaces
[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 ('windows', '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 if platform == 'winddk':
88 env.Tool('winddk', ['.'])
89
90 env.Append(CPPPATH = [
91 env['SDK_INC_PATH'],
92 env['DDK_INC_PATH'],
93 env['WDM_INC_PATH'],
94 env['CRT_INC_PATH'],
95 ])
96
97 common.generate(env)
98
99
100 # Includes
101 env.Append(CPPPATH = [
102 '#/include',
103 '#/src/gallium/include',
104 '#/src/gallium/auxiliary',
105 '#/src/gallium/drivers',
106 ])
107
108
109 # x86 assembly
110 if x86:
111 if gcc:
112 env.Append(CFLAGS = '-m32')
113 env.Append(CXXFLAGS = '-m32')
114
115
116 # Posix
117 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
118 env.Append(CPPDEFINES = [
119 '_POSIX_SOURCE',
120 ('_POSIX_C_SOURCE', '199309L'),
121 '_SVID_SOURCE',
122 '_BSD_SOURCE',
123 '_GNU_SOURCE',
124
125 'PTHREADS',
126 'HAVE_POSIX_MEMALIGN',
127 ])
128 env.Append(CPPPATH = ['/usr/X11R6/include'])
129 env.Append(LIBPATH = ['/usr/X11R6/lib'])
130 env.Append(LIBS = [
131 'm',
132 'pthread',
133 'expat',
134 'dl',
135 ])
136
137
138 # DRI
139 if dri:
140 env.ParseConfig('pkg-config --cflags --libs libdrm')
141 env.Append(CPPDEFINES = [
142 ('USE_EXTERNAL_DXTN_LIB', '1'),
143 'IN_DRI_DRIVER',
144 'GLX_DIRECT_RENDERING',
145 'GLX_INDIRECT_RENDERING',
146 ])
147
148 # LLVM
149 if llvm:
150 # See also http://www.scons.org/wiki/UsingPkgConfig
151 env.ParseConfig('llvm-config --cflags --ldflags --libs')
152 env.Append(CPPDEFINES = ['MESA_LLVM'])
153 # Force C++ linkage
154 env['LINK'] = env['CXX']
155
156 # libGL
157 if platform in ('linux', 'freebsd', 'darwin'):
158 env.Append(LIBS = [
159 'X11',
160 'Xext',
161 'Xxf86vm',
162 'Xdamage',
163 'Xfixes',
164 ])
165
166 # for debugging
167 #print env.Dump()
168
169 Export('env')
170
171
172 #######################################################################
173 # Invoke SConscripts
174
175 # TODO: Build several variants at the same time?
176 # http://www.scons.org/wiki/SimultaneousVariantBuilds
177
178 SConscript(
179 'src/SConscript',
180 build_dir = common.make_build_dir(env),
181 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
182 )