José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 1 | ####################################################################### |
| 2 | # Top-level SConstruct |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 3 | # |
| 4 | # For example, invoke scons as |
| 5 | # |
José Fonseca | 81b6a80 | 2008-02-06 14:36:50 +0900 | [diff] [blame] | 6 | # scons debug=1 dri=0 machine=x86 |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 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 |
José Fonseca | 81b6a80 | 2008-02-06 14:36:50 +0900 | [diff] [blame] | 14 | # machine='x86' |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 15 | # |
| 16 | # Invoke |
| 17 | # |
| 18 | # scons -h |
| 19 | # |
| 20 | # to get the full list of options. See scons manpage for more info. |
| 21 | # |
| 22 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 23 | import os |
| 24 | import os.path |
| 25 | import sys |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 26 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 27 | import common |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 28 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 29 | ####################################################################### |
| 30 | # Configuration options |
| 31 | |
José Fonseca | 6410e94 | 2008-07-13 23:36:59 +0900 | [diff] [blame] | 32 | default_statetrackers = 'mesa' |
| 33 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 34 | if common.default_platform in ('linux', 'freebsd', 'darwin'): |
Jakob Bornecrantz | d60b2c6 | 2009-06-24 02:42:41 +0200 | [diff] [blame] | 35 | default_drivers = 'softpipe,failover,i915simple,trace,identity' |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 36 | default_winsys = 'xlib' |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 37 | elif common.default_platform in ('winddk',): |
Jakob Bornecrantz | d60b2c6 | 2009-06-24 02:42:41 +0200 | [diff] [blame] | 38 | default_drivers = 'softpipe,i915simple,trace,identity' |
José Fonseca | 5a67df6 | 2008-06-03 00:04:19 +0900 | [diff] [blame] | 39 | default_winsys = 'all' |
José Fonseca | 26c57d1 | 2008-02-23 00:46:40 +0900 | [diff] [blame] | 40 | else: |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 41 | default_drivers = 'all' |
| 42 | default_winsys = 'all' |
José Fonseca | e70a431 | 2008-02-24 16:43:07 +0900 | [diff] [blame] | 43 | |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 44 | opts = Variables('config.py') |
José Fonseca | 13174c1 | 2008-03-03 18:52:37 +0100 | [diff] [blame] | 45 | common.AddOptions(opts) |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 46 | opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers, |
Michel Dänzer | d22bd14 | 2009-08-25 15:39:05 +0200 | [diff] [blame^] | 47 | ['mesa', 'python', 'xorg'])) |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 48 | opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, |
Jakob Bornecrantz | d60b2c6 | 2009-06-24 02:42:41 +0200 | [diff] [blame] | 49 | ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace', 'r300', 'identity'])) |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 50 | opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, |
Corbin Simpson | b7ffe1e | 2009-04-04 00:34:10 -0700 | [diff] [blame] | 51 | ['xlib', 'intel', 'gdi', 'radeon'])) |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 52 | |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 53 | opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) |
Jonathan White | 3c81992 | 2008-08-29 11:30:32 -0600 | [diff] [blame] | 54 | |
José Fonseca | 81b6a80 | 2008-02-06 14:36:50 +0900 | [diff] [blame] | 55 | env = Environment( |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 56 | options = opts, |
| 57 | tools = ['gallium'], |
José Fonseca | 2c4349a | 2008-07-15 07:56:42 +0900 | [diff] [blame] | 58 | toolpath = ['#scons'], |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 59 | ENV = os.environ, |
| 60 | ) |
| 61 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 62 | Help(opts.GenerateHelpText(env)) |
| 63 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 64 | # replicate options values in local variables |
| 65 | debug = env['debug'] |
| 66 | dri = env['dri'] |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 67 | llvm = env['llvm'] |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 68 | machine = env['machine'] |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 69 | platform = env['platform'] |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 70 | |
| 71 | # derived options |
| 72 | x86 = machine == 'x86' |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 73 | ppc = machine == 'ppc' |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 74 | gcc = platform in ('linux', 'freebsd', 'darwin') |
José Fonseca | 35460fc | 2008-04-25 18:16:25 +0900 | [diff] [blame] | 75 | msvc = platform in ('windows', 'winddk') |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 76 | |
| 77 | Export([ |
| 78 | 'debug', |
| 79 | 'x86', |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 80 | 'ppc', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 81 | 'dri', |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 82 | 'llvm', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 83 | 'platform', |
| 84 | 'gcc', |
| 85 | 'msvc', |
| 86 | ]) |
| 87 | |
| 88 | |
| 89 | ####################################################################### |
| 90 | # Environment setup |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 91 | |
| 92 | # Includes |
| 93 | env.Append(CPPPATH = [ |
| 94 | '#/include', |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 95 | '#/src/gallium/include', |
| 96 | '#/src/gallium/auxiliary', |
| 97 | '#/src/gallium/drivers', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 98 | ]) |
| 99 | |
| 100 | |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 101 | # Posix |
| 102 | if 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é Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 122 | |
| 123 | # DRI |
| 124 | if 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é Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 133 | # LLVM |
| 134 | if llvm: |
| 135 | # See also http://www.scons.org/wiki/UsingPkgConfig |
Michel Dänzer | 2b6235c | 2009-03-09 17:46:49 +0100 | [diff] [blame] | 136 | env.ParseConfig('llvm-config --cflags --ldflags --libs backend bitreader engine instrumentation interpreter ipo') |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 137 | env.Append(CPPDEFINES = ['MESA_LLVM']) |
Michel Dänzer | 72c9d4a | 2008-03-04 18:28:23 +0100 | [diff] [blame] | 138 | # Force C++ linkage |
José Fonseca | 9a76798 | 2008-03-04 12:40:18 +0100 | [diff] [blame] | 139 | env['LINK'] = env['CXX'] |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 140 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 141 | # libGL |
José Fonseca | a7ce6d3 | 2008-04-25 19:53:13 +0900 | [diff] [blame] | 142 | if platform in ('linux', 'freebsd', 'darwin'): |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 143 | env.Append(LIBS = [ |
| 144 | 'X11', |
| 145 | 'Xext', |
| 146 | 'Xxf86vm', |
| 147 | 'Xdamage', |
| 148 | 'Xfixes', |
| 149 | ]) |
| 150 | |
José Fonseca | 4f17bd2 | 2008-03-12 13:34:30 +0000 | [diff] [blame] | 151 | # for debugging |
| 152 | #print env.Dump() |
| 153 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 154 | Export('env') |
| 155 | |
| 156 | |
| 157 | ####################################################################### |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 158 | # Invoke SConscripts |
| 159 | |
José Fonseca | f4192cb4 | 2008-01-31 14:21:49 +0900 | [diff] [blame] | 160 | # TODO: Build several variants at the same time? |
| 161 | # http://www.scons.org/wiki/SimultaneousVariantBuilds |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 162 | |
| 163 | SConscript( |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 164 | 'src/SConscript', |
José Fonseca | 9bf83fb | 2009-01-24 15:56:28 +0000 | [diff] [blame] | 165 | variant_dir = env['build'], |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 166 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 167 | ) |