Index: CompilerSetup.py.tmpl
===================================================================
--- CompilerSetup.py.tmpl	(revision 103)
+++ CompilerSetup.py.tmpl	(working copy)
@@ -1,12 +1,47 @@
+# -*- coding: utf-8 -*-
+from SCons.Script import *
+
 # Edit the settings and paths in this file as required for your system.
 
-# The default compiler to be used for each platform.
-# Note that this can easily be overridden at the command-line
-# by the "cmp" parameter. Example: scons -Q cmp=vc8
-defaultCompilerWin32="vc9";     # Valid values are "vc8" and "vc9".
-defaultCompilerLinux="g++";     # Currently, only "g++" is a valid value.
 
+# envCommon is the common base environment for constructing all Cafu programs.
+# The base environment defines the target platform and architecture and the
+# compiler and other tools for the built. It is normally initialized without
+# any parameters, which means that the installed compiler and other details
+# are automatically detected.
+#
+# MSVC_VERSION sets the version of Visual C/C++ to use.
+#   Set it to an unexpected value (e.g. "XXX") to see the valid values for
+#   your system, such as "8.0", "8.0Exp", "9.0", "9.0Exp", "10.0", "10.0Exp".
+#   If not set, SCons will select the latest version of Visual C/C++ installed
+#   on your system.
+#
+# TARGET_ARCH sets the target architecture for the Visual C/C++ compiler.
+#   It it currently unused under Linux, where the host architecture determines
+#   the target architecture. Valid values are:
+#         "x86" or "i386" for 32 bit builds,
+#         "x86_64" or "amd64" for 64 bit builds,
+#         "ia64" for Itanium builds.
+#
+# Examples:
+#   # Print all valid values for MSVC_VERSION on your system.
+#   envCommon=Environment(MSVC_VERSION="XXX");
+#     
+#   # Use Visual C/C++ version 9 (2008), Express Edition.
+#   envCommon=Environment(MSVC_VERSION="9.0Exp");
+#     
+#   # Use the latest Visual C/C++ version for creating 32 bit binaries.
+#   envCommon=Environment(TARGET_ARCH="x86");
+#     
+#   # Use Visual C/C++ version 9 (2008) for creating 32 bit binaries.
+#   envCommon=Environment(MSVC_VERSION="9.0", TARGET_ARCH="x86");
+#
+# See the SCons man page at
+# <http://www.scons.org/doc/2.0.0.final.0/HTML/scons-man.html> for full
+# details about possible parameters to Environment().
+envCommon=Environment();
 
+
 # This string describes all program variants that should be built:
 # Insert a "d" for having all code being built in the debug   variant.
 # Insert a "p" for having all code being built in the profile variant.
Index: SConscript
===================================================================
--- SConscript	(revision 103)
+++ SConscript	(working copy)
@@ -154,7 +154,9 @@
     #   Note that we only (want to) determine the right library path matching the used compiler here.
     #   The specific wx-version used (e.g. latest stable vs. trunk) is still determined locally (here),
     #   BUT if this is moved into the SConstruct file, also the wx-version (wxPath above) must be fixed there.
-    LibPath="/lib/"+compiler+"_lib"
+    LibPath="/lib/"+compiler
+    if wxEnv["TARGET_ARCH"]: LibPath += "_"+wxEnv["TARGET_ARCH"];
+    LibPath += "_lib"
 
     wxEnv.Append(CPPPATH=['ExtLibs/freetype/include'])      # Linux builds (must) use the systems freetype library instead.
     wxEnv.Append(LIBPATH = [wxPath+LibPath])
Index: SConstruct
===================================================================
--- SConstruct	(revision 103)
+++ SConstruct	(working copy)
@@ -1,5 +1,4 @@
-import os, sys
-import CompilerSetup
+import os, shutil, sys
 
 
 # See the SCons manual, http://www.scons.org/wiki/GoFastButton and the man page for more information about the next two lines.
@@ -10,76 +9,47 @@
 print ""
 
 
