1 #############################################################################
3 # Copyright 2008-2009 VMware, Inc.
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 #############################################################################
37 default_platform = _platform_map.get(sys.platform, 'unix')
48 if 'PROCESSOR_ARCHITECTURE' in os.environ:
49 default_machine = os.environ['PROCESSOR_ARCHITECTURE']
51 default_machine = platform.machine()
52 default_machine = _machine_map.get(default_machine, 'generic')
55 vars.Add(BoolVariable('debug', 'debug build', 'no'))
56 vars.Add(EnumVariable('platform', 'target platform', default_platform,
57 allowed_values=('linux', 'freebsd', 'unix', 'other', 'windows')))
58 vars.Add(EnumVariable('machine', 'use machine-specific assembly code', default_machine,
59 allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
60 vars.Add(EnumVariable('toolchain', 'compiler toolchain', 'default',
61 allowed_values=('default', 'crossmingw', 'winsdk')))
62 vars.Add(EnumVariable('MSVS_VERSION', 'Microsoft Visual Studio version', None, allowed_values=('7.1', '8.0', '9.0')))
67 Help(vars.GenerateHelpText(env))
71 env.Tool(env['toolchain'], toolpath = ['scons'])
73 env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
74 env['msvc'] = env['CC'] == 'cl'
76 # C preprocessor options
79 cppdefines += ['NDEBUG']
80 if env['platform'] == 'windows':
86 '_CRT_SECURE_NO_DEPRECATE',
87 '_CRT_NON_CONFORMING_SWPRINTFS',
88 'WIN32_LEAN_AND_MEAN',
90 ('_WIN32_WINNT', '0x0501'), # minimum required OS version
93 cppdefines += ['_DEBUG']
94 env.Append(CPPDEFINES = cppdefines)
99 ccflags = [] # C & C++
102 ccflags += ['-O0', '-g3']
104 ccflags += ['-O3', '-g0']
105 if env['machine'] == 'x86':
107 if env['machine'] == 'x86_64':
110 # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
112 '-Werror=declaration-after-statement',
114 '-Wmissing-field-initializers',
116 '-fmessage-length=0', # be nice to Eclipse
119 '-Wmissing-prototypes',
124 '/Od', # disable optimizations
125 '/Oi', # enable intrinsic functions
126 '/Oy-', # disable frame pointer omission
127 '/GL-', # disable whole program optimization
131 '/Ox', # maximum optimizations
132 '/Oi', # enable intrinsic functions
133 '/Ot', # favor code speed
136 '/EHsc', # set exception handling model
137 '/W4', # warning level
138 #'/Wp64', # enable 64 bit porting warnings
140 # Automatic pdb generation
141 # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
142 env.EnsureSConsVersion(0, 98, 0)
143 env['PDB'] = '${TARGET.base}.pdb'
144 env.Append(CCFLAGS = ccflags)
145 env.Append(CFLAGS = cflags)
146 env.Append(CXXFLAGS = cxxflags)
148 if env['platform'] == 'windows' and env['msvc']:
149 # Choose the appropriate MSVC CRT
150 # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
152 env.Append(CCFLAGS = ['/MTd'])
153 env.Append(SHCCFLAGS = ['/LDd'])
155 env.Append(CCFLAGS = ['/MT'])
156 env.Append(SHCCFLAGS = ['/LD'])
160 if env['machine'] == 'x86':
161 env.Append(ASFLAGS = ['-m32'])
162 if env['machine'] == 'x86_64':
163 env.Append(ASFLAGS = ['-m64'])
168 if env['machine'] == 'x86':
169 linkflags += ['-m32']
170 if env['machine'] == 'x86_64':
171 linkflags += ['-m64']
172 if env['platform'] == 'windows' and env['msvc']:
174 # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
179 env.Append(LINKFLAGS = linkflags)
187 SConscript('zlib/SConscript')
189 env.Tool('dxsdk', toolpath = ['scons'])
191 conf = Configure(env)
192 has_d3d7 = conf.CheckCXXHeader('ddraw.h')
193 has_d3d8 = conf.CheckCXXHeader('d3d8.h')
194 has_d3d9 = conf.CheckCXXHeader('d3d9.h')
195 if env['toolchain'] != 'crossmingw':
196 has_d3d10 = conf.CheckCXXHeader('d3d10.h')
197 has_d3d10_1 = conf.CheckCXXHeader('d3d10_1.h')
199 # The above checks do not give reliable results for MinGW
204 if has_d3d7 and False:
206 target = 'ddraw.cpp',
207 source = ['ddraw.py', 'd3d.py', 'd3dtypes.py', 'd3dcaps.py', 'windows.py', 'base.py'],
208 action = 'python $SOURCE > $TARGET',
211 ddraw = env.SharedLibrary(
225 source = ['d3d8.py', 'd3d8types.py', 'd3d8caps.py', 'windows.py', 'base.py'],
226 action = 'python $SOURCE > $TARGET',
229 d3d8 = env.SharedLibrary(
243 source = ['d3d9.py', 'd3d9types.py', 'd3d9caps.py', 'd3dshader.py', 'windows.py', 'base.py'],
244 action = 'python $SOURCE > $TARGET',
247 d3d9 = env.SharedLibrary(
260 target = 'd3d10.cpp',
261 source = ['d3d10misc.py', 'windows.py', 'base.py'],
262 action = 'python $SOURCE > $TARGET',
265 d3d10 = env.SharedLibrary(
278 target = 'd3d10_1.cpp',
279 source = ['d3d10_1.py', 'windows.py', 'base.py'],
280 action = 'python $SOURCE > $TARGET',
283 d3d10_1 = env.SharedLibrary(
295 target = 'opengl32.cpp',
296 source = ['opengl32.py', 'gl.py', 'windows.py', 'base.py'],
297 action = 'python $SOURCE > $TARGET',
300 opengl32 = env.SharedLibrary(
309 env.Default(opengl32)
311 env.Tool('packaging')
319 SUMMARY = 'Tool to trace Direct3D & OpenGL API calls from applications.',
320 SOURCE_URL = 'http://code.google.com/p/jrfonseca/source/browse?repo=apitrace',
331 env.Alias('zip', zip)