Index: build/premake/extern_libs4.lua
===================================================================
--- build/premake/extern_libs4.lua	(revision 15764)
+++ 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()
@@ -357,6 +361,7 @@
 				win_names  = { "libiconv" },
 				-- TODO: glibc provides symbols for this, so we should only include that (and depend on libiconv) on non-glibc unix
 				osx_names = { "iconv" },
+				bsd_names = { "iconv" },
 				dbg_suffix = "",
 			})
 		end,
Index: build/premake/premake4.lua
===================================================================
--- build/premake/premake4.lua	(revision 15764)
+++ build/premake/premake4.lua	(working copy)
@@ -37,6 +37,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
@@ -50,7 +57,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()
@@ -108,7 +115,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)
@@ -392,9 +399,12 @@
 	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" }
Index: libraries/source/fcollada/src/FCollada/FUtils/FUStringConversion.cpp
===================================================================
--- libraries/source/fcollada/src/FCollada/FUtils/FUStringConversion.cpp	(revision 15764)
+++ 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 15764)
+++ 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;
 				}
 

