Index: build/premake/extern_libs4.lua
===================================================================
--- build/premake/extern_libs4.lua	(revision 15785)
+++ build/premake/extern_libs4.lua	(working copy)
@@ -235,7 +235,8 @@
 				-- Suppress all the Boost warnings on OS X by including it as a system directory
 				buildoptions { "-isystem../" .. libraries_dir .. "boost/include" }
 			end
-			if os.getversion().description == "OpenBSD" then
+			-- TODO This actually applies to most libraries we use on BSDs, make this a global setting.
+			if os.is("bsd") then
 				includedirs { "/usr/local/include" }
 			end
 		end,
@@ -347,6 +348,9 @@
 			elseif os.is("macosx") then
 				add_default_include_paths("iconv")
 				defines { "LIBICONV_STATIC" }
+			-- TODO Check OpenBSD 
+			elseif os.getversion().description == "FreeBSD" then
+				defines { "HAVE_ICONV_CONST" }
 			end
 		end,
 		link_settings = function()
@@ -359,6 +363,13 @@
 				osx_names = { "iconv" },
 				dbg_suffix = "",
 			})
+			-- FreeBSD 10 and up have iconv in libc
+			-- TODO: Check other BSDs
+			if(not (os.getversion().description == "FreeBSD" and os.getversion().majorversion >= 10)) then
+				add_default_links({
+					bsd_names = { "iconv" }
+				})
+			end
 		end,
 	},
 	icu = {
Index: build/premake/premake4.lua
===================================================================
--- build/premake/premake4.lua	(revision 15785)
+++ build/premake/premake4.lua	(working copy)
@@ -38,6 +38,13 @@
 
 dofile("extern_libs4.lua")
 
+cc = os.getenv("CC") 
+if cc == nil or cc == "" then 
+	-- TODO check if gcc exists and not on OS X 
+	--      else use clang if present 
+	cc = "gcc" 
+end 
+
 -- detect CPU architecture (simplistic, currently only supports x86, amd64 and ARM)
 arch = "x86"
 if _OPTIONS["android"] then
@@ -51,7 +58,7 @@
 	if arch == "x86_64" or arch == "amd64" then
 		arch = "amd64"
 	else
-		os.execute("gcc -dumpmachine > .gccmachine.tmp")
+		os.execute(cc .. " -dumpmachine > .gccmachine.tmp")
 		local f = io.open(".gccmachine.tmp", "r")
 		local machine = f:read("*line")
 		f:close()
@@ -109,7 +116,7 @@
 	-- It's too late to do this test by the time we start compiling the PCH file, so
 	-- do the test in this build script instead (which is kind of ugly - please fix if
 	-- you have a better idea)
-	if not _OPTIONS["icc"] then
+	if not _OPTIONS["icc"] and cc == "gcc" then
 		os.execute("gcc -dumpversion > .gccver.tmp")
 		local f = io.open(".gccver.tmp", "r")
 		major, dot, minor = f:read(1, 1, 1)
@@ -393,12 +400,18 @@
 	if not os.is("windows") and not os.is("macosx") then
 		-- X11 includes may be installed in one of a gadzillion of three places
 		-- Famous last words: "You can't include too much! ;-)"
+		-- TODO update comment (or add /usr/local/ as an include search path for BSDs)
 		includedirs {
 			"/usr/X11R6/include/X11",
 			"/usr/X11R6/include",
+			"/usr/local/include/X11",
+			"/usr/local/include",
 			"/usr/include/X11"
 		}
-		libdirs { "/usr/X11R6/lib" }
+		libdirs {
+			"/usr/X11R6/lib",
+			"/usr/local/lib"
+		 }
 	end
 end
 
Index: libraries/source/fcollada/src/FCollada/FUtils/FUStringConversion.cpp
===================================================================
--- libraries/source/fcollada/src/FCollada/FUtils/FUStringConversion.cpp	(revision 15785)
+++ libraries/source/fcollada/src/FCollada/FUtils/FUStringConversion.cpp	(working copy)
@@ -247,6 +247,7 @@
 template FMVector4 FUStringConversion::ToVector4<char>(const char**);
 
 template bool FUStringConversion::ToBoolean<char>(const char*);
+template int FUStringConversion::ToInt32<char>(const char**);
 template unsigned int FUStringConversion::ToUInt32<char>(const char**);
 template unsigned int FUStringConversion::HexToUInt32<char>(const char**, unsigned int);
 
Index: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp
===================================================================
--- source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp	(revision 15785)
+++ source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp	(working copy)
@@ -158,7 +158,7 @@
 					wxString x(xmlData->GetNodeContent());
 					unsigned long xTmp = 0;
 					x.ToULong(&xTmp);
-					wxASSERT(xTmp <= (unsigned long)UINT32_MAX);
+					wxASSERT(xTmp <= (unsigned long)std::numeric_limits<unsigned int>::max());
 					actorSeed = xTmp;
 				}
 
Index: source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp
===================================================================
--- source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp	(revision 15785)
+++ source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp	(working copy)
@@ -146,7 +146,7 @@
 	void Do()
 	{
 		m_OldSettings = GetSettings();
-		m_NewSettings = msg->settings;
+		m_NewSettings = msg->settings._Unwrap();
 		Redo();
 	}
 
