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 | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 35 | default_drivers = 'softpipe,failover,i915simple,i965simple' |
| 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 | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 38 | default_drivers = 'softpipe,i915simple' |
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 | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 49 | ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell'])) |
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 | |
José Fonseca | 81b6a80 | 2008-02-06 14:36:50 +0900 | [diff] [blame] | 53 | env = Environment( |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 54 | options = opts, |
| 55 | tools = ['gallium'], |
José Fonseca | 2c4349a | 2008-07-15 07:56:42 +0900 | [diff] [blame] | 56 | toolpath = ['#scons'], |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 57 | ENV = os.environ, |
| 58 | ) |
| 59 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 60 | Help(opts.GenerateHelpText(env)) |
| 61 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 62 | # replicate options values in local variables |
| 63 | debug = env['debug'] |
| 64 | dri = env['dri'] |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 65 | llvm = env['llvm'] |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 66 | machine = env['machine'] |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 67 | platform = env['platform'] |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 68 | |
| 69 | # derived options |
| 70 | x86 = machine == 'x86' |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 71 | gcc = platform in ('linux', 'freebsd', 'darwin') |
José Fonseca | 35460fc | 2008-04-25 18:16:25 +0900 | [diff] [blame] | 72 | msvc = platform in ('windows', 'winddk') |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 73 | |
| 74 | Export([ |
| 75 | 'debug', |
| 76 | 'x86', |
| 77 | 'dri', |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 78 | 'llvm', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 79 | 'platform', |
| 80 | 'gcc', |
| 81 | 'msvc', |
| 82 | ]) |
| 83 | |
| 84 | |
| 85 | ####################################################################### |
| 86 | # Environment setup |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 87 | |
| 88 | # Includes |
| 89 | env.Append(CPPPATH = [ |
| 90 | '#/include', |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 91 | '#/src/gallium/include', |
| 92 | '#/src/gallium/auxiliary', |
| 93 | '#/src/gallium/drivers', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 94 | ]) |
| 95 | |
| 96 | |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 97 | # Posix |
| 98 | if 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é Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 118 | |
| 119 | # DRI |
| 120 | if 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é Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 129 | # LLVM |
| 130 | if 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änzer | 72c9d4a | 2008-03-04 18:28:23 +0100 | [diff] [blame] | 134 | # Force C++ linkage |
José Fonseca | 9a76798 | 2008-03-04 12:40:18 +0100 | [diff] [blame] | 135 | env['LINK'] = env['CXX'] |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 136 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 137 | # libGL |
José Fonseca | a7ce6d3 | 2008-04-25 19:53:13 +0900 | [diff] [blame] | 138 | if platform in ('linux', 'freebsd', 'darwin'): |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 139 | env.Append(LIBS = [ |
| 140 | 'X11', |
| 141 | 'Xext', |
| 142 | 'Xxf86vm', |
| 143 | 'Xdamage', |
| 144 | 'Xfixes', |
| 145 | ]) |
| 146 | |
José Fonseca | 4f17bd2 | 2008-03-12 13:34:30 +0000 | [diff] [blame] | 147 | # for debugging |
| 148 | #print env.Dump() |
| 149 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 150 | Export('env') |
| 151 | |
| 152 | |
| 153 | ####################################################################### |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 154 | # Invoke SConscripts |
| 155 | |
José Fonseca | f4192cb4 | 2008-01-31 14:21:49 +0900 | [diff] [blame] | 156 | # TODO: Build several variants at the same time? |
| 157 | # http://www.scons.org/wiki/SimultaneousVariantBuilds |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 158 | |
| 159 | SConscript( |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 160 | 'src/SConscript', |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 161 | build_dir = env['build'], |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 162 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 163 | ) |