blob: fe27ceafe7b8bf90a7ecaf5a137d87dd99f23ec9 [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é Fonseca58a3d7d2008-02-23 19:49:08 +090035 default_drivers = 'softpipe,failover,i915simple,i965simple'
36 default_winsys = 'xlib'
José Fonseca94090432008-02-27 17:36:28 +090037elif common.default_platform in ('winddk',):
José Fonseca58a3d7d2008-02-23 19:49:08 +090038 default_drivers = 'softpipe,i915simple'
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é 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é Fonseca5a67df62008-06-03 00:04:19 +090051 ['xlib', 'intel', 'gdi']))
José Fonsecac42e6252008-01-31 13:14:35 +090052
José Fonseca81b6a802008-02-06 14:36:50 +090053env = Environment(
José Fonsecab04aa712008-06-06 14:48:57 +090054 options = opts,
55 tools = ['gallium'],
José Fonseca2c4349a2008-07-15 07:56:42 +090056 toolpath = ['#scons'],
José Fonsecab04aa712008-06-06 14:48:57 +090057 ENV = os.environ,
58)
59
José Fonsecac42e6252008-01-31 13:14:35 +090060Help(opts.GenerateHelpText(env))
61
José Fonsecac42e6252008-01-31 13:14:35 +090062# replicate options values in local variables
63debug = env['debug']
64dri = env['dri']
José Fonsecae773a812008-02-19 10:50:39 +090065llvm = env['llvm']
José Fonsecac42e6252008-01-31 13:14:35 +090066machine = env['machine']
José Fonsecad710a7c2008-02-19 18:53:16 +090067platform = env['platform']
José Fonsecac42e6252008-01-31 13:14:35 +090068
69# derived options
70x86 = machine == 'x86'
José Fonsecad710a7c2008-02-19 18:53:16 +090071gcc = platform in ('linux', 'freebsd', 'darwin')
José Fonseca35460fc2008-04-25 18:16:25 +090072msvc = platform in ('windows', 'winddk')
José Fonsecac42e6252008-01-31 13:14:35 +090073
74Export([
75 'debug',
76 'x86',
77 'dri',
José Fonsecae773a812008-02-19 10:50:39 +090078 'llvm',
José Fonsecac42e6252008-01-31 13:14:35 +090079 'platform',
80 'gcc',
81 'msvc',
82])
83
84
85#######################################################################
86# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +090087
88# Includes
89env.Append(CPPPATH = [
90 '#/include',
José Fonseca33ceb672008-02-18 10:52:44 +000091 '#/src/gallium/include',
92 '#/src/gallium/auxiliary',
93 '#/src/gallium/drivers',
José Fonsecac42e6252008-01-31 13:14:35 +090094])
95
96
José Fonseca00137962008-02-07 19:59:17 +090097# Posix
98if 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
José Fonsecac42e6252008-01-31 13:14:35 +0900118
119# DRI
120if 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
José Fonsecae773a812008-02-19 10:50:39 +0900129# LLVM
130if llvm:
131 # See also http://www.scons.org/wiki/UsingPkgConfig
132 env.ParseConfig('llvm-config --cflags --ldflags --libs')
133 env.Append(CPPDEFINES = ['MESA_LLVM'])
Michel Dänzer72c9d4a2008-03-04 18:28:23 +0100134 # Force C++ linkage
José Fonseca9a767982008-03-04 12:40:18 +0100135 env['LINK'] = env['CXX']
José Fonsecae773a812008-02-19 10:50:39 +0900136
José Fonsecac42e6252008-01-31 13:14:35 +0900137# libGL
José Fonsecaa7ce6d32008-04-25 19:53:13 +0900138if platform in ('linux', 'freebsd', 'darwin'):
José Fonsecac42e6252008-01-31 13:14:35 +0900139 env.Append(LIBS = [
140 'X11',
141 'Xext',
142 'Xxf86vm',
143 'Xdamage',
144 'Xfixes',
145 ])
146
José Fonseca4f17bd22008-03-12 13:34:30 +0000147# for debugging
148#print env.Dump()
149
José Fonsecac42e6252008-01-31 13:14:35 +0900150Export('env')
151
152
153#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900154# Invoke SConscripts
155
José Fonsecaf4192cb42008-01-31 14:21:49 +0900156# TODO: Build several variants at the same time?
157# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900158
159SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000160 'src/SConscript',
José Fonsecab04aa712008-06-06 14:48:57 +0900161 build_dir = env['build'],
José Fonsecac42e6252008-01-31 13:14:35 +0900162 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
163)