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 | |
| 32 | if common.default_platform in ('linux', 'freebsd', 'darwin'): |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 33 | default_statetrackers = 'mesa' |
| 34 | default_drivers = 'softpipe,failover,i915simple,i965simple' |
| 35 | default_winsys = 'xlib' |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 36 | elif common.default_platform in ('winddk',): |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 37 | default_statetrackers = 'none' |
| 38 | default_drivers = 'softpipe,i915simple' |
| 39 | default_winsys = 'none' |
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 | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 46 | opts.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers, |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 47 | ['mesa'])) |
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 | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 51 | ['xlib', 'intel'])) |
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( |
| 54 | options = opts, |
| 55 | ENV = os.environ) |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 56 | Help(opts.GenerateHelpText(env)) |
| 57 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 58 | # replicate options values in local variables |
| 59 | debug = env['debug'] |
| 60 | dri = env['dri'] |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 61 | llvm = env['llvm'] |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 62 | machine = env['machine'] |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 63 | platform = env['platform'] |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 64 | |
| 65 | # derived options |
| 66 | x86 = machine == 'x86' |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 67 | gcc = platform in ('linux', 'freebsd', 'darwin') |
José Fonseca | 35460fc | 2008-04-25 18:16:25 +0900 | [diff] [blame] | 68 | msvc = platform in ('windows', 'winddk') |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 69 | |
| 70 | Export([ |
| 71 | 'debug', |
| 72 | 'x86', |
| 73 | 'dri', |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 74 | 'llvm', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 75 | 'platform', |
| 76 | 'gcc', |
| 77 | 'msvc', |
| 78 | ]) |
| 79 | |
| 80 | |
| 81 | ####################################################################### |
| 82 | # Environment setup |
| 83 | # |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 84 | # TODO: put the compiler specific settings in separate files |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 85 | # TODO: auto-detect as much as possible |
| 86 | |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 87 | if platform == 'winddk': |
José Fonseca | b215d7d | 2008-05-28 01:24:06 +0900 | [diff] [blame] | 88 | env.Tool('winddk', ['scons']) |
José Fonseca | efd3368 | 2008-02-25 14:46:53 +0900 | [diff] [blame] | 89 | |
| 90 | env.Append(CPPPATH = [ |
| 91 | env['SDK_INC_PATH'], |
| 92 | env['DDK_INC_PATH'], |
| 93 | env['WDM_INC_PATH'], |
| 94 | env['CRT_INC_PATH'], |
| 95 | ]) |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 96 | |
José Fonseca | b215d7d | 2008-05-28 01:24:06 +0900 | [diff] [blame] | 97 | if platform == 'wince': |
| 98 | env.Tool('evc', ['scons']) |
| 99 | |
José Fonseca | 35460fc | 2008-04-25 18:16:25 +0900 | [diff] [blame] | 100 | common.generate(env) |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 101 | |
| 102 | |
| 103 | # Includes |
| 104 | env.Append(CPPPATH = [ |
| 105 | '#/include', |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 106 | '#/src/gallium/include', |
| 107 | '#/src/gallium/auxiliary', |
| 108 | '#/src/gallium/drivers', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 109 | ]) |
| 110 | |
| 111 | |
| 112 | # x86 assembly |
| 113 | if x86: |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 114 | if gcc: |
| 115 | env.Append(CFLAGS = '-m32') |
| 116 | env.Append(CXXFLAGS = '-m32') |
| 117 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 118 | |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 119 | # Posix |
| 120 | if platform in ('posix', 'linux', 'freebsd', 'darwin'): |
| 121 | env.Append(CPPDEFINES = [ |
| 122 | '_POSIX_SOURCE', |
| 123 | ('_POSIX_C_SOURCE', '199309L'), |
| 124 | '_SVID_SOURCE', |
| 125 | '_BSD_SOURCE', |
| 126 | '_GNU_SOURCE', |
| 127 | |
| 128 | 'PTHREADS', |
| 129 | 'HAVE_POSIX_MEMALIGN', |
| 130 | ]) |
| 131 | env.Append(CPPPATH = ['/usr/X11R6/include']) |
| 132 | env.Append(LIBPATH = ['/usr/X11R6/lib']) |
| 133 | env.Append(LIBS = [ |
| 134 | 'm', |
| 135 | 'pthread', |
| 136 | 'expat', |
| 137 | 'dl', |
| 138 | ]) |
| 139 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 140 | |
| 141 | # DRI |
| 142 | if dri: |
| 143 | env.ParseConfig('pkg-config --cflags --libs libdrm') |
| 144 | env.Append(CPPDEFINES = [ |
| 145 | ('USE_EXTERNAL_DXTN_LIB', '1'), |
| 146 | 'IN_DRI_DRIVER', |
| 147 | 'GLX_DIRECT_RENDERING', |
| 148 | 'GLX_INDIRECT_RENDERING', |
| 149 | ]) |
| 150 | |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 151 | # LLVM |
| 152 | if llvm: |
| 153 | # See also http://www.scons.org/wiki/UsingPkgConfig |
| 154 | env.ParseConfig('llvm-config --cflags --ldflags --libs') |
| 155 | env.Append(CPPDEFINES = ['MESA_LLVM']) |
Michel Dänzer | 72c9d4a | 2008-03-04 18:28:23 +0100 | [diff] [blame] | 156 | # Force C++ linkage |
José Fonseca | 9a76798 | 2008-03-04 12:40:18 +0100 | [diff] [blame] | 157 | env['LINK'] = env['CXX'] |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 158 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 159 | # libGL |
José Fonseca | a7ce6d3 | 2008-04-25 19:53:13 +0900 | [diff] [blame] | 160 | if platform in ('linux', 'freebsd', 'darwin'): |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 161 | env.Append(LIBS = [ |
| 162 | 'X11', |
| 163 | 'Xext', |
| 164 | 'Xxf86vm', |
| 165 | 'Xdamage', |
| 166 | 'Xfixes', |
| 167 | ]) |
| 168 | |
José Fonseca | 4f17bd2 | 2008-03-12 13:34:30 +0000 | [diff] [blame] | 169 | # for debugging |
| 170 | #print env.Dump() |
| 171 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 172 | Export('env') |
| 173 | |
| 174 | |
| 175 | ####################################################################### |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 176 | # Invoke SConscripts |
| 177 | |
José Fonseca | f4192cb4 | 2008-01-31 14:21:49 +0900 | [diff] [blame] | 178 | # TODO: Build several variants at the same time? |
| 179 | # http://www.scons.org/wiki/SimultaneousVariantBuilds |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 180 | |
| 181 | SConscript( |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 182 | 'src/SConscript', |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 183 | build_dir = common.make_build_dir(env), |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 184 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 185 | ) |