-# Set the default compiler (platform dependent).
-if sys.platform=="win32":
-    compiler=ARGUMENTS.get("cmp", CompilerSetup.defaultCompilerWin32)
-elif sys.platform=="linux2":
-    compiler=ARGUMENTS.get("cmp", CompilerSetup.defaultCompilerLinux)
-else:
-    print "Unknown platform '" + sys.platform + "'."
-    exit
+try:
+    import CompilerSetup
+except ImportError:
+    # In order to make getting started with the Cafu source code more convenient, install the
+    # CompilerSetup.py file from the related template file (which is under version control) automatically.
+    shutil.copy("CompilerSetup.py.tmpl", "CompilerSetup.py")
+    import CompilerSetup
 
-# Set the list of variants (debug, profile, release) that should be built.
-BVs=ARGUMENTS.get("bv", CompilerSetup.buildVariants)
+# Import the (user-configured) base environment from the setup file.
+# The base environment is evaluated and further refined (e.g. with compiler-specific settings) below.
+envCommon=CompilerSetup.envCommon;
 
 
-# Set the build directories.
-my_build_dir="build/"+sys.platform+"/"+compiler
-my_build_dir_dbg=my_build_dir+"/debug"
-my_build_dir_rel=my_build_dir+"/release"
-my_build_dir_prf=my_build_dir+"/profile"
-
-CommonLibPaths=["#/ExtLibs/bullet/",
-                "#/ExtLibs/freealut/",
-                "#/ExtLibs/jpeg/",
-                "#/ExtLibs/libogg/",
-                "#/ExtLibs/libpng/",
-                "#/ExtLibs/libvorbis/",
-                "#/ExtLibs/lwo/",
-                "#/ExtLibs/lua/",
-                "#/ExtLibs/mpg123/",
-                "#/ExtLibs/noise/",
-                "#/ExtLibs/openal-soft/",
-                "#/ExtLibs/zlib/",
-                "#/Libs/"];
-
-if sys.platform=="win32":
-    # Only for Windows, as under Linux we must link to the systems freetype library.
-    CommonLibPaths.append("#/ExtLibs/freetype/");
-
-CommonLibPaths_dbg=[x+my_build_dir_dbg for x in CommonLibPaths];
-CommonLibPaths_rel=[x+my_build_dir_rel for x in CommonLibPaths];
-CommonLibPaths_prf=[x+my_build_dir_prf for x in CommonLibPaths];
-
-
 # This big if-else tree has a branch for each supported platform and each supported compiler.
 # For the chosen combination of platform and compiler, it prepares the environments envDebug, envRelease and envProfile.
 if sys.platform=="win32":
-    if compiler=="vc8":
-        ################################################
-        ### Win32, Visual C++ 2005 (Express Edition) ###
-        ################################################
+    if envCommon["MSVC_VERSION"] in ["8.0", "8.0Exp"]:
+        ##############################
+        ### Win32, Visual C++ 2005 ###
+        ##############################
 
+        compiler="vc8"
+
         # Reference of commonly used compiler switches:
-        # /EHsc    Enable exception handling.
-        # /GR      Enable RTTI.
-        # /J       Treat char as unsigned char.
-        # /MT      Use multi-threaded run-time libraries (statically linked into the exe). Defines _MT.
-        # /MTd     Use multi-threaded debug run-time libraries (statically linked into the exe). Defines _DEBUG and _MT.
-        # /nologo  No version and name banner.
-        # /Od      Disable optimizations.
-        # /O2      Fastest possible code.
-        # /Ob2     Inline expansion at compilers discretion.
-        # /RTC1    Run-Time Error Checks: Catch release-build errors in debug build.
-        # /W3      Warning level.
-        # /WX      Treat warnings as errors.
-        # /Z7      Include full debug info.
+        # /EHsc  Enable exception handling.
+        # /GR    Enable RTTI.
+        # /J     Treat char as unsigned char.
+        # /MT    Use multi-threaded run-time libraries (statically linked into the exe). Defines _MT.
+        # /MTd   Use multi-threaded debug run-time libraries (statically linked into the exe). Defines _DEBUG and _MT.
+        # /Od    Disable optimizations.
+        # /O2    Fastest possible code.
+        # /Ob2   Inline expansion at compilers discretion.
+        # /RTC1  Run-Time Error Checks: Catch release-build errors in debug build.
+        # /W3    Warning level.
+        # /WX    Treat warnings as errors.
+        # /Z7    Include full debug info.
 
         # Begin with an environment with settings that are common for debug, release and profile builds.
