scons: Revamp how to specify targets to build.
[mesa.git] / SConstruct
1 #######################################################################
2 # Top-level SConstruct
3 #
4 # For example, invoke scons as
5 #
6 # scons build=debug llvm=yes machine=x86
7 #
8 # to set configuration variables. Or you can write those options to a file
9 # named config.py:
10 #
11 # # config.py
12 # build='debug'
13 # llvm=True
14 # machine='x86'
15 #
16 # Invoke
17 #
18 # scons -h
19 #
20 # to get the full list of options. See scons manpage for more info.
21 #
22
23 import os
24 import os.path
25 import sys
26 import SCons.Util
27
28 import common
29
30 #######################################################################
31 # Configuration options
32
33 opts = Variables('config.py')
34 common.AddOptions(opts)
35 opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
36
37 env = Environment(
38 options = opts,
39 tools = ['gallium'],
40 toolpath = ['#scons'],
41 ENV = os.environ,
42 )
43
44 # Backwards compatability with old target configuration variable
45 try:
46 targets = ARGUMENTS['targets']
47 except KeyError:
48 pass
49 else:
50 targets = targets.split(',')
51 print 'scons: warning: targets option is deprecated; pass the targets on their own such as'
52 print
53 print ' scons %s' % ' '.join(targets)
54 print
55 COMMAND_LINE_TARGETS.append(targets)
56
57
58 Help(opts.GenerateHelpText(env))
59
60
61 #######################################################################
62 # Environment setup
63
64 # Includes
65 env.Prepend(CPPPATH = [
66 '#/include',
67 ])
68 env.Append(CPPPATH = [
69 '#/src/gallium/include',
70 '#/src/gallium/auxiliary',
71 '#/src/gallium/drivers',
72 '#/src/gallium/winsys',
73 ])
74
75 if env['msvc']:
76 env.Append(CPPPATH = ['#include/c99'])
77
78 # Embedded
79 if env['platform'] == 'embedded':
80 env.Append(CPPDEFINES = [
81 '_POSIX_SOURCE',
82 ('_POSIX_C_SOURCE', '199309L'),
83 '_SVID_SOURCE',
84 '_BSD_SOURCE',
85 '_GNU_SOURCE',
86
87 'PTHREADS',
88 ])
89 env.Append(LIBS = [
90 'm',
91 'pthread',
92 'dl',
93 ])
94
95 # Posix
96 if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
97 env.Append(CPPDEFINES = [
98 '_POSIX_SOURCE',
99 ('_POSIX_C_SOURCE', '199309L'),
100 '_SVID_SOURCE',
101 '_BSD_SOURCE',
102 '_GNU_SOURCE',
103 'PTHREADS',
104 'HAVE_POSIX_MEMALIGN',
105 ])
106 if env['gcc']:
107 env.Append(CFLAGS = ['-fvisibility=hidden'])
108 if env['platform'] == 'darwin':
109 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
110 env.Append(LIBS = [
111 'm',
112 'pthread',
113 'dl',
114 ])
115
116 # for debugging
117 #print env.Dump()
118
119 Export('env')
120
121
122 #######################################################################
123 # Invoke SConscripts
124
125 # TODO: Build several variants at the same time?
126 # http://www.scons.org/wiki/SimultaneousVariantBuilds
127
128 SConscript(
129 'src/SConscript',
130 variant_dir = env['build_dir'],
131 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
132 )
133