From c455673f8705d9035b939edab682e2e246edf94e Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 9 Mar 2010 22:17:33 +0000 Subject: [PATCH] Added scons options "shared_libname=true" to link agains the system shared libraries for lzo, sfml, and soil. For example add the scons option "shared_lzo=true" for lzo. This will check for the system libraries and then fall back to building and linking statically against the Externals if not found. You must have liblzo2-dev, libsoil-dev, and libsfml-dev installed. Note that you need version 1.5 or later for sfml. Currently scons doesn't check the version for you. If you are having trouble with segmentation faults in linux try "shared_soil=true". That seems to fix the problem. How do we fix this for the static build? git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5182 8ced0084-cf51-0410-be5f-012b33b47a6e --- Externals/LZO/SConscript | 2 +- Externals/SFML/src/SConscript | 2 +- Externals/SOIL/SConscript | 2 +- SConstruct | 46 ++++++++++++++++--- Source/Core/Core/Src/SConscript | 2 +- Source/Core/Core/Src/State.cpp | 4 ++ Source/Core/DolphinWX/Src/SConscript | 4 +- Source/Core/VideoCommon/Src/HiresTextures.cpp | 4 ++ Source/Plugins/Plugin_VideoOGL/Src/SConscript | 2 +- .../Plugin_VideoSoftware/Src/SConscript | 2 +- 10 files changed, 56 insertions(+), 14 deletions(-) diff --git a/Externals/LZO/SConscript b/Externals/LZO/SConscript index 3e7a277af7..ced88ab351 100644 --- a/Externals/LZO/SConscript +++ b/Externals/LZO/SConscript @@ -10,4 +10,4 @@ env_lzo = env.Clone( CCFLAGS = env.filterWarnings(env['CCFLAGS']), CXXFLAGS = env.filterWarnings(env['CXXFLAGS']), ) -env_lzo.StaticLibrary(env['local_libs'] + "minilzo", files) +env_lzo.StaticLibrary(env['local_libs'] + "lzo2", files) diff --git a/Externals/SFML/src/SConscript b/Externals/SFML/src/SConscript index dde2295f4a..45d0c81db3 100644 --- a/Externals/SFML/src/SConscript +++ b/Externals/SFML/src/SConscript @@ -19,4 +19,4 @@ env_sfml = env.Clone( CXXFLAGS = env.filterWarnings(env['CXXFLAGS']), ) -env_sfml.StaticLibrary(env['local_libs'] + "sfml", files) +env_sfml.StaticLibrary(env['local_libs'] + "sfml-network", files) diff --git a/Externals/SOIL/SConscript b/Externals/SOIL/SConscript index be4a9721cc..2564300faf 100644 --- a/Externals/SOIL/SConscript +++ b/Externals/SOIL/SConscript @@ -15,4 +15,4 @@ env_soil = env.Clone( parse_flags = ['-fPIC'] ) -env_soil.StaticLibrary(env['local_libs'] + "libsoil", files) +env_soil.StaticLibrary(env['local_libs'] + "SOIL", files) diff --git a/SConstruct b/SConstruct index a8ac71c853..c29b5d8e19 100644 --- a/SConstruct +++ b/SConstruct @@ -50,10 +50,7 @@ include_paths = [ basedir + 'Source/Core/Core/Src', basedir + 'Source/Core/DebuggerWX/Src', basedir + 'Externals/Bochs_disasm', - basedir + 'Externals/LZO', - basedir + 'Externals/SOIL', basedir + 'Externals/Lua', - basedir + 'Externals/SFML/include', basedir + 'Externals/WiiUseSrc/Src', basedir + 'Source/Core/VideoCommon/Src', basedir + 'Source/Core/InputCommon/Src', @@ -64,9 +61,6 @@ include_paths = [ dirs = [ 'Externals/Bochs_disasm', - 'Externals/LZO', - 'Externals/SOIL', - 'Externals/SFML/src', 'Externals/Lua', 'Externals/WiiUseSrc/Src', 'Source/Core/Common/Src', @@ -112,6 +106,9 @@ vars.AddVariables( BoolVariable('wxgl', 'Set For Building with WX GL libs (WIP)', False), BoolVariable('opencl', 'Build with OpenCL', False), BoolVariable('nojit', 'Remove entire jit cores', False), + BoolVariable('shared_soil', 'Use system shared libSOIL', False), + BoolVariable('shared_lzo', 'Use system shared liblzo2', False), + BoolVariable('shared_sfml', 'Use system shared libsfml-network', False), PathVariable('userdir', 'Set the name of the user data directory in home', '.dolphin-emu', PathVariable.PathAccept), EnumVariable('install', 'Choose a local or global installation', 'local', allowed_values = ('local', 'global'), @@ -324,6 +321,40 @@ if sys.platform != 'darwin': # needed for mic env['HAVE_PORTAUDIO'] = conf.CheckPortaudio(1890) +# SOIL +env['SHARED_SOIL'] = 0; +if env['shared_soil']: + env['SHARED_SOIL'] = conf.CheckPKG('SOIL') + if not env['SHARED_SOIL']: + print "shared SOIL library not detected" + print "falling back to the static library" +if not env['SHARED_SOIL']: + env['CPPPATH'] += [ basedir + 'Externals/SOIL' ] + dirs += ['Externals/SOIL'] + +# LZO +env['SHARED_LZO'] = 0; +if env['shared_lzo']: + env['SHARED_LZO'] = conf.CheckPKG('lzo2') + if not env['SHARED_LZO']: + print "shared LZO library not detected" + print "falling back to the static library" +if not env['SHARED_LZO']: + env['CPPPATH'] += [ basedir + 'Externals/LZO' ] + dirs += ['Externals/LZO'] + +# SFML +env['SHARED_SFML'] = 0; +if env['shared_sfml']: + # TODO: Check the version of sfml. It should be at least version 1.5 + env['SHARED_SFML'] = conf.CheckPKG('sfml-network') and conf.CheckCXXHeader("SFML/Network/Ftp.hpp") + if not env['SHARED_SFML']: + print "shared sfml-network library not detected" + print "falling back to the static library" +if not env['SHARED_SFML']: + env['CPPPATH'] += [ basedir + 'Externals/SFML/include' ] + dirs += ['Externals/SFML/src'] + #osx 64 specifics if sys.platform == 'darwin': if env['osx'] == '64cocoa': @@ -380,6 +411,9 @@ conf.Define('USE_WX', env['USE_WX']) conf.Define('HAVE_X11', env['HAVE_X11']) conf.Define('HAVE_COCOA', env['HAVE_COCOA']) conf.Define('HAVE_PORTAUDIO', env['HAVE_PORTAUDIO']) +conf.Define('SHARED_SOIL', env['SHARED_SOIL']) +conf.Define('SHARED_LZO', env['SHARED_LZO']) +conf.Define('SHARED_SFML', env['SHARED_SFML']) conf.Define('USER_DIR', "\"" + env['userdir'] + "\"") if (ARGUMENTS.get('install') == 'global'): conf.Define('DATA_DIR', "\"" + env['data_dir'] + "\"") diff --git a/Source/Core/Core/Src/SConscript b/Source/Core/Core/Src/SConscript index 5c2c2b2aae..8b5ee229f7 100644 --- a/Source/Core/Core/Src/SConscript +++ b/Source/Core/Core/Src/SConscript @@ -138,7 +138,7 @@ libs = [ 'bdisasm', 'inputcommon', 'lua', - 'sfml' + 'sfml-network' ] env_core = env.Clone(); diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index 85920c9e24..0b62fca92b 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -31,7 +31,11 @@ #include +#if defined(SHARED_LZO) && SHARED_LZO +#include +#else #include "minilzo.h" +#endif // TODO: Move to namespace diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index 6dfeb54bf8..2605c736fb 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -11,8 +11,8 @@ files = [ ] libs = [ - 'core', 'minilzo', 'discio', 'bdisasm', 'videocommon', - 'inputcommon', 'common', 'lua', 'z', 'sfml' + 'core', 'lzo2', 'discio', 'bdisasm', 'videocommon', + 'inputcommon', 'common', 'lua', 'z', 'sfml-network' ] if wxenv['HAVE_WX']: diff --git a/Source/Core/VideoCommon/Src/HiresTextures.cpp b/Source/Core/VideoCommon/Src/HiresTextures.cpp index 4539e54357..50040d2fd3 100644 --- a/Source/Core/VideoCommon/Src/HiresTextures.cpp +++ b/Source/Core/VideoCommon/Src/HiresTextures.cpp @@ -20,7 +20,11 @@ #include #include #include +#if defined(SHARED_SOIL) && SHARED_SOIL +#include +#else #include "SOIL.h" +#endif #include "CommonPaths.h" #include "FileUtil.h" #include "FileSearch.h" diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SConscript b/Source/Plugins/Plugin_VideoOGL/Src/SConscript index 9a9349c26b..c3806c9e34 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/SConscript +++ b/Source/Plugins/Plugin_VideoOGL/Src/SConscript @@ -31,7 +31,7 @@ compileFlags = [ linkFlags = [ ] libs = [ - 'videocommon', 'soil', 'common' + 'videocommon', 'SOIL', 'common' ] gfxenv = env.Clone() diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SConscript b/Source/Plugins/Plugin_VideoSoftware/Src/SConscript index 88f959d102..28360ee6eb 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SConscript +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SConscript @@ -42,7 +42,7 @@ compileFlags = [ linkFlags = [ ] libs = [ - 'videocommon', 'soil', 'common' + 'videocommon', 'SOIL', 'common' ] gfxenv = env.Clone()