-        envCommon=Environment(
-            CCFLAGS = Split("/nologo /GR /EHsc"),   # CCFLAGS is also taken as the default value for CXXFLAGS.
-            CPPDEFINES = ["_CRT_SECURE_NO_DEPRECATE", "_CRT_NONSTDC_NO_DEPRECATE"],
-            LINKFLAGS = Split("/nologo /incremental:no"))
+        envCommon.Append(CCFLAGS = Split("/GR /EHsc"))   # CCFLAGS is also taken as the default value for CXXFLAGS.
+        envCommon.Append(CPPDEFINES = ["_CRT_SECURE_NO_DEPRECATE", "_CRT_NONSTDC_NO_DEPRECATE"])
+        envCommon.Append(LINKFLAGS = Split("/incremental:no"))
 
         # Explicitly instruct SCons to detect and use the Microsoft Platform SDK, as it is not among the default tools.
         # See thread "Scons 2010/01/17 doesn't look for MS SDK?" at <http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2455554>
@@ -100,19 +70,20 @@
         envProfile.Append(CCFLAGS=Split("/MT /O2 /Ob2 /Z7"));
         envProfile.Append(LINKFLAGS=["/fixed:no", "/debug"]);
 
-    elif compiler=="vc9":
-        ################################################
-        ### Win32, Visual C++ 2008 (Express Edition) ###
-        ################################################
+    elif envCommon["MSVC_VERSION"] in ["9.0", "9.0Exp"]:
+        ##############################
+        ### Win32, Visual C++ 2008 ###
+        ##############################
 
+        compiler="vc9"
+
         # Reference of commonly used compiler switches:
         # Identical to the compiler switches for Visual C++ 2005, see there for more details.
 
         # Begin with an environment with settings that are common for debug, release and profile builds.
-        envCommon=Environment(
-            CCFLAGS = Split("/nologo /GR /EHsc"),   # CCFLAGS is also taken as the default value for CXXFLAGS.
-            CPPDEFINES = ["_CRT_SECURE_NO_DEPRECATE", "_CRT_NONSTDC_NO_DEPRECATE"],
-            LINKFLAGS = Split("/nologo /incremental:no"))
+        envCommon.Append(CCFLAGS = Split("/GR /EHsc"))   # CCFLAGS is also taken as the default value for CXXFLAGS.
+        envCommon.Append(CPPDEFINES = ["_CRT_SECURE_NO_DEPRECATE", "_CRT_NONSTDC_NO_DEPRECATE"])
+        envCommon.Append(LINKFLAGS = Split("/incremental:no"))
 
         # Explicitly instruct SCons to detect and use the Microsoft Platform SDK, as it is not among the default tools.
         # See thread "Scons 2010/01/17 doesn't look for MS SDK?" at <http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2455554>
@@ -133,71 +104,58 @@
         envProfile.Append(CCFLAGS=Split("/MT /O2 /Ob2 /Z7"));
         envProfile.Append(LINKFLAGS=["/fixed:no", "/debug"]);
 
-    elif compiler=="ow":
-        #########################
-        ### Win32, OpenWatcom ###
-        #########################
+    elif envCommon["MSVC_VERSION"] in ["10.0", "10.0Exp"]:
+        ##############################
+        ### Win32, Visual C++ 2010 ###
+        ##############################
 
+        compiler="vc10"
+
         # Reference of commonly used compiler switches:
-        # -5r     Pentium register based calling.
-        # -bt=nt  Compile for NT.
-        # -d2     Full debug info (required for wdw and wprof).
-        # -e25    Stop compilation after 25 errors.
-        # -od     No optimizations.
-        # -otexan Fastest possible code.
-        # -w8     Enable all warnings.
-        # -we     Treat warnings as errors.
-        # -zp8    8-byte structure alignment.
-        # -zq     Quiet operation.
-        # -xr     Enable Run-time type information. According to docs, comes with no execution (speed) penalty at all, except for the use of dynamic_cast.
-        # -xs     Enable exceptions.
+        # Identical to the compiler switches for Visual C++ 2005, see there for more details.
 
         # Begin with an environment with settings that are common for debug, release and profile builds.
