1 #############################################################################
3 # Copyright 2008 Tungsten Graphics, 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(PathVariable('dxsdk', 'DirectX SDK installation dir', os.environ.get('DXSDK_DIR', 'C:\\DXSDK')))
57 vars.Add(EnumVariable('MSVS_VERSION', 'Microsoft Visual Studio version', None, allowed_values=('7.1', '8.0', '9.0')))
62 Help(vars.GenerateHelpText(env))
66 env.Tool(env['toolchain'], ['scons'])
68 env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
69 env['msvc'] = env['CC'] == 'cl'
71 # C preprocessor options
74 cppdefines += ['NDEBUG']
75 if env['platform'] == 'windows':
81 '_CRT_SECURE_NO_DEPRECATE',
82 '_CRT_NON_CONFORMING_SWPRINTFS',
83 'WIN32_LEAN_AND_MEAN',
85 ('_WIN32_WINNT', '0x0501'), # minimum required OS version
88 cppdefines += ['_DEBUG']
89 env.Append(CPPDEFINES = cppdefines)
94 ccflags = [] # C & C++
97 ccflags += ['-O0', '-g3']
99 ccflags += ['-O3', '-g0']
100 if env['machine'] == 'x86':
102 if env['machine'] == 'x86_64':
105 # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
107 '-Werror=declaration-after-statement',
109 '-Wmissing-field-initializers',
111 '-fmessage-length=0', # be nice to Eclipse
114 '-Wmissing-prototypes',
119 '/Od', # disable optimizations
120 '/Oi', # enable intrinsic functions
121 '/Oy-', # disable frame pointer omission
122 '/GL-', # disable whole program optimization
126 '/Ox', # maximum optimizations
127 '/Oi', # enable intrinsic functions
128 '/Ot', # favor code speed
131 '/EHsc', # set exception handling model
132 '/W4', # warning level
133 #'/Wp64', # enable 64 bit porting warnings
135 # Automatic pdb generation
136 # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
137 env.EnsureSConsVersion(0, 98, 0)
138 env['PDB'] = '${TARGET.base}.pdb'
139 env.Append(CCFLAGS = ccflags)
140 env.Append(CFLAGS = cflags)
141 env.Append(CXXFLAGS = cxxflags)
143 if env['platform'] == 'windows' and env['msvc']:
144 # Choose the appropriate MSVC CRT
145 # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
147 env.Append(CCFLAGS = ['/MTd'])
148 env.Append(SHCCFLAGS = ['/LDd'])
150 env.Append(CCFLAGS = ['/MT'])
151 env.Append(SHCCFLAGS = ['/LD'])
155 if env['machine'] == 'x86':
156 env.Append(ASFLAGS = ['-m32'])
157 if env['machine'] == 'x86_64':
158 env.Append(ASFLAGS = ['-m64'])
163 if env['machine'] == 'x86':
164 linkflags += ['-m32']
165 if env['machine'] == 'x86_64':
166 linkflags += ['-m64']
167 if env['platform'] == 'windows' and env['msvc']:
169 # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
174 env.Append(LINKFLAGS = linkflags)
182 SConscript('zlib/SConscript')
185 env.Append(CPPPATH = [os.path.join(os.environ['DXSDK'], 'Include'),])
189 conf = Configure(env)
190 has_d3d9 = conf.CheckCHeader('d3d9.h')
191 has_d3d8 = conf.CheckCHeader('d3d8.h')
192 has_d3d7 = conf.CheckCHeader('ddraw.h')
197 target = 'ddraw.cpp',
198 source = ['ddraw.py', 'd3d.py', 'd3dtypes.py', 'd3dcaps.py', 'windows.py', 'base.py'],
199 action = 'python $SOURCE > $TARGET',
202 ddraw = env.SharedLibrary(
216 source = ['d3d8.py', 'd3d8types.py', 'd3d8caps.py', 'windows.py', 'base.py'],
217 action = 'python $SOURCE > $TARGET',
220 d3d8 = env.SharedLibrary(
234 source = ['d3d9.py', 'd3d9types.py', 'd3d9caps.py', 'windows.py', 'base.py'],
235 action = 'python $SOURCE > $TARGET',
238 d3d9 = env.SharedLibrary(
250 target = 'opengl32.cpp',
251 source = ['opengl32.py', 'gl.py', 'windows.py', 'base.py'],
252 action = 'python $SOURCE > $TARGET',
255 opengl32 = env.SharedLibrary(
264 env.Default(opengl32)
266 env.Tool('packaging')
274 SUMMARY = 'Tool to trace Direct3D & OpenGL API calls from applications.',
275 SOURCE_URL = 'http://cgit.freedesktop.org/~jrfonseca/apitrace/',
288 env.Alias('zip', zip)