1 #############################################################################
3 # Copyright 2008-2009 VMware, Inc.
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published
7 # by the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #############################################################################
31 default_platform = _platform_map.get(sys.platform, 'unix')
42 if 'PROCESSOR_ARCHITECTURE' in os.environ:
43 default_machine = os.environ['PROCESSOR_ARCHITECTURE']
45 default_machine = platform.machine()
46 default_machine = _machine_map.get(default_machine, 'generic')
49 vars.Add(BoolVariable('debug', 'debug build', 'no'))
50 vars.Add(EnumVariable('platform', 'target platform', default_platform,
51 allowed_values=('linux', 'freebsd', 'unix', 'other', 'windows')))
52 vars.Add(EnumVariable('machine', 'use machine-specific assembly code', default_machine,
53 allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
54 vars.Add(EnumVariable('toolchain', 'compiler toolchain', 'default',
55 allowed_values=('default', 'crossmingw', 'winsdk')))
56 vars.Add(EnumVariable('MSVS_VERSION', 'Microsoft Visual Studio version', None, allowed_values=('7.1', '8.0', '9.0')))
61 Help(vars.GenerateHelpText(env))
65 env.Tool(env['toolchain'], toolpath = ['scons'])
67 env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
68 env['msvc'] = env['CC'] == 'cl'
70 # C preprocessor options
73 cppdefines += ['NDEBUG']
74 if env['platform'] == 'windows':
80 '_CRT_SECURE_NO_DEPRECATE',
81 '_CRT_NON_CONFORMING_SWPRINTFS',
82 'WIN32_LEAN_AND_MEAN',
84 ('_WIN32_WINNT', '0x0501'), # minimum required OS version
87 cppdefines += ['_DEBUG']
88 env.Append(CPPDEFINES = cppdefines)
93 ccflags = [] # C & C++
96 ccflags += ['-O0', '-g3']
98 ccflags += ['-O3', '-g0']
99 if env['machine'] == 'x86':
101 if env['machine'] == 'x86_64':
104 # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
106 '-Werror=declaration-after-statement',
108 '-Wmissing-field-initializers',
110 '-fmessage-length=0', # be nice to Eclipse
113 '-Wmissing-prototypes',
118 '/Od', # disable optimizations
119 '/Oi', # enable intrinsic functions
120 '/Oy-', # disable frame pointer omission
121 '/GL-', # disable whole program optimization
125 '/Ox', # maximum optimizations
126 '/Oi', # enable intrinsic functions
127 '/Ot', # favor code speed
130 '/EHsc', # set exception handling model
131 '/W4', # warning level
132 #'/Wp64', # enable 64 bit porting warnings
134 # Automatic pdb generation
135 # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
136 env.EnsureSConsVersion(0, 98, 0)
137 env['PDB'] = '${TARGET.base}.pdb'
138 env.Append(CCFLAGS = ccflags)
139 env.Append(CFLAGS = cflags)
140 env.Append(CXXFLAGS = cxxflags)
142 if env['platform'] == 'windows' and env['msvc']:
143 # Choose the appropriate MSVC CRT
144 # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
146 env.Append(CCFLAGS = ['/MTd'])
147 env.Append(SHCCFLAGS = ['/LDd'])
149 env.Append(CCFLAGS = ['/MT'])
150 env.Append(SHCCFLAGS = ['/LD'])
154 if env['machine'] == 'x86':
155 env.Append(ASFLAGS = ['-m32'])
156 if env['machine'] == 'x86_64':
157 env.Append(ASFLAGS = ['-m64'])
162 if env['machine'] == 'x86':
163 linkflags += ['-m32']
164 if env['machine'] == 'x86_64':
165 linkflags += ['-m64']
166 if env['platform'] == 'windows' and env['msvc']:
168 # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
173 env.Append(LINKFLAGS = linkflags)
181 SConscript('zlib/SConscript')
183 env.Tool('dxsdk', toolpath = ['scons'])
185 conf = Configure(env)
186 has_d3d7 = conf.CheckCXXHeader('ddraw.h')
187 has_d3d8 = conf.CheckCXXHeader('d3d8.h')
188 has_d3d9 = conf.CheckCXXHeader('d3d9.h')
189 if env['toolchain'] != 'crossmingw':
190 has_d3d10 = conf.CheckCXXHeader('d3d10.h')
191 has_d3d10_1 = conf.CheckCXXHeader('d3d10_1.h')
193 # The above checks do not give reliable results for MinGW
198 if has_d3d7 and False:
200 target = 'ddraw.cpp',
201 source = ['ddraw.py', 'd3d.py', 'd3dtypes.py', 'd3dcaps.py', 'windows.py', 'base.py'],
202 action = 'python $SOURCE > $TARGET',
205 ddraw = env.SharedLibrary(
219 source = ['d3d8.py', 'd3d8types.py', 'd3d8caps.py', 'windows.py', 'base.py'],
220 action = 'python $SOURCE > $TARGET',
223 d3d8 = env.SharedLibrary(
237 source = ['d3d9.py', 'd3d9types.py', 'd3d9caps.py', 'd3dshader.py', 'windows.py', 'base.py'],
238 action = 'python $SOURCE > $TARGET',
241 d3d9 = env.SharedLibrary(
254 target = 'd3d10.cpp',
255 source = ['d3d10misc.py', 'windows.py', 'base.py'],
256 action = 'python $SOURCE > $TARGET',
259 d3d10 = env.SharedLibrary(
272 target = 'd3d10_1.cpp',
273 source = ['d3d10_1.py', 'windows.py', 'base.py'],
274 action = 'python $SOURCE > $TARGET',
277 d3d10_1 = env.SharedLibrary(
289 target = 'opengl32.cpp',
290 source = ['opengl32.py', 'gl.py', 'windows.py', 'base.py'],
291 action = 'python $SOURCE > $TARGET',
294 opengl32 = env.SharedLibrary(
303 env.Default(opengl32)
305 env.Tool('packaging')
313 SUMMARY = 'Tool to trace Direct3D & OpenGL API calls from applications.',
314 SOURCE_URL = 'http://cgit.freedesktop.org/~jrfonseca/apitrace/',
327 env.Alias('zip', zip)