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'): |
José Fonseca | f52db6c | 2008-08-21 01:41:20 +0100 | [diff] [blame] | 35 | default_drivers = 'softpipe,failover,i915simple,i965simple,trace' |
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',): |
José Fonseca | f52db6c | 2008-08-21 01:41:20 +0100 | [diff] [blame] | 38 | default_drivers = 'softpipe,i915simple,trace' |
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 | 13174c1 | 2008-03-03 18:52:37 +0100 | [diff] [blame] | 44 | opts = Options('config.py') |
| 45 | common.AddOptions(opts) |
José Fonseca | fb4361a | 2008-06-27 12:35:18 +0900 | [diff] [blame] | 46 | opts.Add(ListOption('statetrackers', 'state trackers to build', default_statetrackers, |
José Fonseca | 6410e94 | 2008-07-13 23:36:59 +0900 | [diff] [blame] | 47 | ['mesa', 'python'])) |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 48 | opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers, |
José Fonseca | 35355f7 | 2008-08-06 21:36:25 +0100 | [diff] [blame] | 49 | ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace'])) |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 50 | opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys, |
José Fonseca | 5a67df6 | 2008-06-03 00:04:19 +0900 | [diff] [blame] | 51 | ['xlib', 'intel', 'gdi'])) |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 52 | |
Jonathan White | 3c81992 | 2008-08-29 11:30:32 -0600 | [diff] [blame] | 53 | opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) |
| 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' |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 73 | gcc = platform in ('linux', 'freebsd', 'darwin') |
José Fonseca | 35460fc | 2008-04-25 18:16:25 +0900 | [diff] [blame] | 74 | msvc = platform in ('windows', 'winddk') |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 75 | |
| 76 | Export([ |
| 77 | 'debug', |
| 78 | 'x86', |
| 79 | 'dri', |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 80 | 'llvm', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 81 | 'platform', |
| 82 | 'gcc', |
| 83 | 'msvc', |
| 84 | ]) |
| 85 | |
| 86 | |
| 87 | ####################################################################### |
| 88 | # Environment setup |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 89 | |
| 90 | # Includes |
| 91 | env.Append(CPPPATH = [ |
| 92 | '#/include', |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 93 | '#/src/gallium/include', |
| 94 | '#/src/gallium/auxiliary', |
| 95 | '#/src/gallium/drivers', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 96 | ]) |
| 97 | |
| 98 | |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 99 | # Posix |
| 100 | if 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é Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 120 | |
| 121 | # DRI |
| 122 | if 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é Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 131 | # LLVM |
| 132 | if 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änzer | 72c9d4a | 2008-03-04 18:28:23 +0100 | [diff] [blame] | 136 | # Force C++ linkage |
José Fonseca | 9a76798 | 2008-03-04 12:40:18 +0100 | [diff] [blame] | 137 | env['LINK'] = env['CXX'] |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 138 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 139 | # libGL |
José Fonseca | a7ce6d3 | 2008-04-25 19:53:13 +0900 | [diff] [blame] | 140 | if platform in ('linux', 'freebsd', 'darwin'): |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 141 | env.Append(LIBS = [ |
| 142 | 'X11', |
| 143 | 'Xext', |
| 144 | 'Xxf86vm', |
| 145 | 'Xdamage', |
| 146 | 'Xfixes', |
| 147 | ]) |
| 148 | |
José Fonseca | 4f17bd2 | 2008-03-12 13:34:30 +0000 | [diff] [blame] | 149 | # for debugging |
| 150 | #print env.Dump() |
| 151 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 152 | Export('env') |
| 153 | |
| 154 | |
| 155 | ####################################################################### |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 156 | # Invoke SConscripts |
| 157 | |
José Fonseca | f4192cb4 | 2008-01-31 14:21:49 +0900 | [diff] [blame] | 158 | # TODO: Build several variants at the same time? |
| 159 | # http://www.scons.org/wiki/SimultaneousVariantBuilds |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 160 | |
| 161 | SConscript( |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 162 | 'src/SConscript', |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 163 | build_dir = env['build'], |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 164 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 165 | ) |