getopt: Make code more portable.
[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
36 env = Environment(
37 options = opts,
38 tools = ['gallium'],
39 toolpath = ['#scons'],
40 ENV = os.environ,
41 )
42
43 # Backwards compatability with old target configuration variable
44 try:
45 targets = ARGUMENTS['targets']
46 except KeyError:
47 pass
48 else:
49 targets = targets.split(',')
50 print 'scons: warning: targets option is deprecated; pass the targets on their own such as'
51 print
52 print ' scons %s' % ' '.join(targets)
53 print
54 COMMAND_LINE_TARGETS.append(targets)
55
56
57 Help(opts.GenerateHelpText(env))
58
59
60 #######################################################################
61 # Environment setup
62
63 # Includes
64 env.Prepend(CPPPATH = [
65 '#/include',
66 ])
67 env.Append(CPPPATH = [
68 '#/src/gallium/include',
69 '#/src/gallium/auxiliary',
70 '#/src/gallium/drivers',
71 '#/src/gallium/winsys',
72 ])
73
74 if env['msvc']:
75 env.Append(CPPPATH = ['#include/c99'])
76
77 # Embedded
78 if env['platform'] == 'embedded':
79 env.Append(CPPDEFINES = [
80 '_POSIX_SOURCE',
81 ('_POSIX_C_SOURCE', '199309L'),
82 '_SVID_SOURCE',
83 '_BSD_SOURCE',
84 '_GNU_SOURCE',
85
86 'PTHREADS',
87 ])
88 env.Append(LIBS = [
89 'm',
90 'pthread',
91 'dl',
92 ])
93
94 # Posix
95 if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
96 env.Append(CPPDEFINES = [
97 '_POSIX_SOURCE',
98 ('_POSIX_C_SOURCE', '199309L'),
99 '_SVID_SOURCE',
100 '_BSD_SOURCE',
101 '_GNU_SOURCE',
102 'PTHREADS',
103 'HAVE_POSIX_MEMALIGN',
104 ])
105 if env['gcc']:
106 env.Append(CFLAGS = ['-fvisibility=hidden'])
107 if env['platform'] == 'darwin':
108 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
109 env.Append(LIBS = [
110 'm',
111 'pthread',
112 'dl',
113 ])
114
115 # for debugging
116 #print env.Dump()
117
118 Export('env')
119
120
121 #######################################################################
122 # Invoke SConscripts
123
124 # TODO: Build several variants at the same time?
125 # http://www.scons.org/wiki/SimultaneousVariantBuilds
126
127 SConscript(
128 'src/SConscript',
129 variant_dir = env['build_dir'],
130 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
131 )
132