blob: 59d05bc54fed3c47d4296b6db99633eca00710cc [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
José Fonseca6410e942008-07-13 23:36:59 +090032default_statetrackers = 'mesa'
33
José Fonseca94090432008-02-27 17:36:28 +090034if common.default_platform in ('linux', 'freebsd', 'darwin'):
Jakob Bornecrantzd60b2c62009-06-24 02:42:41 +020035 default_drivers = 'softpipe,failover,i915simple,trace,identity'
José Fonseca58a3d7d2008-02-23 19:49:08 +090036 default_winsys = 'xlib'
José Fonseca94090432008-02-27 17:36:28 +090037elif common.default_platform in ('winddk',):
Jakob Bornecrantzd60b2c62009-06-24 02:42:41 +020038 default_drivers = 'softpipe,i915simple,trace,identity'
José Fonseca5a67df62008-06-03 00:04:19 +090039 default_winsys = 'all'
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é Fonsecae9fb90a2009-05-01 16:12:17 +010044opts = Variables('config.py')
José Fonseca13174c12008-03-03 18:52:37 +010045common.AddOptions(opts)
José Fonsecae9fb90a2009-05-01 16:12:17 +010046opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
Michel Dänzerd22bd142009-08-25 15:39:05 +020047 ['mesa', 'python', 'xorg']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010048opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
Jakob Bornecrantzd60b2c62009-06-24 02:42:41 +020049 ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace', 'r300', 'identity']))
José Fonsecae9fb90a2009-05-01 16:12:17 +010050opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
Corbin Simpsonb7ffe1e2009-04-04 00:34:10 -070051 ['xlib', 'intel', 'gdi', 'radeon']))
José Fonsecac42e6252008-01-31 13:14:35 +090052
José Fonsecae9fb90a2009-05-01 16:12:17 +010053opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
Jonathan White3c819922008-08-29 11:30:32 -060054
José Fonseca81b6a802008-02-06 14:36:50 +090055env = Environment(
José Fonsecab04aa712008-06-06 14:48:57 +090056 options = opts,
57 tools = ['gallium'],
José Fonseca2c4349a2008-07-15 07:56:42 +090058 toolpath = ['#scons'],
José Fonsecab04aa712008-06-06 14:48:57 +090059 ENV = os.environ,
60)
61
José Fonsecac42e6252008-01-31 13:14:35 +090062Help(opts.GenerateHelpText(env))
63
José Fonsecac42e6252008-01-31 13:14:35 +090064# replicate options values in local variables
65debug = env['debug']
66dri = env['dri']
José Fonsecae773a812008-02-19 10:50:39 +090067llvm = env['llvm']
José Fonsecac42e6252008-01-31 13:14:35 +090068machine = env['machine']
José Fonsecad710a7c2008-02-19 18:53:16 +090069platform = env['platform']
José Fonsecac42e6252008-01-31 13:14:35 +090070
71# derived options
72x86 = machine == 'x86'
Michel Dänzer6b69e3c2008-10-23 10:28:48 +020073ppc = machine == 'ppc'
José Fonsecad710a7c2008-02-19 18:53:16 +090074gcc = platform in ('linux', 'freebsd', 'darwin')
José Fonseca35460fc2008-04-25 18:16:25 +090075msvc = platform in ('windows', 'winddk')
José Fonsecac42e6252008-01-31 13:14:35 +090076
77Export([
78 'debug',
79 'x86',
Michel Dänzer6b69e3c2008-10-23 10:28:48 +020080 'ppc',
José Fonsecac42e6252008-01-31 13:14:35 +090081 'dri',
José Fonsecae773a812008-02-19 10:50:39 +090082 'llvm',
José Fonsecac42e6252008-01-31 13:14:35 +090083 'platform',
84 'gcc',
85 'msvc',
86])
87
88
89#######################################################################
90# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +090091
92# Includes
93env.Append(CPPPATH = [
94 '#/include',
José Fonseca33ceb672008-02-18 10:52:44 +000095 '#/src/gallium/include',
96 '#/src/gallium/auxiliary',
97 '#/src/gallium/drivers',
José Fonsecac42e6252008-01-31 13:14:35 +090098])
99
100
José Fonseca00137962008-02-07 19:59:17 +0900101# Posix
102if platform in ('posix', 'linux', 'freebsd', 'darwin'):
103 env.Append(CPPDEFINES = [
104 '_POSIX_SOURCE',
105 ('_POSIX_C_SOURCE', '199309L'),
106 '_SVID_SOURCE',
107 '_BSD_SOURCE',
108 '_GNU_SOURCE',
109
110 'PTHREADS',
111 'HAVE_POSIX_MEMALIGN',
112 ])
113 env.Append(CPPPATH = ['/usr/X11R6/include'])
114 env.Append(LIBPATH = ['/usr/X11R6/lib'])
115 env.Append(LIBS = [
116 'm',
117 'pthread',
118 'expat',
119 'dl',
120 ])
121
José Fonsecac42e6252008-01-31 13:14:35 +0900122
123# DRI
124if dri:
125 env.ParseConfig('pkg-config --cflags --libs libdrm')
126 env.Append(CPPDEFINES = [
127 ('USE_EXTERNAL_DXTN_LIB', '1'),
128 'IN_DRI_DRIVER',
129 'GLX_DIRECT_RENDERING',
130 'GLX_INDIRECT_RENDERING',
131 ])
132
José Fonsecae773a812008-02-19 10:50:39 +0900133# LLVM
134if llvm:
135 # See also http://www.scons.org/wiki/UsingPkgConfig
Michel Dänzer2b6235c2009-03-09 17:46:49 +0100136 env.ParseConfig('llvm-config --cflags --ldflags --libs backend bitreader engine instrumentation interpreter ipo')
José Fonsecae773a812008-02-19 10:50:39 +0900137 env.Append(CPPDEFINES = ['MESA_LLVM'])
Michel Dänzer72c9d4a2008-03-04 18:28:23 +0100138 # Force C++ linkage
José Fonseca9a767982008-03-04 12:40:18 +0100139 env['LINK'] = env['CXX']
José Fonsecae773a812008-02-19 10:50:39 +0900140
José Fonsecac42e6252008-01-31 13:14:35 +0900141# libGL
José Fonsecaa7ce6d32008-04-25 19:53:13 +0900142if platform in ('linux', 'freebsd', 'darwin'):
José Fonsecac42e6252008-01-31 13:14:35 +0900143 env.Append(LIBS = [
144 'X11',
145 'Xext',
146 'Xxf86vm',
147 'Xdamage',
148 'Xfixes',
149 ])
150
José Fonseca4f17bd22008-03-12 13:34:30 +0000151# for debugging
152#print env.Dump()
153
José Fonsecac42e6252008-01-31 13:14:35 +0900154Export('env')
155
156
157#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900158# Invoke SConscripts
159
José Fonsecaf4192cb42008-01-31 14:21:49 +0900160# TODO: Build several variants at the same time?
161# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900162
163SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000164 'src/SConscript',
José Fonseca9bf83fb2009-01-24 15:56:28 +0000165 variant_dir = env['build'],
José Fonsecac42e6252008-01-31 13:14:35 +0900166 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
167)