| 1 | import os, platform, sys
|
|---|
| 2 | import CompilerSetup
|
|---|
| 3 |
|
|---|
| 4 | Import('env', 'buildMode', 'compiler')
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 | CommonWorldObject = env.StaticObject("Common/World.cpp")
|
|---|
| 8 |
|
|---|
| 9 | env.Program('CaBSP/CaBSP', # I had preferred writing 'CaBSP' instead of 'CaBSP/CaBSP' here, but then under Linux we would get both a directory *and* an executeable with name 'CaBSP' in the build directory, which is not allowed/possible.
|
|---|
| 10 | Split("CaBSP/CaBSP.cpp CaBSP/BspTreeBuilder/BspTreeBuilder.cpp") + CommonWorldObject,
|
|---|
| 11 | LIBS=Split("SceneGraph MatSys ClipSys cfsLib cfs_jpeg bulletcollision lua minizip lightwave png z"))
|
|---|
| 12 |
|
|---|
| 13 | env.Program('CaPVS/CaPVS',
|
|---|
| 14 | Split("CaPVS/CaPVS.cpp CaPVS/CaPVSWorld.cpp") + CommonWorldObject,
|
|---|
| 15 | LIBS=Split("SceneGraph MatSys ClipSys cfsLib cfs_jpeg bulletcollision lua minizip lightwave png z"))
|
|---|
| 16 |
|
|---|
| 17 | env.Program('CaLight/CaLight',
|
|---|
| 18 | Split("CaLight/CaLight.cpp CaLight/CaLightWorld.cpp") + CommonWorldObject,
|
|---|
| 19 | LIBS=Split("SceneGraph MatSys ClipSys cfsLib cfs_jpeg bulletcollision lua minizip lightwave png z"))
|
|---|
| 20 |
|
|---|
| 21 | env.Program('CaSHL/CaSHL',
|
|---|
| 22 | Split("CaSHL/CaSHL.cpp CaSHL/CaSHLWorld.cpp") + CommonWorldObject,
|
|---|
| 23 | LIBS=Split("SceneGraph MatSys ClipSys cfsLib cfs_jpeg bulletcollision lua minizip lightwave png z"))
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | envTools = env.Clone()
|
|---|
| 28 |
|
|---|
| 29 | if sys.platform=="win32":
|
|---|
| 30 | envTools.Append(LIBPATH=['ExtLibs/DirectX7/lib'])
|
|---|
| 31 | # glu32 is only needed for the TerrainViewerOld...
|
|---|
| 32 | envTools.Append(LIBS=Split("SceneGraph MatSys ClipSys cfsLib cfs_jpeg bulletcollision lua minizip lightwave png z")
|
|---|
| 33 | + Split("gdi32 glu32 opengl32 user32") + ['cfsOpenGL', 'dinput', 'dxguid'])
|
|---|
| 34 | elif sys.platform=="linux2":
|
|---|
| 35 | # GLU is only needed for the TerrainViewerOld...
|
|---|
| 36 | envTools.Append(CPPPATH=['/usr/include/freetype2']) # As of 2009-09-10, this line is to become unnecessary in the future, see /usr/include/ftbuild.h for details.
|
|---|
| 37 | envTools.Append(LIBS=Split("SceneGraph MatSys cfsOpenGL ClipSys cfsLib cfs_jpeg bulletcollision lua minizip lightwave png z")
|
|---|
| 38 | + Split("GL GLU X11 dl"))
|
|---|
| 39 |
|
|---|
| 40 | envTools.Program("MakeFont", "CaTools/MakeFont.cpp", LIBS=envTools["LIBS"]+["freetype"])
|
|---|
| 41 |
|
|---|
| 42 | if sys.platform!="win32" or envTools["TARGET_ARCH"]=="x86":
|
|---|
| 43 | # Don't build these programs under 64-bit Windows, as they still depend on our legacy 32-bit-only DirectInput code.
|
|---|
| 44 | envTools.Program('CaSanity', ['CaTools/CaSanity.cpp'] + CommonWorldObject)
|
|---|
| 45 | envTools.Program('MaterialViewer', "CaTools/MaterialViewer.cpp")
|
|---|
| 46 | envTools.Program('TerrainViewer', "CaTools/TerrainViewer.cpp")
|
|---|
| 47 | envTools.Program('TerrainViewerOld', "CaTools/TerrainViewerOld.cpp")
|
|---|
| 48 |
|
|---|
| 49 | if sys.platform=="win32":
|
|---|
| 50 | env.Program('ReadDump', "CaTools/ReadDump.cpp", LIBS="wsock32")
|
|---|
| 51 | elif sys.platform=="linux2":
|
|---|
| 52 | env.Program('ReadDump', "CaTools/ReadDump.cpp")
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | # Create a common construction environment for our wxWidgets-based programs (Cafu and CaWE).
|
|---|
| 57 | wxEnv = env.Clone()
|
|---|
| 58 |
|
|---|
| 59 | if sys.platform=="win32":
|
|---|
| 60 | wxPath="#/ExtLibs/wxWidgets";
|
|---|
| 61 |
|
|---|
| 62 | # TODO: Move this into the SConstruct file (including the wx include path above).
|
|---|
| 63 | # Note that we only (want to) determine the right library path matching the used compiler here.
|
|---|
| 64 | # The specific wx-version used (e.g. latest stable vs. trunk) is still determined locally (here),
|
|---|
| 65 | # BUT if this is moved into the SConstruct file, also the wx-version (wxPath above) must be fixed there.
|
|---|
| 66 | LibPath="/lib/"+compiler
|
|---|
| 67 |
|
|---|
| 68 | # Append wxWidgets-specific suffixes matching the TARGET_CPU setting for the Makefiles.
|
|---|
| 69 | if wxEnv["TARGET_ARCH"] in ["x86_64", "amd64", "emt64"]: LibPath += "_amd64"
|
|---|
| 70 | elif wxEnv["TARGET_ARCH"] in ["ia64"]: LibPath += "_ia64"
|
|---|
| 71 |
|
|---|
| 72 | LibPath += "_lib"
|
|---|
| 73 |
|
|---|
| 74 | wxEnv.Append(LIBPATH=[wxPath+LibPath])
|
|---|
| 75 |
|
|---|
| 76 | if buildMode=="dbg":
|
|---|
| 77 | wxEnv.Append(CPPPATH=[wxPath+LibPath+"/mswud"])
|
|---|
| 78 | wxEnv.Append(LIBS=Split("wxbase29ud wxbase29ud_net wxjpegd wxmsw29ud_adv wxmsw29ud_core wxmsw29ud_gl wxmsw29ud_aui wxmsw29ud_propgrid wxregexud"))
|
|---|
| 79 | else:
|
|---|
| 80 | wxEnv.Append(CPPPATH=[wxPath+LibPath+"/mswu"])
|
|---|
| 81 | wxEnv.Append(LIBS=Split("wxbase29u wxbase29u_net wxjpeg wxmsw29u_adv wxmsw29u_core wxmsw29u_gl wxmsw29u_aui wxmsw29u_propgrid wxregexu"))
|
|---|
| 82 |
|
|---|
| 83 | wxEnv.Append(CPPPATH=[wxPath+'/include']) # This must be appended *after* the LibPath-specific paths.
|
|---|
| 84 | wxEnv.Append(LIBS=Split("advapi32 comctl32 comdlg32 gdi32 ole32 oleaut32 opengl32 rpcrt4 shell32 user32 winspool wsock32"))
|
|---|
| 85 |
|
|---|
| 86 | elif sys.platform=="linux2":
|
|---|
| 87 | wxEnv.ParseConfig(Dir("#/ExtLibs/wxWidgets").abspath + "/build-gtk/wx-config --cxxflags --libs std,aui,gl,propgrid | sed 's/-l\\S*jpeg\\S*\\ //g'")
|
|---|
| 88 | wxEnv.Append(LIBS=Split("cairo pangocairo-1.0 X11"))
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | envCafu = wxEnv.Clone()
|
|---|
| 93 | envCafu.Append(CPPPATH=['ExtLibs/lua/src'])
|
|---|
| 94 |
|
|---|
| 95 | if sys.platform=="win32":
|
|---|
| 96 | envCafu.Append(LIBS=Split("SceneGraph MatSys SoundSys cfsLib cfs_jpeg bulletcollision minizip lua ClipSys png z"))
|
|---|
| 97 | envCafu.Append(LIBS=Split("lightwave")) # For the GuiSys::ModelWindowT class.
|
|---|
| 98 |
|
|---|
| 99 | WinResource = envCafu.RES("Ca3DE/Cafu.rc")
|
|---|
| 100 |
|
|---|
| 101 | elif sys.platform=="linux2":
|
|---|
| 102 | # -Wl,-rpath,. is so that also the . directory is searched for dynamic libraries when they're opened.
|
|---|
| 103 | # -Wl,--export-dynamic is so that the exe exports its symbols so that the MatSys, SoundSys and game .so libs can in turn resolve theirs.
|
|---|
| 104 | envCafu.Append(LINKFLAGS=['-Wl,-rpath,.', '-Wl,--export-dynamic'])
|
|---|
| 105 | envCafu.Append(LIBS=Split("MatSys SoundSys SceneGraph ClipSys"))
|
|---|
| 106 |
|
|---|
| 107 | # pthread is needed because some libraries that we load (possibly indirectly), e.g. the libCg.so and libopenal.so, use functions
|
|---|
| 108 | # from the pthread library, but have not been linked themselves against it. They rely on the executable to be linked appropriately
|
|---|
| 109 | # in order to resolve the pthread symbols. Paul Pluzhnikov states in a newsgroup posting (see [1]) that even if the .so libs were
|
|---|
| 110 | # linked against libpthread.so, the main exe still *must* link with -lpthread, too, because:
|
|---|
| 111 | # "Note that dlopen()ing an MT library from non-MT executable is not supported on most platforms, certainly not on Linux."
|
|---|
| 112 | # [1] http://groups.google.de/group/gnu.gcc.help/browse_thread/thread/1e8f8dfd6027d7fa/
|
|---|
| 113 | # rt is required in order to resolve clock_gettime() in openal-soft.
|
|---|
| 114 | envCafu.Append(LIBS=Split("GL rt pthread"))
|
|---|
| 115 |
|
|---|
| 116 | # Wrapping -lcfsLib in --whole-archive and --no-whole-archive is required so that the linker puts all symbols that are in libcfsLib.a
|
|---|
| 117 | # into the executable, because otherwise, it would omit e.g. some ParticleEngine-related stuff that is not referenced by the engine,
|
|---|
| 118 | # and when the game DLL later needs it, we get an "undefined symbol" error from dlopen().
|
|---|
| 119 | # See my post "Having the GNU linker *not* remove unused symbols..." to the gnu.g++.help newsgroup on 2006-04-07,
|
|---|
| 120 | # and the replies by Maett and Paul Pluzhnikov.
|
|---|
| 121 | # Implementing this by appending to LINKCOM is a SCons-specific hack though,
|
|---|
| 122 | # because SCons currently does not support such kind of "wrapping". See my post to the scons-users mailing list on 2006-04-09
|
|---|
| 123 | # at http://scons.tigris.org/servlets/BrowseList?list=users&by=thread&from=455553.
|
|---|
| 124 | # The "-llightwave, ..." are all needed as a direct consequence of the forced --whole-archive for cfsLib,
|
|---|
| 125 | # which in turn requires these...
|
|---|
| 126 | # Note that this (using --whole-archive) is actually the proper strategy under Linux (vs. Windows), because this is *the* way
|
|---|
| 127 | # in order to make sure that the -fPIC can be handled correctly - otherwise we had to link .so libs with non-fPIC object files...
|
|---|
| 128 | envCafu.Append(LINKCOM=" -Wl,--whole-archive -lcfsLib -lbulletdynamics -lbulletcollision -lbulletmath -Wl,--no-whole-archive -llua -llightwave -lminizip -lcfs_jpeg -lpng -lz")
|
|---|
| 129 |
|
|---|
| 130 | WinResource = []
|
|---|
| 131 |
|
|---|
| 132 | EngineCommonAndServerObjs = envCafu.StaticObject(Split("""Ca3DE/AppCafu.cpp Ca3DE/MainCanvas.cpp Ca3DE/MainFrame.cpp Ca3DE/ConDefs.cpp
|
|---|
| 133 | Ca3DE/Both/Ca3DEWorld.cpp Ca3DE/Both/EntityManager.cpp Ca3DE/Both/EngineEntity.cpp
|
|---|
| 134 | Ca3DE/Server/Server.cpp Ca3DE/Server/ServerWorld.cpp Ca3DE/Server/ClientInfo.cpp"""))
|
|---|
| 135 |
|
|---|
| 136 | appCafu = envCafu.Program('Ca3DE/Cafu',
|
|---|
| 137 | EngineCommonAndServerObjs + CommonWorldObject + ["Common/WorldMan.cpp"] + WinResource +
|
|---|
| 138 | Glob("Ca3DE/Client/*.cpp"))
|
|---|
| 139 |
|
|---|
| 140 | if sys.platform=="linux2":
|
|---|
| 141 | # This is a work-around for the fact that SCons doesn't automatically add dependencies for the libraries mentioned in LINKCOM.
|
|---|
| 142 | for LibName in Split("""cfsLib bulletdynamics bulletcollision bulletmath
|
|---|
| 143 | lua lightwave minizip cfs_jpeg"""): # png and z are not in the list, because we use the system libraries.
|
|---|
| 144 | LibFile = envCafu.FindFile("lib" + LibName + ".so", envCafu['LIBPATH'])
|
|---|
| 145 | if LibFile==None:
|
|---|
| 146 | LibFile = envCafu.FindFile("lib" + LibName + ".a", envCafu['LIBPATH'])
|
|---|
| 147 | # print "appCafu depends on: ", LibFile
|
|---|
| 148 | envCafu.Depends(appCafu, LibFile)
|
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 | envCaWE = wxEnv.Clone()
|
|---|
| 153 | envCaWE.Append(CPPPATH=['ExtLibs/lua/src', 'ExtLibs/noise/src'])
|
|---|
| 154 | envCaWE.Append(LIBS=Split("SceneGraph MatSys ClipSys cfsLib ModelLoaders cfs_jpeg bulletcollision noise lua minizip lightwave freetype png z"))
|
|---|
| 155 |
|
|---|
| 156 | SourceFilesList = (Glob("CaWE/*.cpp")
|
|---|
| 157 | +Glob("CaWE/FontWizard/*.cpp")
|
|---|
| 158 | +Glob("CaWE/GuiEditor/*.cpp")+Glob("CaWE/GuiEditor/Commands/*.cpp")+Glob("CaWE/GuiEditor/Windows/*.cpp")
|
|---|
| 159 | +Glob("CaWE/MapCommands/*.cpp")
|
|---|
| 160 | +Glob("CaWE/MaterialBrowser/*.cpp")
|
|---|
| 161 | +Glob("CaWE/ModelEditor/*.cpp")+Glob("CaWE/ModelEditor/Commands/*.cpp")
|
|---|
| 162 | +Glob("CaWE/wxExt/*.cpp")
|
|---|
| 163 | +Glob("CaWE/wxFB/*.cpp"))
|
|---|
| 164 |
|
|---|
| 165 | if sys.platform=="win32":
|
|---|
| 166 | SourceFilesList += envCaWE.RES("CaWE/CaWE.rc")
|
|---|
| 167 |
|
|---|
| 168 | if os.path.exists(Dir("#/ExtLibs/fbx/lib").abspath):
|
|---|
| 169 | envCaWE.Append(LIBPATH=["ExtLibs/fbx/lib/" +
|
|---|
| 170 | {"vc8": "vs2005", "vc9": "vs2008", "vc10": "vs2010"}[compiler] + "/" +
|
|---|
| 171 | ("x64" if envCaWE["TARGET_ARCH"] in ["x86_64", "amd64", "emt64"] else "x86")])
|
|---|
| 172 | envCaWE.Append(LIBS=["fbxsdk-2012.1-mdd" if buildMode=="dbg" else "fbxsdk-2012.1-md", "wininet"])
|
|---|
| 173 |
|
|---|
| 174 | elif sys.platform=="linux2":
|
|---|
| 175 | envCaWE.Append(CPPPATH=['/usr/include/freetype2']) # As of 2009-09-10, this line is to become unnecessary in the future, see /usr/include/ftbuild.h for details.
|
|---|
| 176 | envCaWE.Append(LINKFLAGS=['-Wl,-rpath,.']) # Have dlopen() consider "." when searching for SOs (e.g. libCg.so).
|
|---|
| 177 | envCaWE.Append(LINKFLAGS=['-Wl,--export-dynamic']) # Have our symbols available for dynamically loaded SOs (e.g. the renderer DLLs).
|
|---|
| 178 |
|
|---|
| 179 | if os.path.exists(Dir("#/ExtLibs/fbx/lib").abspath):
|
|---|
| 180 | envCaWE.Append(LIBPATH=["ExtLibs/fbx/lib/gcc4/" +
|
|---|
| 181 | ("x64" if platform.machine()=="x86_64" else "x86")])
|
|---|
| 182 | envCaWE.Append(LIBS=["fbxsdk-2012.1-staticd" if buildMode=="dbg" else "fbxsdk-2012.1-static"])
|
|---|
| 183 |
|
|---|
| 184 | envCaWE.Program('CaWE/CaWE', SourceFilesList + CommonWorldObject)
|
|---|