-        envCommon=Environment(
-            CXX = "wpp386",
-            CCFLAGS = Split("-e25 -zq -5r -bt=nt -xr -xs"),     # CCFLAGS is also taken as the default value for CXXFLAGS.
-            LINK = "wlink",
-            LINKFLAGS = ["option quiet"])
+        envCommon.Append(CCFLAGS = Split("/GR /EHsc"))   # CCFLAGS is also taken as the default value for CXXFLAGS.
+        envCommon.Append(CPPDEFINES = ["_CRT_SECURE_NO_DEPRECATE", "_CRT_NONSTDC_NO_DEPRECATE"])
+        envCommon.Append(LINKFLAGS = Split("/incremental:no"))
 
-        # Compiler system environment paths.
-        watcom_base="D:\\Programme\\OpenWatcom\\OW13RC3"
+        # Explicitly instruct SCons to detect and use the Microsoft Platform SDK, as it is not among the default tools.
+        # See thread "Scons 2010/01/17 doesn't look for MS SDK?" at <http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2455554>
+        # for further information.
+        envCommon.Tool('mssdk')
 
-        envCommon['ENV']['PATH'   ]="%s\\binnt;%s\\binw" % (watcom_base, watcom_base)
-        envCommon['ENV']['INCLUDE']="%s\\h;%s\\h\\nt" % (watcom_base, watcom_base)
-        envCommon['ENV']['LIB'    ]="%s\\lib386;%s\\lib386\\nt" % (watcom_base, watcom_base)
-
-
         # Environment for debug builds:
         envDebug=envCommon.Clone();
-        envDebug.Append(CCFLAGS=Split("-d2 -od"));
-        envDebug.Append(LINKFLAGS=["debug all"]);
+        envDebug.Append(CCFLAGS=Split("/MTd /Od /Z7 /RTC1"));
+        envDebug.Append(LINKFLAGS=["/debug"]);
 
         # Environment for release builds:
         envRelease=envCommon.Clone();
-        envRelease.Append(CCFLAGS=Split("-zp8 -otexan"));
+        envRelease.Append(CCFLAGS=Split("/MT /O2 /Ob2"));
 
         # Environment for profile builds:
         envProfile=envCommon.Clone();
-        envProfile.Append(CCFLAGS=Split("-zp8 -otexan -d2"));
-        envProfile.Append(LINKFLAGS=["debug all"]);
+        envProfile.Append(CCFLAGS=Split("/MT /O2 /Ob2 /Z7"));
+        envProfile.Append(LINKFLAGS=["/fixed:no", "/debug"]);
 
     else:
         ###############################
         ### Win32, unknown compiler ###
         ###############################
 
-        print "Unknown compiler " + compiler + " on platform " + sys.platform + "."
+        print "Unknown compiler on platform " + sys.platform + "."
         exit
 
 elif sys.platform=="linux2":
-    if compiler=="g++":
+    if envCommon["CXX"]=="g++":
         ##################
         ### Linux, g++ ###
         ##################
 
+        compiler="g++"
+
         # Begin with an environment with settings that are common for debug, release and profile builds.
-        envCommon=Environment(
-            CCFLAGS = Split(""))     # CCFLAGS is also taken as the default value for CXXFLAGS.
+        envCommon.Append(CCFLAGS = Split(""))   # CCFLAGS is also taken as the default value for CXXFLAGS.
 
         # Environment for debug builds:
         envDebug=envCommon.Clone();
@@ -217,7 +175,7 @@
         ### Linux, unknown compiler ###
         ###############################
 
-        print "Unknown compiler " + compiler + " on platform " + sys.platform + "."
+        print "Unknown compiler " + envCommon["CXX"] + " on platform " + sys.platform + "."
         exit
 
 else:
@@ -233,67 +191,44 @@
 ### Build all external libraries ###
 ####################################
 
