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 for compilation line', False),
99 BoolVariable('bundle', 'Set to create bundle', False),
100 BoolVariable('lint', 'Set for lint build (extra warnings)', False),
101 BoolVariable('nojit', 'Remove entire jit cores', False),
102 BoolVariable('nowx', 'Set for building with no WX libs', False),
103 EnumVariable('flavor', 'Choose a build flavor', 'release',
104 allowed_values
= ('release','devel','debug','fastlog','prof'),
106 PathVariable('wxconfig', 'Path to the wxconfig', None),
107 EnumVariable('pgo', 'Profile-Guided Optimization (generate or use)', 'none',
108 allowed_values
= ('none', 'generate', 'use'),
110 ('CC', 'The c compiler', 'gcc'),
111 ('CXX', 'The c++ compiler', 'g++'),
114 if not sys
.platform
== 'win32' and not sys
.platform
== 'darwin':
116 BoolVariable('wxgl', 'Set for building with WX GL', False),
117 PathVariable('destdir',
118 'Temporary install location (for package building)',
119 None, PathVariable
.PathAccept
),
120 EnumVariable('install',
121 'Choose a local or global installation', 'local',
122 allowed_values
= ('local', 'global'), ignorecase
= 2),
123 PathVariable('prefix',
124 'Installation prefix (only used for a global build)',
125 '/usr', PathVariable
.PathAccept
),
126 PathVariable('userdir',
127 'Set the name of the user data directory in home',
128 '.dolphin-emu', PathVariable
.PathAccept
),
129 BoolVariable('opencl', 'Build with OpenCL', False),
130 BoolVariable('shared_glew', 'Use system shared libGLEW', True),
131 BoolVariable('shared_lzo', 'Use system shared liblzo2', True),
132 BoolVariable('shared_sdl', 'Use system shared libSDL', True),
133 BoolVariable('shared_sfml', 'Use system shared libsfml-network', True),
134 BoolVariable('shared_soil', 'Use system shared libSOIL', True),
135 BoolVariable('shared_zlib', 'Use system shared libz', True),
139 CPPPATH
= include_paths
,
147 if sys
.platform
== 'win32':
148 env
['tools'] = ['mingw']
149 env
['ENV'] = os
.environ
152 'PATH' : os
.environ
['PATH'],
153 'HOME' : os
.environ
['HOME'],
154 'PKG_CONFIG_PATH' : os
.environ
.get('PKG_CONFIG_PATH')
157 # Save the given command line options
158 vars.Save('args.cache', env
)
161 if not env
['verbose']:
162 env
['CCCOMSTR'] = "Compiling $TARGET"
163 env
['CXXCOMSTR'] = "Compiling $TARGET"
164 env
['ARCOMSTR'] = "Archiving $TARGET"
165 env
['LINKCOMSTR'] = "Linking $TARGET"
166 env
['ASCOMSTR'] = "Assembling $TARGET"
167 env
['ASPPCOMSTR'] = "Assembling $TARGET"
168 env
['SHCCCOMSTR'] = "Compiling shared $TARGET"
169 env
['SHCXXCOMSTR'] = "Compiling shared $TARGET"
170 env
['SHLINKCOMSTR'] = "Linking shared $TARGET"
171 env
['RANLIBCOMSTR'] = "Indexing $TARGET"
174 flavour
= env
['flavor']
175 if (flavour
== 'debug'):
176 compileFlags
.append('-ggdb')
177 cppDefines
.append('_DEBUG') #enables LOGGING
178 # FIXME: this disable wx debugging how do we make it work?
179 cppDefines
.append('NDEBUG')
180 elif (flavour
== 'devel'):
181 compileFlags
.append('-ggdb')
182 elif (flavour
== 'fastlog'):
183 compileFlags
.append('-O3')
184 cppDefines
.append('DEBUGFAST')
185 elif (flavour
== 'prof'):
186 compileFlags
.append('-O3')
187 compileFlags
.append('-ggdb')
188 elif (flavour
== 'release'):
189 compileFlags
.append('-O3')
190 compileFlags
.append('-fomit-frame-pointer');
193 warnings
.append('error')
194 # Should check for the availability of these (in GCC 4.3 or newer)
195 if sys
.platform
!= 'darwin':
196 warnings
.append('no-array-bounds')
197 warnings
.append('no-unused-result')
198 # wxWidgets causes too many warnings with these
199 #warnings.append('unreachable-code')
200 #warnings.append('float-equal')
202 # Add the warnings to the compile flags
203 compileFlags
+= [ ('-W' + warning
) for warning
in warnings
]
205 env
['CCFLAGS'] = compileFlags
206 env
['CPPDEFINES'] = cppDefines
207 if not sys
.platform
== 'win32':
208 env
['CXXFLAGS'] = ['-fvisibility-inlines-hidden']
210 # PGO - Profile Guided Optimization
211 if env
['pgo']=='generate':
212 compileFlags
.append('-fprofile-generate')
213 env
['LINKFLAGS']='-fprofile-generate'
214 if env
['pgo']=='use':
215 compileFlags
.append('-fprofile-use')
216 env
['LINKFLAGS']='-fprofile-use'
218 # Configuration tests section
219 tests
= {'CheckWXConfig' : wxconfig
.CheckWXConfig
,
220 'CheckPKGConfig' : utils
.CheckPKGConfig
,
221 'CheckPKG' : utils
.CheckPKG
,
222 'CheckSDL' : utils
.CheckSDL
,
223 'CheckPortaudio' : utils
.CheckPortaudio
,
227 env
['build_dir'] = os
.path
.join(basedir
, 'Build',
228 platform
.system() + '-' + platform
.machine() + '-' + env
['flavor'] + os
.sep
)
230 # Static libs go here
231 env
['local_libs'] = env
['build_dir'] + os
.sep
+ 'libs' + os
.sep
233 # Where do we run from
234 env
['base_dir'] = os
.getcwd()+ '/'
238 if flavour
== 'debug':
240 elif flavour
== 'prof':
243 # Set up the install locations
244 if sys
.platform
== 'linux2' and env
['install'] == 'global':
245 env
['prefix'] = os
.path
.join(env
['prefix'] + os
.sep
)
246 env
['binary_dir'] = env
['prefix'] + 'bin/'
247 env
['plugin_dir'] = env
['prefix'] + 'lib/dolphin-emu/'
248 env
['data_dir'] = env
['prefix'] + "share/dolphin-emu/"
250 env
['prefix'] = os
.path
.join(env
['base_dir'] + 'Binary',
251 platform
.system() + '-' + platform
.machine() + extra
+ os
.sep
)
252 env
['binary_dir'] = env
['prefix']
253 env
['plugin_dir'] = env
['prefix'] + 'plugins/'
254 env
['data_dir'] = env
['prefix']
255 if sys
.platform
== 'darwin':
256 env
['plugin_dir'] = env
['prefix'] + 'Dolphin.app/Contents/PlugIns/'
257 env
['data_dir'] = env
['prefix'] + 'Dolphin.app/Contents/'
259 conf
= env
.Configure(custom_tests
= tests
,
260 config_h
="Source/Core/Common/Src/Config.h")
262 env
['HAVE_OPENCL'] = 0
265 if sys
.platform
== 'darwin':
266 compileFlags
+= ['-mmacosx-version-min=10.5']
267 conf
.Define('MAP_32BIT', 0)
268 env
['CC'] = "gcc-4.2"
269 env
['CFLAGS'] = ['-x', 'objective-c']
270 env
['CXX'] = "g++-4.2"
271 env
['CXXFLAGS'] = ['-x', 'objective-c++']
272 env
['CCFLAGS'] += ['-arch' , 'x86_64' , '-arch' , 'i386']
273 env
['LINKFLAGS'] += ['-arch', 'x86_64' , '-arch' , 'i386']
274 env
['FRAMEWORKS'] += ['CoreFoundation', 'CoreServices']
275 env
['FRAMEWORKS'] += ['IOBluetooth', 'IOKit', 'OpenGL']
276 env
['FRAMEWORKS'] += ['AudioUnit', 'CoreAudio']
277 if platform
.mac_ver()[0] >= '10.6.0':
278 env
['HAVE_OPENCL'] = 1
279 env
['LINKFLAGS'] += ['-weak_framework', 'OpenCL']
280 env
['FRAMEWORKS'] += ['Cg']
282 if not conf
.CheckPKGConfig('0.15.0'):
283 print "Can't find pkg-config, some tests will fail"
286 shared
['glew'] = shared
['lzo'] = shared
['sdl'] = \
287 shared
['soil'] = shared
['sfml'] = shared
['zlib'] = 0
288 if not sys
.platform
== 'win32' and not sys
.platform
== 'darwin':
289 if env
['shared_glew']:
290 shared
['glew'] = conf
.CheckPKG('GLEW')
291 if env
['shared_sdl']:
292 shared
['sdl'] = conf
.CheckPKG('SDL')
293 if env
['shared_zlib']:
294 shared
['zlib'] = conf
.CheckPKG('z')
295 if env
['shared_lzo']:
296 shared
['lzo'] = conf
.CheckPKG('lzo2')
297 # TODO: Check the version of sfml. It should be at least version 1.5
298 if env
['shared_sfml']:
299 shared
['sfml'] = conf
.CheckPKG('sfml-network') and \
300 conf
.CheckCXXHeader("SFML/Network/Ftp.hpp")
301 if env
['shared_soil']:
302 shared
['soil'] = conf
.CheckPKG('SOIL')
305 print "Shared library " + lib
+ " not detected, " \
306 "falling back to the static library"
308 if shared
['glew'] == 0:
309 env
['CPPPATH'] += [basedir
+ 'Externals/GLew/include']
310 dirs
+= ['Externals/GLew']
311 if shared
['lzo'] == 0:
312 env
['CPPPATH'] += [basedir
+ 'Externals/LZO']
313 dirs
+= ['Externals/LZO']
314 if shared
['sdl'] == 0:
315 env
['CPPPATH'] += [basedir
+ 'Externals/SDL']
316 env
['CPPPATH'] += [basedir
+ 'Externals/SDL/include']
317 dirs
+= ['Externals/SDL']
318 if shared
['soil'] == 0:
319 env
['CPPPATH'] += [basedir
+ 'Externals/SOIL']
320 dirs
+= ['Externals/SOIL']
321 if shared
['sfml'] == 0:
322 env
['CPPPATH'] += [basedir
+ 'Externals/SFML/include']
323 dirs
+= ['Externals/SFML/src']
324 if shared
['zlib'] == 0:
325 env
['CPPPATH'] += [basedir
+ 'Externals/zlib']
326 dirs
+= ['Externals/zlib']
328 if sys
.platform
== 'win32' or sys
.platform
== 'darwin':
330 wxmods
= ['aui', 'adv', 'core', 'base']
337 if sys
.platform
== 'darwin':
338 wxver
= '2.9' # 64-bit on OS X
343 env
['HAVE_WX'] = env
['USE_WX'] = 0;
345 env
['HAVE_WX'] = conf
.CheckWXConfig(wxver
, wxmods
, 0)
346 wxconfig
.ParseWXConfig(env
)
347 # wx-config wants us to link with the OS X QuickTime framework
348 # which is not available for x86_64 and we don't use it anyway.
349 # Strip it out to silence some harmless linker warnings.
350 if env
['FRAMEWORKS'].count('QuickTime'):
351 env
['FRAMEWORKS'].remove('QuickTime')
352 # Make sure that the libraries claimed by wx-config are valid
353 #env['HAVE_WX'] = conf.CheckPKG('c')
355 if not env
['HAVE_WX'] and not env
['nowx']:
356 print "WX libraries not found - see config.log"
359 conf
.Define('HAVE_WX', env
['HAVE_WX'])
360 conf
.Define('USE_WX', env
['USE_WX'])
362 if not sys
.platform
== 'win32' and not sys
.platform
== 'darwin':
363 env
['LINKFLAGS'] += ['-pthread']
365 env
['HAVE_BLUEZ'] = conf
.CheckPKG('bluez')
366 conf
.Define('HAVE_BLUEZ', env
['HAVE_BLUEZ'])
368 env
['HAVE_ALSA'] = conf
.CheckPKG('alsa')
369 conf
.Define('HAVE_ALSA', env
['HAVE_ALSA'])
371 env
['HAVE_AO'] = conf
.CheckPKG('ao')
372 conf
.Define('HAVE_AO', env
['HAVE_AO'])
374 env
['HAVE_OPENAL'] = conf
.CheckPKG('openal')
375 conf
.Define('HAVE_OPENAL', env
['HAVE_OPENAL'])
377 env
['HAVE_PORTAUDIO'] = conf
.CheckPortaudio(1890)
378 conf
.Define('HAVE_PORTAUDIO', env
['HAVE_PORTAUDIO'])
380 env
['HAVE_PULSEAUDIO'] = conf
.CheckPKG('libpulse-simple')
381 conf
.Define('HAVE_PULSEAUDIO', env
['HAVE_PULSEAUDIO'])
383 env
['HAVE_X11'] = conf
.CheckPKG('x11')
384 env
['HAVE_XRANDR'] = env
['HAVE_X11'] and conf
.CheckPKG('xrandr')
385 conf
.Define('HAVE_XRANDR', env
['HAVE_XRANDR'])
386 conf
.Define('HAVE_X11', env
['HAVE_X11'])
388 # Check for GTK 2.0 or newer
389 if env
['HAVE_WX'] and not conf
.CheckPKG('gtk+-2.0'):
390 print "gtk+-2.0 developement headers not detected"
391 print "gtk+-2.0 is required to build the WX GUI"
394 if not conf
.CheckPKG('GL'):
395 print "Must have OpenGL to build"
397 if not conf
.CheckPKG('GLU'):
398 print "Must have GLU to build"
400 if not conf
.CheckPKG('Cg'):
401 print "Must have Cg framework from NVidia to build"
403 if not conf
.CheckPKG('CgGL'):
404 print "Must have CgGl to build"
407 env
['HAVE_OPENCL'] = conf
.CheckPKG('OpenCL')
409 conf
.Define('USER_DIR', "\"" + env
['userdir'] + "\"")
410 if (env
['install'] == 'global'):
411 conf
.Define('DATA_DIR', "\"" + env
['data_dir'] + "\"")
412 conf
.Define('LIBS_DIR', "\"" + env
['prefix'] + 'lib/' + "\"")
414 conf
.Define('HAVE_OPENCL', env
['HAVE_OPENCL'])
420 conf
.Define('NOJIT', env
['NOJIT'])
423 if not sys
.platform
== 'win32':
424 conf
.Define('LUA_USE_LINUX')
427 env
['USE_OPROFILE'] = 0
428 if (flavour
== 'prof'):
429 proflibs
= [ '/usr/lib/oprofile', '/usr/local/lib/oprofile' ]
430 env
['LIBPATH'].append(proflibs
)
431 env
['RPATH'].append(proflibs
)
432 if conf
.CheckPKG('opagent'):
433 env
['USE_OPROFILE'] = 1
434 conf
.Define('USE_OPROFILE', env
['USE_OPROFILE'])
436 print "Can't build prof without oprofile, disabling"
438 # After all configuration tests are done
441 env
['LIBPATH'].append(env
['local_libs'])
443 rev
= utils
.GenerateRevFile(env
['flavor'],
444 "Source/Core/Common/Src/svnrev_template.h",
445 "Source/Core/Common/Src/svnrev.h")
446 # Print a nice progress indication when not compiling
447 Progress(['-\r', '\\\r', '|\r', '/\r'], interval
=5)
449 # Setup destdir for package building
450 # Warning: The program will not run from this location. It is assumed the
451 # package will later install it to the prefix as it was defined before this.
452 if env
.has_key('destdir'):
453 env
['prefix'] = env
['destdir'] + env
['prefix']
454 env
['plugin_dir'] = env
['destdir'] + env
['plugin_dir']
455 env
['binary_dir'] = env
['destdir'] + env
['binary_dir']
456 env
['data_dir'] = env
['destdir'] + env
['data_dir']
458 # Die on unknown variables
459 unknown
= vars.UnknownVariables()
461 print "Unknown variables:", unknown
.keys()
465 Help(vars.GenerateHelpText(env
))
471 subdir
+ os
.sep
+ 'SConscript',
472 variant_dir
= env
[ 'build_dir' ] + subdir
+ os
.sep
,
477 if sys
.platform
== 'darwin':
478 env
.Install(env
['data_dir'], 'Data/Sys')
479 env
.Install(env
['data_dir'], 'Data/User')
480 env
.Install(env
['binary_dir'] + 'Dolphin.app/Contents/Resources/',
481 'Source/Core/DolphinWX/resources/Dolphin.icns')
483 env
.InstallAs(env
['data_dir'] + 'sys', 'Data/Sys')
484 env
.InstallAs(env
['data_dir'] + 'user', 'Data/User')
486 env
.Alias('install', env
['prefix'])
489 if sys
.platform
== 'linux2':
490 # Make tar ball (TODO put inside normal dir)
491 tar_env
= env
.Clone()
492 tarball
= tar_env
.Tar('dolphin-' + rev
+ '.tar.bz2', env
['prefix'])
493 tar_env
.Append(TARFLAGS
='-j', TARCOMSTR
="Creating release tarball")
494 env
.Clean(all
, tarball
)
495 elif sys
.platform
== 'darwin':
496 app
= env
['binary_dir'] + 'Dolphin.app'
497 dmg
= env
['binary_dir'] + 'Dolphin-r' + rev
+ '.dmg'
498 env
.Command('.', app
+ '/Contents/MacOS/Dolphin', 'rm -f ' + dmg
+
499 ' && hdiutil create -srcfolder ' + app
+ ' -format UDBZ ' + dmg
+
500 ' && hdiutil internet-enable -yes ' + dmg
)