blob: 5f7b6dd4d118444f273469e7af32ad71e68304bd [file] [log] [blame]
José Fonsecac42e6252008-01-31 13:14:35 +09001#######################################################################
2# Top-level SConstruct
José Fonsecac42e6252008-01-31 13:14:35 +09003#
4# For example, invoke scons as
5#
José Fonseca81b6a802008-02-06 14:36:50 +09006# scons debug=1 dri=0 machine=x86
José Fonsecac42e6252008-01-31 13:14:35 +09007#
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
José Fonseca81b6a802008-02-06 14:36:50 +090014# machine='x86'
José Fonsecac42e6252008-01-31 13:14:35 +090015#
16# Invoke
17#
18# scons -h
19#
20# to get the full list of options. See scons manpage for more info.
21#
22
José Fonseca94090432008-02-27 17:36:28 +090023import os
24import os.path
25import sys
José Fonsecad710a7c2008-02-19 18:53:16 +090026
José Fonseca94090432008-02-27 17:36:28 +090027import common
José Fonseca58a3d7d2008-02-23 19:49:08 +090028
José Fonseca94090432008-02-27 17:36:28 +090029#######################################################################
30# Configuration options
31
32if common.default_platform in ('linux', 'freebsd', 'darwin'):
José Fonseca58a3d7d2008-02-23 19:49:08 +090033 default_statetrackers = 'mesa'
34 default_drivers = 'softpipe,failover,i915simple,i965simple'
35 default_winsys = 'xlib'
José Fonseca94090432008-02-27 17:36:28 +090036elif common.default_platform in ('winddk',):
José Fonseca58a3d7d2008-02-23 19:49:08 +090037 default_statetrackers = 'none'
38 default_drivers = 'softpipe,i915simple'
39 default_winsys = 'none'
José Fonseca26c57d12008-02-23 00:46:40 +090040else:
José Fonseca58a3d7d2008-02-23 19:49:08 +090041 default_drivers = 'all'
42 default_winsys = 'all'
José Fonsecae70a4312008-02-24 16:43:07 +090043
José Fonseca13174c12008-03-03 18:52:37 +010044opts = Options('config.py')
45common.AddOptions(opts)
José Fonseca58a3d7d2008-02-23 19:49:08 +090046opts.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers,
José Fonseca94090432008-02-27 17:36:28 +090047 ['mesa']))
José Fonseca58a3d7d2008-02-23 19:49:08 +090048opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers,
José Fonseca94090432008-02-27 17:36:28 +090049 ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell']))
José Fonseca58a3d7d2008-02-23 19:49:08 +090050opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys,
José Fonseca94090432008-02-27 17:36:28 +090051 ['xlib', 'intel']))
José Fonsecac42e6252008-01-31 13:14:35 +090052
José Fonseca81b6a802008-02-06 14:36:50 +090053env = Environment(
54 options = opts,
55 ENV = os.environ)
José Fonsecac42e6252008-01-31 13:14:35 +090056Help(opts.GenerateHelpText(env))
57
José Fonsecac42e6252008-01-31 13:14:35 +090058# replicate options values in local variables
59debug = env['debug']
60dri = env['dri']
José Fonsecae773a812008-02-19 10:50:39 +090061llvm = env['llvm']
José Fonsecac42e6252008-01-31 13:14:35 +090062machine = env['machine']
José Fonsecad710a7c2008-02-19 18:53:16 +090063platform = env['platform']
José Fonsecac42e6252008-01-31 13:14:35 +090064
65# derived options
66x86 = machine == 'x86'
José Fonsecad710a7c2008-02-19 18:53:16 +090067gcc = platform in ('linux', 'freebsd', 'darwin')
José Fonseca35460fc2008-04-25 18:16:25 +090068msvc = platform in ('windows', 'winddk')
José Fonsecac42e6252008-01-31 13:14:35 +090069
70Export([
71 'debug',
72 'x86',
73 'dri',
José Fonsecae773a812008-02-19 10:50:39 +090074 'llvm',
José Fonsecac42e6252008-01-31 13:14:35 +090075 'platform',
76 'gcc',
77 'msvc',
78])
79
80
81#######################################################################
82# Environment setup
83#
José Fonsecad710a7c2008-02-19 18:53:16 +090084# TODO: put the compiler specific settings in separate files
José Fonsecac42e6252008-01-31 13:14:35 +090085# TODO: auto-detect as much as possible
86
José Fonsecad710a7c2008-02-19 18:53:16 +090087if platform == 'winddk':
José Fonsecab215d7d2008-05-28 01:24:06 +090088 env.Tool('winddk', ['scons'])
José Fonsecaefd33682008-02-25 14:46:53 +090089
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 ])
José Fonsecad710a7c2008-02-19 18:53:16 +090096
José Fonsecab215d7d2008-05-28 01:24:06 +090097if platform == 'wince':
98 env.Tool('evc', ['scons'])
99
José Fonseca35460fc2008-04-25 18:16:25 +0900100common.generate(env)
José Fonsecac42e6252008-01-31 13:14:35 +0900101
102
103# Includes
104env.Append(CPPPATH = [
105 '#/include',
José Fonseca33ceb672008-02-18 10:52:44 +0000106 '#/src/gallium/include',
107 '#/src/gallium/auxiliary',
108 '#/src/gallium/drivers',
José Fonsecac42e6252008-01-31 13:14:35 +0900109])
110
111
112# x86 assembly
113if x86:
José Fonsecac42e6252008-01-31 13:14:35 +0900114 if gcc:
115 env.Append(CFLAGS = '-m32')
116 env.Append(CXXFLAGS = '-m32')
117
José Fonsecac42e6252008-01-31 13:14:35 +0900118
José Fonseca00137962008-02-07 19:59:17 +0900119# Posix
120if platform in ('posix', 'linux', 'freebsd', 'darwin'):
121 env.Append(CPPDEFINES = [
122 '_POSIX_SOURCE',
123 ('_POSIX_C_SOURCE', '199309L'),
124 '_SVID_SOURCE',
125 '_BSD_SOURCE',
126 '_GNU_SOURCE',
127
128 'PTHREADS',
129 'HAVE_POSIX_MEMALIGN',
130 ])
131 env.Append(CPPPATH = ['/usr/X11R6/include'])
132 env.Append(LIBPATH = ['/usr/X11R6/lib'])
133 env.Append(LIBS = [
134 'm',
135 'pthread',
136 'expat',
137 'dl',
138 ])
139
José Fonsecac42e6252008-01-31 13:14:35 +0900140
141# DRI
142if dri:
143 env.ParseConfig('pkg-config --cflags --libs libdrm')
144 env.Append(CPPDEFINES = [
145 ('USE_EXTERNAL_DXTN_LIB', '1'),
146 'IN_DRI_DRIVER',
147 'GLX_DIRECT_RENDERING',
148 'GLX_INDIRECT_RENDERING',
149 ])
150
José Fonsecae773a812008-02-19 10:50:39 +0900151# LLVM
152if llvm:
153 # See also http://www.scons.org/wiki/UsingPkgConfig
154 env.ParseConfig('llvm-config --cflags --ldflags --libs')
155 env.Append(CPPDEFINES = ['MESA_LLVM'])
Michel Dänzer72c9d4a2008-03-04 18:28:23 +0100156 # Force C++ linkage
José Fonseca9a767982008-03-04 12:40:18 +0100157 env['LINK'] = env['CXX']
José Fonsecae773a812008-02-19 10:50:39 +0900158
José Fonsecac42e6252008-01-31 13:14:35 +0900159# libGL
José Fonsecaa7ce6d32008-04-25 19:53:13 +0900160if platform in ('linux', 'freebsd', 'darwin'):
José Fonsecac42e6252008-01-31 13:14:35 +0900161 env.Append(LIBS = [
162 'X11',
163 'Xext',
164 'Xxf86vm',
165 'Xdamage',
166 'Xfixes',
167 ])
168
José Fonseca4f17bd22008-03-12 13:34:30 +0000169# for debugging
170#print env.Dump()
171
José Fonsecac42e6252008-01-31 13:14:35 +0900172Export('env')
173
174
175#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900176# Invoke SConscripts
177
José Fonsecaf4192cb42008-01-31 14:21:49 +0900178# TODO: Build several variants at the same time?
179# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900180
181SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000182 'src/SConscript',
José Fonseca94090432008-02-27 17:36:28 +0900183 build_dir = common.make_build_dir(env),
José Fonsecac42e6252008-01-31 13:14:35 +0900184 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
185)