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('nowx', 'Set for building with no WX libs', False),
102 BoolVariable('wxgl', 'Set for building with WX GL on Linux', False),
103 BoolVariable('opencl', 'Build with OpenCL', False),
104 BoolVariable('nojit', 'Remove entire jit cores', False),
105 BoolVariable('shared_glew', 'Use system shared libGLEW', True),
106 BoolVariable('shared_lzo', 'Use system shared liblzo2', True),
107 BoolVariable('shared_sdl', 'Use system shared libSDL', True),
108 BoolVariable('shared_sfml', 'Use system shared libsfml-network', True),
109 BoolVariable('shared_soil', 'Use system shared libSOIL', True),
110 BoolVariable('shared_zlib', 'Use system shared libz', True),
111 PathVariable('userdir', 'Set the name of the user data directory in home',
112 '.dolphin-emu', PathVariable
.PathAccept
),
113 EnumVariable('install', 'Choose a local or global installation', 'local',
114 allowed_values
= ('local', 'global'),
117 PathVariable('prefix', 'Installation prefix (only used for a global build)',
118 '/usr', PathVariable
.PathAccept
),
119 PathVariable('destdir', 'Temporary install location (for package building)',
120 None, PathVariable
.PathAccept
),
121 EnumVariable('flavor', 'Choose a build flavor', 'release',
122 allowed_values
= ('release','devel','debug','fastlog','prof'),
125 PathVariable('wxconfig', 'Path to the wxconfig', None),
126 EnumVariable('pgo', 'Profile-Guided Optimization (generate or use)', 'none',
127 allowed_values
= ('none', 'generate', 'use'),
130 ('CC', 'The c compiler', 'gcc'),
131 ('CXX', 'The c++ compiler', 'g++'),
135 CPPPATH
= include_paths
,
143 if sys
.platform
== 'win32':
144 env
['tools'] = ['mingw']
145 env
['ENV'] = os
.environ
148 'PATH' : os
.environ
['PATH'],
149 'HOME' : os
.environ
['HOME'],
150 'PKG_CONFIG_PATH' : os
.environ
.get('PKG_CONFIG_PATH')
153 # Save the given command line options
154 vars.Save('args.cache', env
)
157 if not env
['verbose']:
158 env
['CCCOMSTR'] = "Compiling $TARGET"
159 env
['CXXCOMSTR'] = "Compiling $TARGET"
160 env
['ARCOMSTR'] = "Archiving $TARGET"
161 env
['LINKCOMSTR'] = "Linking $TARGET"
162 env
['ASCOMSTR'] = "Assembling $TARGET"
163 env
['ASPPCOMSTR'] = "Assembling $TARGET"
164 env
['SHCCCOMSTR'] = "Compiling shared $TARGET"
165 env
['SHCXXCOMSTR'] = "Compiling shared $TARGET"
166 env
['SHLINKCOMSTR'] = "Linking shared $TARGET"
167 env
['RANLIBCOMSTR'] = "Indexing $TARGET"
170 flavour
= env
['flavor']
171 if (flavour
== 'debug'):
172 compileFlags
.append('-ggdb')
173 cppDefines
.append('_DEBUG') #enables LOGGING
174 # FIXME: this disable wx debugging how do we make it work?
175 cppDefines
.append('NDEBUG')
176 elif (flavour
== 'devel'):
177 compileFlags
.append('-ggdb')
178 elif (flavour
== 'fastlog'):
179 compileFlags
.append('-O3')
180 cppDefines
.append('DEBUGFAST')
181 elif (flavour
== 'prof'):
182 compileFlags
.append('-O3')
183 compileFlags
.append('-ggdb')
184 elif (flavour
== 'release'):
185 compileFlags
.append('-O3')
186 compileFlags
.append('-fomit-frame-pointer');
189 warnings
.append('error')
190 # Should check for the availability of these (in GCC 4.3 or newer)
191 if sys
.platform
!= 'darwin':
192 warnings
.append('no-array-bounds')
193 warnings
.append('no-unused-result')
194 # wxWidgets causes too many warnings with these
195 #warnings.append('unreachable-code')
196 #warnings.append('float-equal')
198 # Add the warnings to the compile flags
199 compileFlags
+= [ ('-W' + warning
) for warning
in warnings
]
201 env
['CCFLAGS'] = compileFlags
202 env
['CPPDEFINES'] = cppDefines
203 if not sys
.platform
== 'win32':
204 env
['CXXFLAGS'] = ['-fvisibility-inlines-hidden']
206 # PGO - Profile Guided Optimization
207 if env
['pgo']=='generate':
208 compileFlags
.append('-fprofile-generate')
209 env
['LINKFLAGS']='-fprofile-generate'
210 if env
['pgo']=='use':
211 compileFlags
.append('-fprofile-use')
212 env
['LINKFLAGS']='-fprofile-use'
214 # Configuration tests section
215 tests
= {'CheckWXConfig' : wxconfig
.CheckWXConfig
,
216 'CheckPKGConfig' : utils
.CheckPKGConfig
,
217 'CheckPKG' : utils
.CheckPKG
,
218 'CheckSDL' : utils
.CheckSDL
,
219 'CheckPortaudio' : utils
.CheckPortaudio
,
223 env
['build_dir'] = os
.path
.join(basedir
, 'Build',
224 platform
.system() + '-' + platform
.machine() + '-' + env
['flavor'] + os
.sep
)
226 # Static libs go here
227 env
['local_libs'] = env
['build_dir'] + os
.sep
+ 'libs' + os
.sep
229 # Where do we run from
230 env
['base_dir'] = os
.getcwd()+ '/'
234 if flavour
== 'debug':
236 elif flavour
== 'prof':
239 # Set up the install locations
240 if (env
['install'] == 'global'):
241 env
['prefix'] = os
.path
.join(env
['prefix'] + os
.sep
)
242 env
['binary_dir'] = env
['prefix'] + 'bin/'
243 env
['plugin_dir'] = env
['prefix'] + 'lib/dolphin-emu/'
244 env
['data_dir'] = env
['prefix'] + "share/dolphin-emu/"
246 env
['prefix'] = os
.path
.join(env
['base_dir'] + 'Binary',
247 platform
.system() + '-' + platform
.machine() + extra
+ os
.sep
)
248 env
['binary_dir'] = env
['prefix']
249 env
['plugin_dir'] = env
['prefix'] + 'plugins/'
250 env
['data_dir'] = env
['prefix']
251 if sys
.platform
== 'darwin':
252 env
['plugin_dir'] = env
['prefix'] + 'Dolphin.app/Contents/PlugIns/'
253 env
['data_dir'] = env
['prefix'] + 'Dolphin.app/Contents/'
255 conf
= env
.Configure(custom_tests
= tests
,
256 config_h
="Source/Core/Common/Src/Config.h")
258 env
['HAVE_OPENCL'] = 0
259 if not sys
.platform
== 'win32':
261 env
['HAVE_OPENCL'] = conf
.CheckPKG('OpenCL')
264 if sys
.platform
== 'darwin':
265 if env
['FRAMEWORKS'].count('OpenCL'):
266 env
['FRAMEWORKS'].remove('OpenCL')
267 env
['LINKFLAGS'] += ['-weak_framework', 'OpenCL']
268 compileFlags
+= ['-isysroot', '/Developer/SDKs/MacOSX10.6.sdk']
270 # OpenCL is new in OS X 10.6. Other than OpenCL,
271 # we try to maintain 10.5 compatibility, however.
272 compileFlags
+= ['-isysroot', '/Developer/SDKs/MacOSX10.5.sdk']
273 compileFlags
+= ['-mmacosx-version-min=10.5']
274 conf
.Define('MAP_32BIT', 0)
275 env
['CC'] = "gcc-4.2"
276 env
['CFLAGS'] = ['-x', 'objective-c']
277 env
['CXX'] = "g++-4.2"
278 env
['CXXFLAGS'] = ['-x', 'objective-c++']
279 env
['CCFLAGS'] += ['-arch' , 'x86_64' , '-arch' , 'i386']
280 env
['LINKFLAGS'] += ['-arch', 'x86_64' , '-arch' , 'i386']
281 env
['FRAMEWORKS'] += ['CoreFoundation', 'CoreServices']
282 env
['FRAMEWORKS'] += ['IOBluetooth', 'IOKit', 'OpenGL']
283 env
['FRAMEWORKS'] += ['AudioUnit', 'CoreAudio']
285 if not conf
.CheckPKGConfig('0.15.0'):
286 print "Can't find pkg-config, some tests will fail"
289 shared
['glew'] = shared
['lzo'] = shared
['sdl'] = \
290 shared
['soil'] = shared
['sfml'] = shared
['zlib'] = 0
291 if not sys
.platform
== 'win32' and not sys
.platform
== 'darwin':
292 if env
['shared_glew']:
293 shared
['glew'] = conf
.CheckPKG('GLEW')
294 if env
['shared_sdl']:
295 shared
['sdl'] = conf
.CheckPKG('SDL')
296 if env
['shared_zlib']:
297 shared
['zlib'] = conf
.CheckPKG('z')
298 if env
['shared_lzo']:
299 shared
['lzo'] = conf
.CheckPKG('lzo2')
300 # TODO: Check the version of sfml. It should be at least version 1.5
301 if env
['shared_sfml']:
302 shared
['sfml'] = conf
.CheckPKG('sfml-network') and \
303 conf
.CheckCXXHeader("SFML/Network/Ftp.hpp")
304 if env
['shared_soil']:
305 shared
['soil'] = conf
.CheckPKG('SOIL')
308 print "Shared library " + lib
+ " not detected, " \
309 "falling back to the static library"
311 if shared
['glew'] == 0:
312 env
['CPPPATH'] += [basedir
+ 'Externals/GLew/include']
313 dirs
+= ['Externals/GLew']
314 if shared
['lzo'] == 0:
315 env
['CPPPATH'] += [basedir
+ 'Externals/LZO']
316 dirs
+= ['Externals/LZO']
317 if shared
['sdl'] == 0:
318 env
['CPPPATH'] += [basedir
+ 'Externals/SDL']
319 env
['CPPPATH'] += [basedir
+ 'Externals/SDL/include']
320 dirs
+= ['Externals/SDL']
321 if shared
['soil'] == 0:
322 env
['CPPPATH'] += [basedir
+ 'Externals/SOIL']
323 dirs
+= ['Externals/SOIL']
324 if shared
['sfml'] == 0:
325 env
['CPPPATH'] += [basedir
+ 'Externals/SFML/include']
326 dirs
+= ['Externals/SFML/src']
327 if shared
['zlib'] == 0:
328 env
['CPPPATH'] += [basedir
+ 'Externals/zlib']
329 dirs
+= ['Externals/zlib']
331 wxmods
= ['aui', 'adv', 'core', 'base']
332 if env
['wxgl'] or sys
.platform
== 'win32' or sys
.platform
== 'darwin':
340 if sys
.platform
== 'darwin':
341 wxver
= '2.9' # 64-bit on OS X
348 env
['HAVE_WX'] = conf
.CheckWXConfig(wxver
, wxmods
, 0)
349 wxconfig
.ParseWXConfig(env
)
350 # wx-config wants us to link with the OS X QuickTime framework
351 # which is not available for x86_64 and we don't use it anyway.
352 # Strip it out to silence some harmless linker warnings.
353 if env
['FRAMEWORKS'].count('QuickTime'):
354 env
['FRAMEWORKS'].remove('QuickTime')
355 # Make sure that the libraries claimed by wx-config are valid
356 #env['HAVE_WX'] = conf.CheckPKG('c')
358 if not env
['HAVE_WX'] and not env
['nowx']:
359 print "WX libraries not found - see config.log"
362 if not sys
.platform
== 'win32':
363 if not conf
.CheckPKG('Cg'):
364 print "Must have Cg framework from NVidia to build"
367 env
['HAVE_BLUEZ'] = 0
368 env
['HAVE_ALSA'] = env
['HAVE_AO'] = env
['HAVE_OPENAL'] = \
369 env
['HAVE_PORTAUDIO'] = env
['HAVE_PULSEAUDIO'] = 0
370 env
['HAVE_X11'] = env
['HAVE_XRANDR'] = 0
371 if not sys
.platform
== 'win32' and not sys
.platform
== 'darwin':
372 env
['LINKFLAGS'] += ['-pthread']
374 env
['HAVE_BLUEZ'] = conf
.CheckPKG('bluez')
376 env
['HAVE_ALSA'] = conf
.CheckPKG('alsa')
377 env
['HAVE_AO'] = conf
.CheckPKG('ao')
378 env
['HAVE_OPENAL'] = conf
.CheckPKG('openal')
379 env
['HAVE_PORTAUDIO'] = conf
.CheckPortaudio(1890)
380 env
['HAVE_PULSEAUDIO'] = conf
.CheckPKG('libpulse-simple')
382 env
['HAVE_X11'] = conf
.CheckPKG('x11')
383 env
['HAVE_XRANDR'] = env
['HAVE_X11'] and conf
.CheckPKG('xrandr')
384 if not conf
.CheckPKG('GL'):
385 print "Must have OpenGL to build"
387 if not conf
.CheckPKG('GLU'):
388 print "Must have GLU to build"
390 if not conf
.CheckPKG('CgGL'):
391 print "Must have CgGl to build"
394 # Check for GTK 2.0 or newer
395 if sys
.platform
== 'linux2':
396 if env
['HAVE_WX'] and not conf
.CheckPKG('gtk+-2.0'):
397 print "gtk+-2.0 developement headers not detected"
398 print "gtk+-2.0 is required to build the WX GUI"
405 conf
.Define('NOJIT', env
['NOJIT'])
407 # Creating config.h defines
408 conf
.Define('HAVE_BLUEZ', env
['HAVE_BLUEZ'])
409 conf
.Define('HAVE_AO', env
['HAVE_AO'])
410 conf
.Define('HAVE_OPENCL', env
['HAVE_OPENCL'])
411 conf
.Define('HAVE_OPENAL', env
['HAVE_OPENAL'])
412 conf
.Define('HAVE_ALSA', env
['HAVE_ALSA'])
413 conf
.Define('HAVE_PULSEAUDIO', env
['HAVE_PULSEAUDIO'])
414 conf
.Define('HAVE_WX', env
['HAVE_WX'])
415 conf
.Define('USE_WX', env
['USE_WX'])
416 conf
.Define('HAVE_X11', env
['HAVE_X11'])
417 conf
.Define('HAVE_XRANDR', env
['HAVE_XRANDR'])
418 conf
.Define('HAVE_PORTAUDIO', env
['HAVE_PORTAUDIO'])
419 conf
.Define('USER_DIR', "\"" + env
['userdir'] + "\"")
420 if (env
['install'] == 'global'):
421 conf
.Define('DATA_DIR', "\"" + env
['data_dir'] + "\"")
422 conf
.Define('LIBS_DIR', "\"" + env
['prefix'] + 'lib/' + "\"")
425 env
['LUA_USE_MACOSX'] = env
['LUA_USE_LINUX'] = env
['LUA_USE_POSIX'] = 0
426 if sys
.platform
== 'darwin':
427 env
['LUA_USE_MACOSX'] = 1
428 elif sys
.platform
== 'linux2':
429 env
['LUA_USE_LINUX'] = 1
431 conf
.Define('LUA_USE_MACOSX', env
['LUA_USE_MACOSX'])
432 conf
.Define('LUA_USE_LINUX', env
['LUA_USE_LINUX'])
435 env
['USE_OPROFILE'] = 0
436 if (flavour
== 'prof'):
437 proflibs
= [ '/usr/lib/oprofile', '/usr/local/lib/oprofile' ]
438 env
['LIBPATH'].append(proflibs
)
439 env
['RPATH'].append(proflibs
)
440 if conf
.CheckPKG('opagent'):
441 env
['USE_OPROFILE'] = 1
443 print "Can't build prof without oprofile, disabling"
445 conf
.Define('USE_OPROFILE', env
['USE_OPROFILE'])
446 # After all configuration tests are done
449 env
['LIBPATH'].append(env
['local_libs'])
451 rev
= utils
.GenerateRevFile(env
['flavor'],
452 "Source/Core/Common/Src/svnrev_template.h",
453 "Source/Core/Common/Src/svnrev.h")
454 # Print a nice progress indication when not compiling
455 Progress(['-\r', '\\\r', '|\r', '/\r'], interval
=5)
457 # Setup destdir for package building
458 # Warning: The program will not run from this location. It is assumed the
459 # package will later install it to the prefix as it was defined before this.
460 if env
.has_key('destdir'):
461 env
['prefix'] = env
['destdir'] + env
['prefix']
462 env
['plugin_dir'] = env
['destdir'] + env
['plugin_dir']
463 env
['binary_dir'] = env
['destdir'] + env
['binary_dir']
464 env
['data_dir'] = env
['destdir'] + env
['data_dir']
466 # Die on unknown variables
467 unknown
= vars.UnknownVariables()
469 print "Unknown variables:", unknown
.keys()
473 Help(vars.GenerateHelpText(env
))
479 subdir
+ os
.sep
+ 'SConscript',
480 variant_dir
= env
[ 'build_dir' ] + subdir
+ os
.sep
,
485 if sys
.platform
== 'darwin':
486 env
.Install(env
['data_dir'], 'Data/Sys')
487 env
.Install(env
['data_dir'], 'Data/User')
488 env
.Install(env
['binary_dir'] + 'Dolphin.app/Contents/Resources/',
489 'Source/Core/DolphinWX/resources/Dolphin.icns')
491 env
.InstallAs(env
['data_dir'] + 'sys', 'Data/Sys')
492 env
.InstallAs(env
['data_dir'] + 'user', 'Data/User')
494 env
.Alias('install', env
['prefix'])
497 if sys
.platform
== 'linux2':
498 # Make tar ball (TODO put inside normal dir)
499 tar_env
= env
.Clone()
500 tarball
= tar_env
.Tar('dolphin-' + rev
+ '.tar.bz2', env
['prefix'])
501 tar_env
.Append(TARFLAGS
='-j', TARCOMSTR
="Creating release tarball")
502 env
.Clean(all
, tarball
)
503 elif sys
.platform
== 'darwin':
504 app
= env
['binary_dir'] + 'Dolphin.app'
505 dmg
= env
['binary_dir'] + 'Dolphin-r' + rev
+ '.dmg'
506 env
.Command('.', app
+ '/Contents/MacOS/Dolphin', 'rm -f ' + dmg
+
507 ' && hdiutil create -srcfolder ' + app
+ ' -format UDBZ ' + dmg
+
508 ' && hdiutil internet-enable -yes ' + dmg
)