blob: c1dc62465191eb1794a076e3f4d0c756f2ad66e5 [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'):
José Fonsecaf52db6c2008-08-21 01:41:20 +010035 default_drivers = 'softpipe,failover,i915simple,i965simple,trace'
José Fonseca58a3d7d2008-02-23 19:49:08 +090036 default_winsys = 'xlib'
José Fonseca94090432008-02-27 17:36:28 +090037elif common.default_platform in ('winddk',):
José Fonsecaf52db6c2008-08-21 01:41:20 +010038 default_drivers = 'softpipe,i915simple,trace'
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é Fonseca13174c12008-03-03 18:52:37 +010044opts = Options('config.py')
45common.AddOptions(opts)
José Fonsecafb4361a2008-06-27 12:35:18 +090046opts.Add(ListOption('statetrackers', 'state trackers to build', default_statetrackers,
José Fonseca6410e942008-07-13 23:36:59 +090047 ['mesa', 'python']))
José Fonseca58a3d7d2008-02-23 19:49:08 +090048opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers,
José Fonseca35355f72008-08-06 21:36:25 +010049 ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace']))
José Fonseca58a3d7d2008-02-23 19:49:08 +090050opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys,
José Fonseca5a67df62008-06-03 00:04:19 +090051 ['xlib', 'intel', 'gdi']))
José Fonsecac42e6252008-01-31 13:14:35 +090052
Jonathan White3c819922008-08-29 11:30:32 -060053opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
54
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'
José Fonsecad710a7c2008-02-19 18:53:16 +090073gcc = platform in ('linux', 'freebsd', 'darwin')
José Fonseca35460fc2008-04-25 18:16:25 +090074msvc = platform in ('windows', 'winddk')
José Fonsecac42e6252008-01-31 13:14:35 +090075
76Export([
77 'debug',
78 'x86',
79 'dri',
José Fonsecae773a812008-02-19 10:50:39 +090080 'llvm',
José Fonsecac42e6252008-01-31 13:14:35 +090081 'platform',
82 'gcc',
83 'msvc',
84])
85
86
87#######################################################################
88# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +090089
90# Includes
91env.Append(CPPPATH = [
92 '#/include',
José Fonseca33ceb672008-02-18 10:52:44 +000093 '#/src/gallium/include',
94 '#/src/gallium/auxiliary',
95 '#/src/gallium/drivers',
José Fonsecac42e6252008-01-31 13:14:35 +090096])
97
98
José Fonseca00137962008-02-07 19:59:17 +090099# Posix
100if platform in ('posix', 'linux', 'freebsd', 'darwin'):
101 env.Append(CPPDEFINES = [
102 '_POSIX_SOURCE',
103 ('_POSIX_C_SOURCE', '199309L'),
104 '_SVID_SOURCE',
105 '_BSD_SOURCE',
106 '_GNU_SOURCE',
107
108 'PTHREADS',
109 'HAVE_POSIX_MEMALIGN',
110 ])
111 env.Append(CPPPATH = ['/usr/X11R6/include'])
112 env.Append(LIBPATH = ['/usr/X11R6/lib'])
113 env.Append(LIBS = [
114 'm',
115 'pthread',
116 'expat',
117 'dl',
118 ])
119
José Fonsecac42e6252008-01-31 13:14:35 +0900120
121# DRI
122if dri:
123 env.ParseConfig('pkg-config --cflags --libs libdrm')
124 env.Append(CPPDEFINES = [
125 ('USE_EXTERNAL_DXTN_LIB', '1'),
126 'IN_DRI_DRIVER',
127 'GLX_DIRECT_RENDERING',
128 'GLX_INDIRECT_RENDERING',
129 ])
130
José Fonsecae773a812008-02-19 10:50:39 +0900131# LLVM
132if llvm:
133 # See also http://www.scons.org/wiki/UsingPkgConfig
134 env.ParseConfig('llvm-config --cflags --ldflags --libs')
135 env.Append(CPPDEFINES = ['MESA_LLVM'])
Michel Dänzer72c9d4a2008-03-04 18:28:23 +0100136 # Force C++ linkage
José Fonseca9a767982008-03-04 12:40:18 +0100137 env['LINK'] = env['CXX']
José Fonsecae773a812008-02-19 10:50:39 +0900138
José Fonsecac42e6252008-01-31 13:14:35 +0900139# libGL
José Fonsecaa7ce6d32008-04-25 19:53:13 +0900140if platform in ('linux', 'freebsd', 'darwin'):
José Fonsecac42e6252008-01-31 13:14:35 +0900141 env.Append(LIBS = [
142 'X11',
143 'Xext',
144 'Xxf86vm',
145 'Xdamage',
146 'Xfixes',
147 ])
148
José Fonseca4f17bd22008-03-12 13:34:30 +0000149# for debugging
150#print env.Dump()
151
José Fonsecac42e6252008-01-31 13:14:35 +0900152Export('env')
153
154
155#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900156# Invoke SConscripts
157
José Fonsecaf4192cb42008-01-31 14:21:49 +0900158# TODO: Build several variants at the same time?
159# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900160
161SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000162 'src/SConscript',
José Fonsecab04aa712008-06-06 14:48:57 +0900163 build_dir = env['build'],
José Fonsecac42e6252008-01-31 13:14:35 +0900164 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
165)