DX9/DX11: Remove some dead or obsolete code.
[dolphin.git] / SConstruct
blobea6978b1757190048b756b1352b0a94f1bbcf3d8
1 # -*- python -*-
3 import os
4 import sys
5 import platform
7 # Home made tests
8 from SconsTests import utils
9 from SconsTests import wxconfig
11 # Some features need at least SCons 1.2
12 EnsureSConsVersion(1, 2)
14 # Construction presets for platform
15 env = Environment(ENV = os.environ)
17 # Handle command line options
18 vars = Variables('args.cache')
20 vars.AddVariables(
21 BoolVariable('verbose', 'Set to show compilation lines', False),
22 BoolVariable('bundle', 'Set to create distribution bundle', False),
23 BoolVariable('lint', 'Set for lint build (fail on warnings)', False),
24 BoolVariable('nowx', 'Set for building without wxWidgets', False),
25 PathVariable('wxconfig', 'Path to wxconfig', None),
26 EnumVariable('flavor', 'Choose a build flavor', 'release', allowed_values =
27 ('release','devel','debug','fastlog','prof'), ignorecase = 2),
30 if env['PLATFORM'] == 'posix': vars.AddVariables(
31 PathVariable('destdir', 'Temporary install location (for package building)',
32 None, PathVariable.PathAccept),
33 EnumVariable('install', 'Choose a local or global installation', 'local',
34 allowed_values = ('local', 'global'), ignorecase = 2),
35 PathVariable('prefix', 'Installation prefix (only used for a global build)',
36 '/usr', PathVariable.PathAccept),
37 PathVariable('userdir', 'Set the name of the user data directory in home',
38 '.dolphin-emu', PathVariable.PathAccept),
39 BoolVariable('opencl', 'Build with OpenCL', False),
40 EnumVariable('pgo', 'Profile-Guided Optimization (generate or use)', 'none',
41 allowed_values = ('none', 'generate', 'use'), ignorecase = 2),
42 BoolVariable('shared_glew', 'Use system shared libGLEW', True),
43 BoolVariable('shared_lzo', 'Use system shared liblzo2', True),
44 BoolVariable('shared_sdl', 'Use system shared libSDL', True),
45 BoolVariable('shared_sfml', 'Use system shared libsfml-network', True),
46 BoolVariable('shared_soil', 'Use system shared libSOIL', True),
47 BoolVariable('shared_zlib', 'Use system shared libz', True),
48 PathVariable('CC', 'The C compiler', 'gcc', PathVariable.PathAccept),
49 PathVariable('CXX', 'The C++ compiler', 'g++', PathVariable.PathAccept),
52 # Save the given command line options
53 vars.Update(env)
54 vars.Save('args.cache', env)
56 # Die on unknown variables
57 unknown = vars.UnknownVariables()
58 if unknown:
59 print "Unknown variables:", unknown.keys()
60 Exit(1)
62 # Verbose compile
63 if not env['verbose']:
64 env['ARCOMSTR'] = "Archiving $TARGET"
65 env['ASCOMSTR'] = "Assembling $TARGET"
66 env['ASPPCOMSTR'] = "Assembling $TARGET"
67 env['CCCOMSTR'] = "Compiling $TARGET"
68 env['CXXCOMSTR'] = "Compiling $TARGET"
69 env['LINKCOMSTR'] = "Linking $TARGET"
70 env['RANLIBCOMSTR'] = "Indexing $TARGET"
71 env['SHCCCOMSTR'] = "Compiling $TARGET"
72 env['SHCXXCOMSTR'] = "Compiling $TARGET"
73 env['SHLINKCOMSTR'] = "Linking $TARGET"
74 env['TARCOMSTR'] = "Creating $TARGET"
76 if not env['flavor'] == 'debug':
77 env['CCFLAGS'] += ['-O3']
78 if env['flavor'] == 'release':
79 env['CCFLAGS'] += ['-fomit-frame-pointer']
80 elif not env['flavor'] == 'fastlog':
81 env['CCFLAGS'] += ['-ggdb']
82 env['CCFLAGS'] += ['-fno-exceptions', '-fno-strict-aliasing']
83 if env['CCVERSION'] >= '4.2.0':
84 env['CCFLAGS'] += ['-fvisibility=hidden']
85 env['CXXFLAGS'] += ['-fvisibility-inlines-hidden']
87 if env['lint']:
88 env['CCFLAGS'] += ['-Werror']
89 env['CCFLAGS'] += ['-Wall', '-Wextra']
90 env['CCFLAGS'] += ['-Wno-missing-field-initializers', '-Wno-unused-parameter']
91 env['CCFLAGS'] += ['-Wpacked', '-Wpointer-arith', '-Wshadow', '-Wwrite-strings']
92 if env['CCVERSION'] < '4.2.0':
93 env['CCFLAGS'] += ['-Wno-pragmas']
94 if env['CCVERSION'] >= '4.3.0':
95 env['CCFLAGS'] += ['-Wno-array-bounds', '-Wno-unused-result']
97 env['CPPDEFINES'] = []
98 if env['flavor'] == 'debug':
99 env['CPPDEFINES'] += ['_DEBUG']
100 elif env['flavor'] == 'fastlog':
101 env['CPPDEFINES'] += ['DEBUGFAST']
102 env['CPPPATH'] = ['#Source/PluginSpecs']
103 env['LIBPATH'] = []
104 env['LIBS'] = []
106 # Object files
107 env['build_dir'] = 'Build' + os.sep + platform.system() + \
108 '-' + platform.machine() + '-' + env['flavor']
110 # Static libs go here
111 env['local_libs'] = '#' + env['build_dir'] + os.sep + 'libs' + os.sep
113 # Default install path
114 if not env.has_key('install') or env['install'] == 'local':
115 env['prefix'] = 'Binary' + os.sep + platform.system() + \
116 '-' + platform.machine()
117 if env['flavor'] == 'debug' or env['flavor'] == 'prof':
118 env['prefix'] += '-' + env['flavor']
120 rev = utils.GenerateRevFile(env['flavor'], '.', None)
122 # OS X specifics
123 if sys.platform == 'darwin':
124 ccld = ['-arch', 'x86_64', '-arch', 'i386', '-mmacosx-version-min=10.5']
125 ccld += ['--sysroot=/Developer/SDKs/MacOSX10.5.sdk']
126 env['CCFLAGS'] += ccld
127 env['CCFLAGS'] += ['-msse3']
128 env['CC'] = "gcc-4.2 -ObjC"
129 env['CXX'] = "g++-4.2 -ObjC++"
130 env['FRAMEWORKS'] += ['AppKit', 'CoreFoundation', 'CoreServices']
131 env['FRAMEWORKS'] += ['AudioUnit', 'CoreAudio']
132 env['FRAMEWORKS'] += ['IOBluetooth', 'IOKit', 'OpenGL']
133 env['LIBPATH'] += ['/usr/lib']
134 env['LIBS'] = ['iconv', 'SDL']
135 env['LINKFLAGS'] += ccld
136 env['LINKFLAGS'] += ['-Wl,-search_paths_first', '-Wl,-Z']
137 env['LINKFLAGS'] += ['-F/System/Library/Frameworks']
139 if platform.mac_ver()[0] < '10.6.0':
140 env['HAVE_OPENCL'] = 0
141 else:
142 env['CCFLAGS'] += ['-Wextra-tokens', '-Wnewline-eof']
143 env['CCFLAGS'] += ['-iframework' +
144 '/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks']
145 env['CCFLAGS'] += ['-iframework' +
146 '/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks']
147 env['CPPDEFINES'] += [('HAVE_OPENCL', 1)]
148 env['HAVE_OPENCL'] = 1
149 env['FRAMEWORKSFLAGS'] = ['-weak_framework', 'OpenCL']
151 if env['nowx']:
152 env['HAVE_WX'] = 0
153 else:
154 wxenv = env.Clone(LIBPATH = '')
155 conf = wxenv.Configure(conf_dir = None, log_file = None,
156 custom_tests = {'CheckWXConfig' : wxconfig.CheckWXConfig})
157 env['HAVE_WX'] = \
158 conf.CheckWXConfig(2.9, 'aui adv core base gl'.split(),
159 env['flavor'] == 'debug')
160 conf.Finish()
161 if not env['HAVE_WX']:
162 print "wxWidgets 2.9 not found using " + env['wxconfig']
163 Exit(1)
164 wxconfig.ParseWXConfig(wxenv)
165 env['CPPDEFINES'] += ['__WXOSX_COCOA__']
166 env['CPPPATH'] = wxenv['CPPPATH']
167 if not wxenv['CPPDEFINES'].count('WXUSINGDLL'):
168 env['FRAMEWORKS'] = wxenv['FRAMEWORKS']
169 env['LIBPATH'] += wxenv['LIBPATH']
170 env['LIBS'] = wxenv['LIBS']
172 env['CPPPATH'] += ['#Externals']
173 env['FRAMEWORKPATH'] += ['Externals/Cg']
174 env['FRAMEWORKS'] += ['Cg']
175 env['shared_zlib'] = True
177 env['data_dir'] = '#' + env['prefix'] + '/Dolphin.app/Contents/Resources'
178 env['plugin_dir'] = '#' + env['prefix'] + '/Dolphin.app/Contents/PlugIns'
180 if env['bundle']:
181 app = env['prefix'] + '/Dolphin.app'
182 dmg = env['prefix'] + '/Dolphin-r' + rev + '.dmg'
183 env.Command(dmg, app, 'rm -f ' + dmg +
184 ' && hdiutil create -srcfolder ' + app + ' -format UDBZ ' + dmg +
185 ' && hdiutil internet-enable -yes ' + dmg)
187 elif sys.platform == 'win32':
188 pass
190 else:
191 env['CCFLAGS'] += ['-fPIC', '-msse2']
192 env['CPPDEFINES'] += ['HAVE_CONFIG_H']
193 env['CPPPATH'].insert(0, '#') # Make sure we pick up our own config.h
194 if sys.platform == 'linux2':
195 env['CPPDEFINES'] += [('_FILE_OFFSET_BITS', 64), '_LARGEFILE_SOURCE']
196 env['CXXFLAGS'] += ['-Wno-deprecated'] # XXX <hash_map>
197 env['LINKFLAGS'] += ['-pthread', '-ldl']
198 env['RPATH'] = []
200 conf = env.Configure(config_h = "#config.h", custom_tests = {
201 'CheckPKG' : utils.CheckPKG,
202 'CheckPKGConfig' : utils.CheckPKGConfig,
203 'CheckPortaudio' : utils.CheckPortaudio,
204 'CheckSDL' : utils.CheckSDL,
205 'CheckWXConfig' : wxconfig.CheckWXConfig,
208 if not conf.CheckPKGConfig('0.15.0'):
209 print "Can't find pkg-config, some tests will fail"
211 if env['shared_glew']:
212 env['shared_glew'] = conf.CheckPKG('GLEW')
213 if env['shared_sdl']:
214 env['shared_sdl'] = conf.CheckPKG('SDL')
215 if env['shared_zlib']:
216 env['shared_zlib'] = conf.CheckPKG('z')
217 if env['shared_lzo']:
218 env['shared_lzo'] = conf.CheckPKG('lzo2')
219 # TODO: Check the version of sfml. It should be at least version 1.5
220 if env['shared_sfml']:
221 env['shared_sfml'] = conf.CheckPKG('sfml-network') and \
222 conf.CheckCXXHeader("SFML/Network/Ftp.hpp")
223 if env['shared_soil']:
224 env['shared_soil'] = conf.CheckPKG('SOIL')
225 for var in env.items():
226 if var[0].startswith('shared_') and var[1] == False:
227 print "Shared library " + var[0][7:] + " not detected, " \
228 "falling back to the static library"
230 if env['nowx']:
231 env['HAVE_WX'] = 0
232 else:
233 env['HAVE_WX'] = conf.CheckWXConfig(2.8, 'aui adv core base'.split(),
234 env['flavor'] == 'debug')
235 conf.Define('HAVE_WX', env['HAVE_WX'])
236 wxconfig.ParseWXConfig(env)
237 if not env['HAVE_WX']:
238 print "wxWidgets not found - see config.log"
239 Exit(1)
241 env['HAVE_BLUEZ'] = conf.CheckPKG('bluez')
242 conf.Define('HAVE_BLUEZ', env['HAVE_BLUEZ'])
244 env['HAVE_ALSA'] = conf.CheckPKG('alsa')
245 conf.Define('HAVE_ALSA', env['HAVE_ALSA'])
246 env['HAVE_AO'] = conf.CheckPKG('ao')
247 conf.Define('HAVE_AO', env['HAVE_AO'])
248 env['HAVE_OPENAL'] = conf.CheckPKG('openal')
249 conf.Define('HAVE_OPENAL', env['HAVE_OPENAL'])
250 env['HAVE_PORTAUDIO'] = conf.CheckPortaudio(1890)
251 conf.Define('HAVE_PORTAUDIO', env['HAVE_PORTAUDIO'])
252 env['HAVE_PULSEAUDIO'] = conf.CheckPKG('libpulse')
253 conf.Define('HAVE_PULSEAUDIO', env['HAVE_PULSEAUDIO'])
255 env['HAVE_X11'] = conf.CheckPKG('x11')
256 env['HAVE_XRANDR'] = env['HAVE_X11'] and conf.CheckPKG('xrandr')
257 conf.Define('HAVE_XRANDR', env['HAVE_XRANDR'])
258 conf.Define('HAVE_X11', env['HAVE_X11'])
260 if env['HAVE_WX'] and not conf.CheckPKG('gtk+-2.0'):
261 print "gtk+-2.0 developement headers not detected"
262 print "gtk+-2.0 is required to build the WX GUI"
263 Exit(1)
265 if not conf.CheckPKG('GL'):
266 print "Must have OpenGL to build"
267 Exit(1)
268 if not conf.CheckPKG('GLU'):
269 print "Must have GLU to build"
270 Exit(1)
271 if not conf.CheckPKG('Cg') and sys.platform == 'linux2':
272 print "Must have Cg toolkit from NVidia to build"
273 Exit(1)
274 if not conf.CheckPKG('CgGL') and sys.platform == 'linux2':
275 print "Must have CgGL to build"
276 Exit(1)
278 if env['opencl']:
279 env['HAVE_OPENCL'] = conf.CheckPKG('OpenCL')
280 conf.Define('HAVE_OPENCL', env['HAVE_OPENCL'])
281 else:
282 env['HAVE_OPENCL'] = 0
284 # PGO - Profile Guided Optimization
285 if env['pgo'] == 'generate':
286 env['CCFLAGS'] += ['-fprofile-generate']
287 env['LINKFLAGS'] += ['-fprofile-generate']
288 if env['pgo'] == 'use':
289 env['CCFLAGS'] += ['-fprofile-use']
290 env['LINKFLAGS'] += ['-fprofile-use']
292 # Profiling
293 if env['flavor'] == 'prof':
294 proflibs = ['/usr/lib/oprofile', '/usr/local/lib/oprofile']
295 env['LIBPATH'] += ['proflibs']
296 env['RPATH'] += ['proflibs']
297 if conf.CheckPKG('opagent'):
298 conf.Define('USE_OPROFILE', 1)
299 else:
300 print "Can't build prof without oprofile, disabling"
302 tarname = 'dolphin-' + rev
303 env['TARFLAGS'] = '-cj'
304 env['TARSUFFIX'] = '.tar.bz2'
306 if env['install'] == 'local':
307 env['binary_dir'] = '#' + env['prefix']
308 env['data_dir'] = '#' + env['prefix']
309 env['plugin_dir'] = '#' + env['prefix'] + '/plugins'
310 if env['bundle']:
311 env.Tar(tarname, env['prefix'])
312 else:
313 env['prefix'] = Dir(env['prefix']).abspath
314 env['binary_dir'] = env['prefix'] + '/bin'
315 env['data_dir'] = env['prefix'] + "/share/dolphin-emu"
316 env['plugin_dir'] = env['prefix'] + '/lib/dolphin-emu'
317 conf.Define('DATA_DIR', "\"" + env['data_dir'] + "/\"")
318 conf.Define('LIBS_DIR', "\"" + env['prefix'] + '/lib/dolphin-emu/' + "\"")
319 # Setup destdir for package building
320 # Warning: The program will not run from this location.
321 # It is assumed the package will later install it to the prefix.
322 if env.has_key('destdir'):
323 env['destdir'] = Dir(env['destdir']).abspath
324 env['binary_dir'] = env['destdir'] + env['binary_dir']
325 env['data_dir'] = env['destdir'] + env['data_dir']
326 env['plugin_dir'] = env['destdir'] + env['plugin_dir']
327 env['prefix'] = env['destdir'] + env['prefix']
328 if env['bundle']:
329 env.Command(tarname + env['TARSUFFIX'], env['prefix'],
330 'tar ' + env['TARFLAGS'] + 'C ' + env['destdir'] + \
331 ' -f ' + tarname + env['TARSUFFIX'] + ' ' + \
332 env['prefix'].split(env['destdir'], 1)[1][1:])
334 conf.Define('USER_DIR', "\"" + env['userdir'] + "\"")
336 # After all configuration tests are done
337 conf.Finish()
339 env.Alias('install', env['prefix'])
341 # Local (static) libraries must be first in the search path for the build in
342 # order that they can override system libraries, but they must not be found
343 # during autoconfiguration as they will then be detected as system libraries.
344 env['LIBPATH'].insert(0, env['local_libs'])
346 dirs = [
347 'Externals/Bochs_disasm',
348 #'Externals/CLRun',
349 'Externals/Lua',
350 'Externals/WiiUse/Src',
351 'Externals/GLew',
352 'Externals/LZO',
353 #'Externals/OpenAL',
354 'Externals/SDL',
355 'Externals/SOIL',
356 'Externals/SFML/src',
357 #'Externals/wxWidgets',
358 'Externals/zlib',
359 'Source/Core/AudioCommon/Src',
360 'Source/Core/Common/Src',
361 'Source/Core/Core/Src',
362 'Source/Core/DSPCore/Src',
363 'Source/Core/DebuggerUICommon/Src',
364 'Source/Core/DebuggerWX/Src',
365 'Source/Core/DiscIO/Src',
366 'Source/Core/DolphinWX/Src',
367 'Source/Core/InputCommon/Src',
368 'Source/Core/InputUICommon/Src',
369 'Source/Core/VideoCommon/Src',
370 'Source/DSPTool/Src',
371 'Source/Plugins/Plugin_DSP_HLE/Src',
372 'Source/Plugins/Plugin_DSP_LLE/Src',
373 #'Source/Plugins/Plugin_VideoDX11/Src',
374 #'Source/Plugins/Plugin_VideoDX9/Src',
375 #'Source/Plugins/Plugin_VideoMerge/Src',
376 'Source/Plugins/Plugin_VideoOGL/Src',
377 'Source/Plugins/Plugin_VideoSoftware/Src',
378 'Source/UnitTests',
381 # Now that platform configuration is done, propagate it to modules
382 for subdir in dirs:
383 SConscript(dirs = subdir, duplicate = 0, exports = 'env',
384 variant_dir = env['build_dir'] + os.sep + subdir)
385 if subdir.startswith('Source/Core'):
386 env['CPPPATH'] += ['#' + subdir]
388 # Print a nice progress indication when not compiling
389 Progress(['-\r', '\\\r', '|\r', '/\r'], interval = 5)
391 # Generate help, printing current status of options
392 Help(vars.GenerateHelpText(env))