8 sys
.path
.append('SconsTests')
12 # Some features need at least SCons 1.2
13 EnsureSConsVersion(1, 2)
26 '-fno-strict-aliasing',
32 ( '_FILE_OFFSET_BITS', 64),
34 'GCC_HASCLASSVISIBILITY',
37 basedir
= os
.getcwd() + '/'
40 basedir
+ 'Source/Core/Common/Src',
41 basedir
+ 'Source/Core/DiscIO/Src',
42 basedir
+ 'Source/PluginSpecs',
43 basedir
+ 'Source/Core/Core/Src',
44 basedir
+ 'Source/Core/DebuggerWX/Src',
45 basedir
+ 'Externals/Bochs_disasm',
46 basedir
+ 'Externals/Lua',
47 basedir
+ 'Externals/WiiUseSrc/Src',
48 basedir
+ 'Source/Core/VideoCommon/Src',
49 basedir
+ 'Source/Core/InputCommon/Src',
50 basedir
+ 'Source/Core/InputUICommon/Src',
51 basedir
+ 'Source/Core/AudioCommon/Src',
52 basedir
+ 'Source/Core/DebuggerUICommon/Src',
53 basedir
+ 'Source/Core/DolphinWX/Src',
54 basedir
+ 'Source/Core/DSPCore/Src',
58 'Externals/Bochs_disasm',
60 'Externals/MemcardManager',
61 'Externals/WiiUseSrc/Src',
62 'Source/Core/Common/Src',
63 'Source/Core/Core/Src',
64 'Source/Core/DiscIO/Src',
65 'Source/Core/VideoCommon/Src',
66 'Source/Core/InputCommon/Src',
67 'Source/Core/AudioCommon/Src',
68 'Source/Core/DebuggerUICommon/Src',
69 'Source/Core/DSPCore/Src',
71 'Source/Core/InputUICommon/Src/',
72 'Source/Plugins/Plugin_VideoOGL/Src',
73 'Source/Plugins/Plugin_VideoSoftware/Src',
74 'Source/Plugins/Plugin_DSP_HLE/Src',
75 'Source/Plugins/Plugin_DSP_LLE/Src',
76 'Source/Plugins/Plugin_Wiimote/Src',
77 'Source/Plugins/Plugin_WiimoteNew/Src/',
78 'Source/Core/DolphinWX/Src',
79 'Source/Core/DebuggerWX/Src',
84 if sys
.platform
== 'darwin':
85 from plistlib
import writePlist
86 def createPlist(target
, source
, env
):
88 for srcNode
in source
:
89 properties
.update(srcNode
.value
)
90 for dstNode
in target
:
91 writePlist(properties
, str(dstNode
))
92 builders
['Plist'] = Builder(action
= createPlist
)
94 # Handle command line options
95 vars = Variables('args.cache')
98 BoolVariable('verbose', 'Set to show compilation lines', False),
99 BoolVariable('bundle', 'Set to create distribution bundle', False),
100 BoolVariable('lint', 'Set for lint build (extra warnings)', False),
101 BoolVariable('nowx', 'Set for building with no WX libs', False),
102 EnumVariable('flavor', 'Choose a build flavor', 'release',
103 allowed_values
= ('release','devel','debug','fastlog','prof'),
105 PathVariable('wxconfig', 'Path to wxconfig', None),
106 ('CC', 'The C compiler', 'gcc'),
107 ('CXX', 'The C++ compiler', 'g++'),
110 if not sys
.platform
== 'win32' and not sys
.platform
== 'darwin':
112 PathVariable('destdir',
113 'Temporary install location (for package building)',
114 None, PathVariable
.PathAccept
),
115 EnumVariable('install',
116 'Choose a local or global installation', 'local',
117 allowed_values
= ('local', 'global'), ignorecase
= 2),
118 PathVariable('prefix',
119 'Installation prefix (only used for a global build)',
120 '/usr', PathVariable
.PathAccept
),
121 PathVariable('userdir',
122 'Set the name of the user data directory in home',
123 '.dolphin-emu', PathVariable
.PathAccept
),
124 BoolVariable('opencl', 'Build with OpenCL', False),
125 EnumVariable('pgo', 'Profile-Guided Optimization (generate or use)',
126 'none', allowed_values
= ('none', 'generate', 'use'),
128 BoolVariable('shared_glew', 'Use system shared libGLEW', True),
129 BoolVariable('shared_lzo', 'Use system shared liblzo2', True),
130 BoolVariable('shared_sdl', 'Use system shared libSDL', True),
131 BoolVariable('shared_sfml', 'Use system shared libsfml-network', True),
132 BoolVariable('shared_soil', 'Use system shared libSOIL', True),
133 BoolVariable('shared_zlib', 'Use system shared libz', True),
137 CPPPATH
= include_paths
,
145 if sys
.platform
== 'win32':
146 env
['tools'] = ['mingw']
147 env
['ENV'] = os
.environ
150 'PATH' : os
.environ
['PATH'],
151 'HOME' : os
.environ
['HOME'],
152 'PKG_CONFIG_PATH' : os
.environ
.get('PKG_CONFIG_PATH')
155 # Save the given command line options
156 vars.Save('args.cache', env
)
159 if not env
['verbose']:
160 env
['CCCOMSTR'] = "Compiling $TARGET"
161 env
['CXXCOMSTR'] = "Compiling $TARGET"
162 env
['ARCOMSTR'] = "Archiving $TARGET"
163 env
['LINKCOMSTR'] = "Linking $TARGET"
164 env
['ASCOMSTR'] = "Assembling $TARGET"
165 env
['ASPPCOMSTR'] = "Assembling $TARGET"
166 env
['SHCCCOMSTR'] = "Compiling shared $TARGET"
167 env
['SHCXXCOMSTR'] = "Compiling shared $TARGET"
168 env
['SHLINKCOMSTR'] = "Linking shared $TARGET"
169 env
['RANLIBCOMSTR'] = "Indexing $TARGET"
172 flavour
= env
['flavor']
173 if (flavour
== 'debug'):
174 compileFlags
.append('-ggdb')
175 cppDefines
.append('_DEBUG') #enables LOGGING
176 # FIXME: this disable wx debugging how do we make it work?
177 cppDefines
.append('NDEBUG')
178 elif (flavour
== 'devel'):
179 compileFlags
.append('-ggdb')
180 elif (flavour
== 'fastlog'):
181 compileFlags
.append('-O3')
182 cppDefines
.append('DEBUGFAST')
183 elif (flavour
== 'prof'):
184 compileFlags
.append('-O3')
185 compileFlags
.append('-ggdb')
186 elif (flavour
== 'release'):
187 compileFlags
.append('-O3')
188 compileFlags
.append('-fomit-frame-pointer');
191 warnings
.append('error')
192 # Should check for the availability of these (in GCC 4.3 or newer)
193 if sys
.platform
!= 'darwin':
194 warnings
.append('no-array-bounds')
195 warnings
.append('no-unused-result')
196 # wxWidgets causes too many warnings with these
197 #warnings.append('unreachable-code')
198 #warnings.append('float-equal')
200 # Add the warnings to the compile flags
201 compileFlags
+= [ ('-W' + warning
) for warning
in warnings
]
203 env
['CCFLAGS'] = compileFlags
204 env
['CPPDEFINES'] = cppDefines
205 if not sys
.platform
== 'win32':
206 env
['CXXFLAGS'] = ['-fvisibility-inlines-hidden']
207 cppDefines
.append('LUA_USE_LINUX')
209 # Configuration tests section
210 tests
= {'CheckWXConfig' : wxconfig
.CheckWXConfig
,
211 'CheckPKGConfig' : utils
.CheckPKGConfig
,
212 'CheckPKG' : utils
.CheckPKG
,
213 'CheckSDL' : utils
.CheckSDL
,
214 'CheckPortaudio' : utils
.CheckPortaudio
,
218 env
['build_dir'] = os
.path
.join(basedir
, 'Build',
219 platform
.system() + '-' + platform
.machine() + '-' + env
['flavor'] + os
.sep
)
221 # Static libs go here
222 env
['local_libs'] = env
['build_dir'] + os
.sep
+ 'libs' + os
.sep
224 # Where do we run from
225 env
['base_dir'] = os
.getcwd()+ '/'
229 if flavour
== 'debug':
231 elif flavour
== 'prof':
234 # Set up the install locations
235 if sys
.platform
== 'linux2' and env
['install'] == 'global':
236 env
['prefix'] = os
.path
.join(env
['prefix'] + os
.sep
)
237 env
['binary_dir'] = env
['prefix'] + 'bin/'
238 env
['plugin_dir'] = env
['prefix'] + 'lib/dolphin-emu/'
239 env
['data_dir'] = env
['prefix'] + "share/dolphin-emu/"
241 env
['prefix'] = os
.path
.join(env
['base_dir'] + 'Binary',
242 platform
.system() + '-' + platform
.machine() + extra
+ os
.sep
)
243 env
['binary_dir'] = env
['prefix']
244 env
['plugin_dir'] = env
['prefix'] + 'plugins/'
245 env
['data_dir'] = env
['prefix']
246 if sys
.platform
== 'darwin':
247 env
['plugin_dir'] = env
['prefix'] + 'Dolphin.app/Contents/PlugIns/'
248 env
['data_dir'] = env
['prefix'] + 'Dolphin.app/Contents/'
251 shared
['glew'] = shared
['lzo'] = shared
['sdl'] = \
252 shared
['soil'] = shared
['sfml'] = shared
['zlib'] = 0
253 wxmods
= ['aui', 'adv', 'core', 'base', 'gl']
254 env
['HAVE_OPENCL'] = 0
258 if sys
.platform
== 'darwin':
259 compileFlags
.append('-mmacosx-version-min=10.5')
260 cppDefines
.append('MAP_32BIT=0')
262 cppDefines
.append('HAVE_WX=1')
263 conf
= env
.Configure(custom_tests
= tests
)
264 # wxWidgets 2.9 has Cocoa support
265 env
['HAVE_WX'] = conf
.CheckWXConfig(2.9, wxmods
, 0)
266 wxconfig
.ParseWXConfig(env
)
267 # Make sure that the libraries claimed by wx-config are valid
268 if not conf
.CheckLib('wx_baseu-2.9'):
269 print "WX libraries not found - see config.log"
272 # wx-config wants us to link with the OS X QuickTime framework
273 # which is not available for x86_64 and we don't use it anyway.
274 # Strip it out to silence some harmless linker warnings.
275 if env
['FRAMEWORKS'].count('QuickTime'):
276 env
['FRAMEWORKS'].remove('QuickTime')
277 env
['CC'] = "gcc-4.2"
278 env
['CFLAGS'] = ['-x', 'objective-c']
279 env
['CXX'] = "g++-4.2"
280 env
['CXXFLAGS'] = ['-x', 'objective-c++']
281 env
['CCFLAGS'] += ['-arch', 'x86_64', '-arch', 'i386']
282 env
['LIBS'] += ['iconv']
283 env
['LINKFLAGS'] += ['-arch', 'x86_64', '-arch', 'i386']
284 env
['FRAMEWORKS'] += ['AppKit', 'CoreFoundation', 'CoreServices']
285 env
['FRAMEWORKS'] += ['IOBluetooth', 'IOKit', 'OpenGL']
286 env
['FRAMEWORKS'] += ['AudioUnit', 'CoreAudio']
287 if platform
.mac_ver()[0] >= '10.6.0':
288 env
['HAVE_OPENCL'] = 1
289 env
['LINKFLAGS'] += ['-weak_framework', 'OpenCL']
290 env
['FRAMEWORKS'] += ['Cg']
292 if not sys
.platform
== 'win32' and not sys
.platform
== 'darwin':
293 conf
= env
.Configure(custom_tests
= tests
,
294 config_h
="Source/Core/Common/Src/Config.h")
296 if not conf
.CheckPKGConfig('0.15.0'):
297 print "Can't find pkg-config, some tests will fail"
299 env
['LINKFLAGS'] += ['-pthread']
301 if env
['shared_glew']:
302 shared
['glew'] = conf
.CheckPKG('GLEW')
303 if env
['shared_sdl']:
304 shared
['sdl'] = conf
.CheckPKG('SDL')
305 if env
['shared_zlib']:
306 shared
['zlib'] = conf
.CheckPKG('z')
307 if env
['shared_lzo']:
308 shared
['lzo'] = conf
.CheckPKG('lzo2')
309 # TODO: Check the version of sfml. It should be at least version 1.5
310 if env
['shared_sfml']:
311 shared
['sfml'] = conf
.CheckPKG('sfml-network') and \
312 conf
.CheckCXXHeader("SFML/Network/Ftp.hpp")
313 if env
['shared_soil']:
314 shared
['soil'] = conf
.CheckPKG('SOIL')
317 print "Shared library " + lib
+ " not detected, " \
318 "falling back to the static library"
321 # wxGLCanvas does not play well with wxGTK
323 env
['HAVE_WX'] = conf
.CheckWXConfig(2.8, wxmods
, 0)
324 wxconfig
.ParseWXConfig(env
)
326 if not env
['HAVE_WX'] and not env
['nowx']:
327 print "WX libraries not found - see config.log"
330 conf
.Define('HAVE_WX', env
['HAVE_WX'])
332 env
['HAVE_BLUEZ'] = conf
.CheckPKG('bluez')
333 conf
.Define('HAVE_BLUEZ', env
['HAVE_BLUEZ'])
335 env
['HAVE_ALSA'] = conf
.CheckPKG('alsa')
336 conf
.Define('HAVE_ALSA', env
['HAVE_ALSA'])
338 env
['HAVE_AO'] = conf
.CheckPKG('ao')
339 conf
.Define('HAVE_AO', env
['HAVE_AO'])
341 env
['HAVE_OPENAL'] = conf
.CheckPKG('openal')
342 conf
.Define('HAVE_OPENAL', env
['HAVE_OPENAL'])
344 env
['HAVE_PORTAUDIO'] = conf
.CheckPortaudio(1890)
345 conf
.Define('HAVE_PORTAUDIO', env
['HAVE_PORTAUDIO'])
347 env
['HAVE_PULSEAUDIO'] = conf
.CheckPKG('libpulse-simple')
348 conf
.Define('HAVE_PULSEAUDIO', env
['HAVE_PULSEAUDIO'])
350 env
['HAVE_X11'] = conf
.CheckPKG('x11')
351 env
['HAVE_XRANDR'] = env
['HAVE_X11'] and conf
.CheckPKG('xrandr')
352 conf
.Define('HAVE_XRANDR', env
['HAVE_XRANDR'])
353 conf
.Define('HAVE_X11', env
['HAVE_X11'])
355 # Check for GTK 2.0 or newer
356 if env
['HAVE_WX'] and not conf
.CheckPKG('gtk+-2.0'):
357 print "gtk+-2.0 developement headers not detected"
358 print "gtk+-2.0 is required to build the WX GUI"
361 if not conf
.CheckPKG('GL'):
362 print "Must have OpenGL to build"
364 if not conf
.CheckPKG('GLU'):
365 print "Must have GLU to build"
367 if not conf
.CheckPKG('Cg'):
368 print "Must have Cg toolkit from NVidia to build"
370 if not conf
.CheckPKG('CgGL'):
371 print "Must have CgGl to build"
375 env
['HAVE_OPENCL'] = conf
.CheckPKG('OpenCL')
377 conf
.Define('USER_DIR', "\"" + env
['userdir'] + "\"")
378 if (env
['install'] == 'global'):
379 conf
.Define('DATA_DIR', "\"" + env
['data_dir'] + "\"")
380 conf
.Define('LIBS_DIR', "\"" + env
['prefix'] + 'lib/' + "\"")
382 # PGO - Profile Guided Optimization
383 if env
['pgo']=='generate':
384 compileFlags
.append('-fprofile-generate')
385 env
['LINKFLAGS']='-fprofile-generate'
386 if env
['pgo']=='use':
387 compileFlags
.append('-fprofile-use')
388 env
['LINKFLAGS']='-fprofile-use'
391 if (flavour
== 'prof'):
392 proflibs
= [ '/usr/lib/oprofile', '/usr/local/lib/oprofile' ]
393 env
['LIBPATH'].append(proflibs
)
394 env
['RPATH'].append(proflibs
)
395 if conf
.CheckPKG('opagent'):
396 conf
.Define('USE_OPROFILE', 1)
398 print "Can't build prof without oprofile, disabling"
400 conf
.Define('HAVE_OPENCL', env
['HAVE_OPENCL'])
402 # After all configuration tests are done
405 # Local (static) libraries must be first in the search path for the build in
406 # order that they can override system libraries, but they must not be found
407 # during autoconfiguration as they will then be detected as system libraries.
408 env
['LIBPATH'].insert(0, env
['local_libs'])
410 if not shared
['glew']:
411 env
['CPPPATH'] += [basedir
+ 'Externals/GLew/include']
412 dirs
+= ['Externals/GLew']
413 if not shared
['lzo']:
414 env
['CPPPATH'] += [basedir
+ 'Externals/LZO']
415 dirs
+= ['Externals/LZO']
416 if not shared
['sdl']:
417 env
['CPPPATH'] += [basedir
+ 'Externals/SDL']
418 env
['CPPPATH'] += [basedir
+ 'Externals/SDL/include']
419 dirs
+= ['Externals/SDL']
420 if not shared
['soil']:
421 env
['CPPPATH'] += [basedir
+ 'Externals/SOIL']
422 dirs
+= ['Externals/SOIL']
423 if not shared
['sfml']:
424 env
['CPPPATH'] += [basedir
+ 'Externals/SFML/include']
425 dirs
+= ['Externals/SFML/src']
426 if not shared
['zlib']:
427 env
['CPPPATH'] += [basedir
+ 'Externals/zlib']
428 dirs
+= ['Externals/zlib']
430 rev
= utils
.GenerateRevFile(env
['flavor'],
431 "Source/Core/Common/Src/svnrev_template.h",
432 "Source/Core/Common/Src/svnrev.h")
434 # Print a nice progress indication when not compiling
435 Progress(['-\r', '\\\r', '|\r', '/\r'], interval
=5)
437 # Setup destdir for package building
438 # Warning: The program will not run from this location. It is assumed the
439 # package will later install it to the prefix as it was defined before this.
440 if env
.has_key('destdir'):
441 env
['prefix'] = env
['destdir'] + env
['prefix']
442 env
['plugin_dir'] = env
['destdir'] + env
['plugin_dir']
443 env
['binary_dir'] = env
['destdir'] + env
['binary_dir']
444 env
['data_dir'] = env
['destdir'] + env
['data_dir']
446 # Die on unknown variables
447 unknown
= vars.UnknownVariables()
449 print "Unknown variables:", unknown
.keys()
453 Help(vars.GenerateHelpText(env
))
459 subdir
+ os
.sep
+ 'SConscript',
460 variant_dir
= env
[ 'build_dir' ] + subdir
+ os
.sep
,
465 if sys
.platform
== 'darwin':
466 env
.Install(env
['data_dir'], 'Data/Sys')
467 env
.Install(env
['data_dir'], 'Data/User')
469 env
.InstallAs(env
['data_dir'] + 'sys', 'Data/Sys')
470 env
.InstallAs(env
['data_dir'] + 'user', 'Data/User')
472 env
.Alias('install', env
['prefix'])
475 if sys
.platform
== 'linux2':
476 # Make tar ball (TODO put inside normal dir)
477 tar_env
= env
.Clone()
478 tarball
= tar_env
.Tar('dolphin-' + rev
+ '.tar.bz2', env
['prefix'])
479 tar_env
.Append(TARFLAGS
='-j', TARCOMSTR
="Creating release tarball")
480 env
.Clean(all
, tarball
)
481 elif sys
.platform
== 'darwin':
482 app
= env
['binary_dir'] + 'Dolphin.app'
483 dmg
= env
['binary_dir'] + 'Dolphin-r' + rev
+ '.dmg'
484 env
.Command('.', app
+ '/Contents/MacOS/Dolphin', 'rm -f ' + dmg
+
485 ' && hdiutil create -srcfolder ' + app
+ ' -format UDBZ ' + dmg
+
486 ' && hdiutil internet-enable -yes ' + dmg
)