python: Move the python scons code to a separate tool module.
[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 default_statetrackers = 'mesa'
33
34 if common.default_platform in ('linux', 'freebsd', 'darwin'):
35 default_drivers = 'softpipe,failover,i915simple,i965simple'
36 default_winsys = 'xlib'
37 elif common.default_platform in ('winddk',):
38 default_drivers = 'softpipe,i915simple'
39 default_winsys = 'all'
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', 'python']))
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', 'gdi']))
52
53 env = Environment(
54 options = opts,
55 tools = ['gallium'],
56 toolpath = ['#scons'],
57 ENV = os.environ,
58 )
59
60 Help(opts.GenerateHelpText(env))
61
62 # replicate options values in local variables
63 debug = env['debug']
64 dri = env['dri']
65 llvm = env['llvm']
66 machine = env['machine']
67 platform = env['platform']
68
69 # derived options
70 x86 = machine == 'x86'
71 gcc = platform in ('linux', 'freebsd', 'darwin')
72 msvc = platform in ('windows', 'winddk')
73
74 Export([
75 'debug',
76 'x86',
77 'dri',
78 'llvm',
79 'platform',
80 'gcc',
81 'msvc',
82 ])
83
84
85 #######################################################################
86 # Environment setup
87
88 # Includes
89 env.Append(CPPPATH = [
90 '#/include',
91 '#/src/gallium/include',
92 '#/src/gallium/auxiliary',
93 '#/src/gallium/drivers',
94 ])
95
96
97 # Posix
98 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
99 env.Append(CPPDEFINES = [
100 '_POSIX_SOURCE',
101 ('_POSIX_C_SOURCE', '199309L'),
102 '_SVID_SOURCE',
103 '_BSD_SOURCE',
104 '_GNU_SOURCE',
105
106 'PTHREADS',
107 'HAVE_POSIX_MEMALIGN',
108 ])
109 env.Append(CPPPATH = ['/usr/X11R6/include'])
110 env.Append(LIBPATH = ['/usr/X11R6/lib'])
111 env.Append(LIBS = [
112 'm',
113 'pthread',
114 'expat',
115 'dl',
116 ])
117
118
119 # DRI
120 if dri:
121 env.ParseConfig('pkg-config --cflags --libs libdrm')
122 env.Append(CPPDEFINES = [
123 ('USE_EXTERNAL_DXTN_LIB', '1'),
124 'IN_DRI_DRIVER',
125 'GLX_DIRECT_RENDERING',
126 'GLX_INDIRECT_RENDERING',
127 ])
128
129 # LLVM
130 if llvm:
131 # See also http://www.scons.org/wiki/UsingPkgConfig
132 env.ParseConfig('llvm-config --cflags --ldflags --libs')
133 env.Append(CPPDEFINES = ['MESA_LLVM'])
134 # Force C++ linkage
135 env['LINK'] = env['CXX']
136
137 # libGL
138 if platform in ('linux', 'freebsd', 'darwin'):
139 env.Append(LIBS = [
140 'X11',
141 'Xext',
142 'Xxf86vm',
143 'Xdamage',
144 'Xfixes',
145 ])
146
147 # for debugging
148 #print env.Dump()
149
150 Export('env')
151
152
153 #######################################################################
154 # Invoke SConscripts
155
156 # TODO: Build several variants at the same time?
157 # http://www.scons.org/wiki/SimultaneousVariantBuilds
158
159 SConscript(
160 'src/SConscript',
161 build_dir = env['build'],
162 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
163 )