-if "d" in BVs: SConscript('ExtLibs/bullet/src/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/bullet/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/bullet/src/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/bullet/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/bullet/src/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/bullet/"+my_build_dir_prf, duplicate=0)
+# Set the list of variants (debug, profile, release) that should be built.
+BVs=ARGUMENTS.get("bv", CompilerSetup.buildVariants)
 
-if "d" in BVs: SConscript('ExtLibs/freealut/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/freealut/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/freealut/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/freealut/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/freealut/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/freealut/"+my_build_dir_prf, duplicate=0)
+# Set the build directories.
+my_build_dir="build/"+sys.platform+"/"+compiler
+if envCommon["TARGET_ARCH"]: my_build_dir += "/"+envCommon["TARGET_ARCH"];
 
-if "d" in BVs: SConscript('ExtLibs/freetype/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/freetype/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/freetype/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/freetype/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/freetype/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/freetype/"+my_build_dir_prf, duplicate=0)
+my_build_dir_dbg=my_build_dir+"/debug"
+my_build_dir_rel=my_build_dir+"/release"
+my_build_dir_prf=my_build_dir+"/profile"
 
-if "d" in BVs: SConscript('ExtLibs/jpeg/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/jpeg/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/jpeg/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/jpeg/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/jpeg/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/jpeg/"+my_build_dir_prf, duplicate=0)
 
-if "d" in BVs: SConscript('ExtLibs/libogg/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/libogg/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/libogg/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/libogg/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/libogg/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/libogg/"+my_build_dir_prf, duplicate=0)
+for lib_name in ["bullet", "freealut", "freetype", "jpeg", "libogg", "libpng", "libvorbis", "lwo", "lua", "mpg123", "noise", "openal-soft", "zlib"]:
+    s_name=lib_name
 
-if "d" in BVs: SConscript('ExtLibs/libpng/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/libpng/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/libpng/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/libpng/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/libpng/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/libpng/"+my_build_dir_prf, duplicate=0)
+    if lib_name=="openal-soft" and sys.platform=="win32": continue;     # OpenAL-Soft is not built on Windows, use the OpenAL Windows SDK there.
+    if lib_name=="bullet": s_name+="/src";
+    if lib_name=="lua":    s_name+="/src";
+    if lib_name=="mpg123": s_name+="/src/libmpg123";
 
-if "d" in BVs: SConscript('ExtLibs/libvorbis/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/libvorbis/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/libvorbis/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/libvorbis/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/libvorbis/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/libvorbis/"+my_build_dir_prf, duplicate=0)
+    if "d" in BVs: SConscript("ExtLibs/"+s_name+"/SConscript", exports={ "env": envDebug },   variant_dir="ExtLibs/"+lib_name+"/"+my_build_dir_dbg, duplicate=0)
+    if "r" in BVs: SConscript("ExtLibs/"+s_name+"/SConscript", exports={ "env": envRelease }, variant_dir="ExtLibs/"+lib_name+"/"+my_build_dir_rel, duplicate=0)
+    if "p" in BVs: SConscript("ExtLibs/"+s_name+"/SConscript", exports={ "env": envProfile }, variant_dir="ExtLibs/"+lib_name+"/"+my_build_dir_prf, duplicate=0)
 
-if "d" in BVs: SConscript('ExtLibs/lwo/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/lwo/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/lwo/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/lwo/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/lwo/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/lwo/"+my_build_dir_prf, duplicate=0)
 
-if "d" in BVs: SConscript('ExtLibs/lua/src/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/lua/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/lua/src/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/lua/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/lua/src/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/lua/"+my_build_dir_prf, duplicate=0)
-
-if "d" in BVs: SConscript('ExtLibs/mpg123/src/libmpg123/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/mpg123/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/mpg123/src/libmpg123/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/mpg123/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/mpg123/src/libmpg123/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/mpg123/"+my_build_dir_prf, duplicate=0)
-
-if "d" in BVs: SConscript('ExtLibs/noise/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/noise/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/noise/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/noise/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/noise/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/noise/"+my_build_dir_prf, duplicate=0)
-
-if sys.platform!="win32":
-    # OpenAL-Soft is not built on Windows, use the OpenAL Windows SDK there.
-    if "d" in BVs: SConscript('ExtLibs/openal-soft/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/openal-soft/"+my_build_dir_dbg, duplicate=0)
-    if "r" in BVs: SConscript('ExtLibs/openal-soft/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/openal-soft/"+my_build_dir_rel, duplicate=0)
-    if "p" in BVs: SConscript('ExtLibs/openal-soft/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/openal-soft/"+my_build_dir_prf, duplicate=0)
-
-if "d" in BVs: SConscript('ExtLibs/zlib/SConscript', exports={'env':envDebug},   variant_dir="ExtLibs/zlib/"+my_build_dir_dbg, duplicate=0)
-if "r" in BVs: SConscript('ExtLibs/zlib/SConscript', exports={'env':envRelease}, variant_dir="ExtLibs/zlib/"+my_build_dir_rel, duplicate=0)
-if "p" in BVs: SConscript('ExtLibs/zlib/SConscript', exports={'env':envProfile}, variant_dir="ExtLibs/zlib/"+my_build_dir_prf, duplicate=0)
-
 # Compile wxWidgets for the current platform.
 if sys.platform=="win32":
-    # Make sure the "compiler" string begins with "vc" and is three characters long.
-    if compiler[0]=='v' and compiler[1]=='c' and len(compiler)==3:
-        result=envDebug.  Execute("nmake /nologo /f makefile.vc BUILD=debug   SHARED=0 USE_OPENGL=1 RUNTIME_LIBS=static COMPILER_PREFIX="+compiler, chdir="ExtLibs/wxWidgets/build/msw");
+    if compiler.startswith("vc"):
+        c_prefix="COMPILER_PREFIX="+compiler
+        if envCommon["TARGET_ARCH"]: c_prefix += "_"+envCommon["TARGET_ARCH"];
+
+        if   envCommon["TARGET_ARCH"] in ["x86_64", "amd64", "emt64"]: target_cpu=" TARGET_CPU=AMD64"
+        elif envCommon["TARGET_ARCH"] in ["ia64"]:                     target_cpu=" TARGET_CPU=IA64"
+        else:                                                          target_cpu=""
+
+        result=envDebug.  Execute("nmake /nologo /f makefile.vc BUILD=debug   SHARED=0 USE_OPENGL=1 RUNTIME_LIBS=static "+c_prefix+target_cpu, chdir="ExtLibs/wxWidgets/build/msw");
         if (result!=0): envDebug.  Exit(result);
-        result=envRelease.Execute("nmake /nologo /f makefile.vc BUILD=release SHARED=0 USE_OPENGL=1 RUNTIME_LIBS=static COMPILER_PREFIX="+compiler, chdir="ExtLibs/wxWidgets/build/msw");
+        result=envRelease.Execute("nmake /nologo /f makefile.vc BUILD=release SHARED=0 USE_OPENGL=1 RUNTIME_LIBS=static "+c_prefix+target_cpu, chdir="ExtLibs/wxWidgets/build/msw");
         if (result!=0): envRelease.Exit(result);
         print "";   # Print just another empty line for better visual separation.
 
@@ -335,9 +270,11 @@
     envRelease.Install(".", ["#/ExtLibs/Cg/bin/cg.dll", "#/ExtLibs/Cg/bin/cgGL.dll"]);
     envRelease.Install(".", ["#/ExtLibs/fmod/api/fmod.dll"]);
     envRelease.Install(".", ["#/ExtLibs/openal-win/OpenAL32.dll", "#/ExtLibs/openal-win/wrap_oal.dll"]);
+
     if "r" in BVs:
         envRelease.Install(".", ["#/ExtLibs/freealut/"+my_build_dir_rel+"/alut.dll"]);
         envRelease.Install(".", ["#/ExtLibs/mpg123/"+my_build_dir_rel+"/mpg123.dll"]);
+
     else:
         envRelease.Install(".", ["#/ExtLibs/freealut/"+my_build_dir_dbg+"/alut.dll"]);
         envRelease.Install(".", ["#/ExtLibs/mpg123/"+my_build_dir_dbg+"/mpg123.dll"]);
@@ -345,10 +282,12 @@
 elif sys.platform=="linux2":
     envRelease.Install(".", ["#/ExtLibs/Cg/lib/libCg.so", "#/ExtLibs/Cg/lib/libCgGL.so"]);
     envRelease.Install(".", ["#/ExtLibs/fmod/api/libfmod-3.75.so"]);
+
     if "r" in BVs:
         envRelease.Install(".", ["#/ExtLibs/freealut/"+my_build_dir_rel+"/libalut.so"]);
         envRelease.Install(".", ["#/ExtLibs/mpg123/"+my_build_dir_rel+"/libmpg123.so"]);
         envRelease.Install(".", ["#/ExtLibs/openal-soft/"+my_build_dir_rel+"/libopenal.so"]);
+
     else:
         envRelease.Install(".", ["#/ExtLibs/freealut/"+my_build_dir_dbg+"/libalut.so"]);
         envRelease.Install(".", ["#/ExtLibs/mpg123/"+my_build_dir_dbg+"/libmpg123.so"]);
@@ -359,6 +298,29 @@
 ### Update the construction environments ###
 ############################################
 
+CommonLibPaths=["#/ExtLibs/bullet/",
+                "#/ExtLibs/freealut/",
+                "#/ExtLibs/jpeg/",
+                "#/ExtLibs/libogg/",
+                "#/ExtLibs/libpng/",
+                "#/ExtLibs/libvorbis/",
+                "#/ExtLibs/lwo/",
+                "#/ExtLibs/lua/",
+                "#/ExtLibs/mpg123/",
+                "#/ExtLibs/noise/",
+                "#/ExtLibs/openal-soft/",
+                "#/ExtLibs/zlib/",
+                "#/Libs/"];
+
+if sys.platform=="win32":
+    # Only for Windows, as under Linux we must link to the systems freetype library.
+    CommonLibPaths.append("#/ExtLibs/freetype/");
+
+CommonLibPaths_dbg=[x+my_build_dir_dbg for x in CommonLibPaths];
+CommonLibPaths_rel=[x+my_build_dir_rel for x in CommonLibPaths];
+CommonLibPaths_prf=[x+my_build_dir_prf for x in CommonLibPaths];
+
+
 # Note that modifying the original environments here affects the build of the external libraries above!
 envDebug_Cafu  =envDebug.Clone();
 envRelease_Cafu=envRelease.Clone();
@@ -380,14 +342,17 @@
     envDebug_Cafu  .Append(CCFLAGS=Split("/J /W3 /WX"));
     envRelease_Cafu.Append(CCFLAGS=Split("/J /W3 /WX"));
     envProfile_Cafu.Append(CCFLAGS=Split("/J /W3 /WX"));
+
 elif compiler=="vc9":
     envDebug_Cafu  .Append(CCFLAGS=Split("/J /W3 /WX"));
     envRelease_Cafu.Append(CCFLAGS=Split("/J /W3 /WX"));
     envProfile_Cafu.Append(CCFLAGS=Split("/J /W3 /WX"));
-elif compiler=="ow":
-    envDebug_Cafu  .Append(CCFLAGS=Split("-w8 -we"));
-    envRelease_Cafu.Append(CCFLAGS=Split("-w8 -we"));
-    envProfile_Cafu.Append(CCFLAGS=Split("-w8 -we"));
+
+elif compiler=="vc10":
+    envDebug_Cafu  .Append(CCFLAGS=Split("/J /W3 /WX"));
+    envRelease_Cafu.Append(CCFLAGS=Split("/J /W3 /WX"));
+    envProfile_Cafu.Append(CCFLAGS=Split("/J /W3 /WX"));
+
 elif compiler=="g++":
     envDebug_Cafu  .Append(CCFLAGS=Split("-funsigned-char -Wall -Werror -Wno-char-subscripts"));
     envRelease_Cafu.Append(CCFLAGS=Split("-funsigned-char -Wall -Werror -Wno-char-subscripts -fno-strict-aliasing"));

