Index: build/premake/premake4/src/base/os.lua
===================================================================
--- build/premake/premake4/src/base/os.lua	(revision 11967)
+++ build/premake/premake4/src/base/os.lua	(working copy)
@@ -1,7 +1,7 @@
 --
 -- os.lua
 -- Additions to the OS namespace.
--- Copyright (c) 2002-2010 Jason Perkins and the Premake project
+-- Copyright (c) 2002-2011 Jason Perkins and the Premake project
 --
 
 
@@ -26,6 +26,9 @@
 		if os.is("windows") then
 			formats = { "%s.dll", "%s" }
 			path = os.getenv("PATH")
+		elseif os.is("haiku") then
+			formats = { "lib%s.so", "%s.so" }
+			path = os.getenv("LIBRARY_PATH")
 		else
 			if os.is("macosx") then
 				formats = { "lib%s.dylib", "%s.dylib" }
@@ -43,7 +46,7 @@
 				end
 			end
 			
-			table.insert(formats, "%s")	
+			table.insert(formats, "%s")
 			path = (path or "") .. ":/lib:/usr/lib:/usr/local/lib"
 		end
 		
@@ -180,6 +183,18 @@
 
 
 --
+-- Run a shell command and return the output.
+--
+
+	function os.outputof(cmd)
+		local pipe = io.popen(cmd)
+		local result = pipe:read('*a')
+		pipe:close()
+		return result
+	end
+
+
+--
 -- Remove a directory, along with any contained files or subdirectories.
 --
 
Index: build/premake/premake4/src/host/os_getversion.c
===================================================================
--- build/premake/premake4/src/host/os_getversion.c	(revision 0)
+++ build/premake/premake4/src/host/os_getversion.c	(working copy)
@@ -0,0 +1,232 @@
+/**
+ * \file   os_getversioninfo.c
+ * \brief  Retrieve operating system version information.
+ * \author Copyright (c) 2011 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+
+struct OsVersionInfo
+{
+	int majorversion;
+	int minorversion;
+	int revision;
+	const char* description;
+} ;
+
+static void getversion(struct OsVersionInfo* info);
+
+int os_getversion(lua_State* L)
+{
+	struct OsVersionInfo info;
+	getversion(&info);
+
+	lua_newtable(L);
+
+	lua_pushstring(L, "majorversion");
+	lua_pushnumber(L, info.majorversion);
+	lua_settable(L, -3);
+
+	lua_pushstring(L, "minorversion");
+	lua_pushnumber(L, info.minorversion);
+	lua_settable(L, -3);
+
+	lua_pushstring(L, "revision");
+	lua_pushnumber(L, info.revision);
+	lua_settable(L, -3);
+
+	lua_pushstring(L, "description");
+	lua_pushstring(L, info.description);
+	lua_settable(L, -3);
+
+	return 1;
+}
+
+/*************************************************************/
+
+#if defined(PLATFORM_WINDOWS)
+
+#if !defined(VER_SUITE_WH_SERVER)
+#define VER_SUITE_WH_SERVER   (0x00008000)
+#endif
+
+#ifndef SM_SERVERR2
+#	define SM_SERVERR2 89
+#endif
+
+SYSTEM_INFO getsysteminfo()
+{
+	typedef void (WINAPI *GetNativeSystemInfoSig)(LPSYSTEM_INFO);
+	GetNativeSystemInfoSig nativeSystemInfo = (GetNativeSystemInfoSig)
+	GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetNativeSystemInfo");
+
+	SYSTEM_INFO systemInfo = {{0}};
+	if ( nativeSystemInfo ) nativeSystemInfo(&systemInfo);
+	else GetSystemInfo(&systemInfo);
+	return systemInfo;
+}
+
+void getversion(struct OsVersionInfo* info)
+{
+	OSVERSIONINFOEX versionInfo = {0};
+
+	versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+	GetVersionEx((OSVERSIONINFO*)&versionInfo);
+
+	info->majorversion = versionInfo.dwMajorVersion;
+	info->minorversion = versionInfo.dwMinorVersion;
+	info->revision = versionInfo.wServicePackMajor;
+
+	if (versionInfo.dwMajorVersion == 5 && versionInfo.dwMinorVersion == 0)
+	{
+		info->description = "Windows 2000";
+	}
+	else if (versionInfo.dwMajorVersion == 5 && versionInfo.dwMinorVersion == 1)
+	{
+		info->description = "Windows XP";
+	}
+	else if (versionInfo.dwMajorVersion == 5 && versionInfo.dwMinorVersion == 2)
+	{
+		SYSTEM_INFO systemInfo = getsysteminfo();
+		if (versionInfo.wProductType == VER_NT_WORKSTATION &&
+			systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
+		{
+			info->description = "Windows XP Professional x64";
+		}
+		else if (versionInfo.wSuiteMask & VER_SUITE_WH_SERVER)
+		{
+			info->description = "Windows Home Server";
+		}
+		else if (GetSystemMetrics(SM_SERVERR2) == 0)
+		{
+			info->description = "Windows Server 2003";
+		}
+		else
+		{
+			info->description = "Windows Server 2003 R2";
+		}
+	}
+	else if (versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion == 0)
+	{
+		if (versionInfo.wProductType == VER_NT_WORKSTATION)
+		{
+			info->description = "Windows Vista";
+		}
+		else
+		{
+			info->description = "Windows Server 2008";
+		}
+	}
+	else if (versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion == 1 )
+	{
+		if (versionInfo.wProductType != VER_NT_WORKSTATION)
+		{
+			info->description = "Windows Server 2008 R2";
+		}
+		else
+		{
+			info->description = "Windows 7";
+		}
+	}
+	else
+	{
+		info->description = "Windows";
+	}
+}
+
+/*************************************************************/
+
+#elif defined(PLATFORM_MACOSX)
+
+#include <CoreServices/CoreServices.h>
+
+void getversion(struct OsVersionInfo* info)
+{
+	SInt32 majorversion, minorversion, bugfix;
+	Gestalt(gestaltSystemVersionMajor, &majorversion);
+	Gestalt(gestaltSystemVersionMinor, &minorversion);
+	Gestalt(gestaltSystemVersionBugFix, &bugfix);
+
+	info->majorversion = majorversion;
+	info->minorversion = minorversion;
+	info->revision = bugfix;
+
+	info->description = "Mac OS X";
+	if (info->majorversion == 10)
+	{
+		switch (info->minorversion)
+		{
+		case 4:
+			info->description = "Mac OS X Tiger";
+			break;
+		case 5:
+			info->description = "Mac OS X Leopard";
+			break;
+		case 6:
+			info->description = "Mac OS X Snow Leopard";
+			break;
+		case 7:
+			info->description = "Mac OS X Lion";
+			break;
+		}
+	}
+}
+
+/*************************************************************/
+
+#elif defined(PLATFORM_BSD) || defined(PLATFORM_LINUX) || defined(PLATFORM_SOLARIS)
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/utsname.h>
+
+void getversion(struct OsVersionInfo* info)
+{
+	struct utsname u;
+	char* ver;
+
+	info->majorversion = 0;
+	info->minorversion = 0;
+	info->revision = 0;
+
+	if (uname(&u))
+	{
+		// error
+		info->description = PLATFORM_STRING;
+		return;
+	}
+
+#if !defined(PLATFORM_LINUX)
+	info->description = u.sysname;
+#else
+	// On Linux info->sysname gets set, but it isn't passed out of this function
+	info->description = "Linux";
+#endif
+
+	if ((ver = strtok(u.release, ".-")) != NULL)
+	{
+		info->majorversion = atoi(ver);
+		// continue parsing from the previous position
+		if ((ver = strtok(NULL, ".-")) != NULL)
+		{
+			info->minorversion = atoi(ver);
+			if ((ver = strtok(NULL, ".-")) != NULL)
+				info->revision = atoi(ver);
+		}
+	}
+}
+
+/*************************************************************/
+
+#else
+
+void getversion(struct OsVersionInfo* info)
+{
+	info->majorversion = 0;
+	info->minorversion = 0;
+	info->revision = 0;
+	info->description = PLATFORM_STRING;
+}
+
+#endif
+
Index: build/premake/premake4/src/host/premake.c
===================================================================
--- build/premake/premake4/src/host/premake.c	(revision 11967)
+++ build/premake/premake4/src/host/premake.c	(working copy)
@@ -38,6 +38,7 @@
 	{ "copyfile",    os_copyfile    },
 	{ "isdir",       os_isdir       },
 	{ "getcwd",      os_getcwd      },
+	{ "getversion",  os_getversion  },
 	{ "isfile",      os_isfile      },
 	{ "matchdone",   os_matchdone   },
 	{ "matchisfile", os_matchisfile },
Index: build/premake/premake4/src/host/premake.h
===================================================================
--- build/premake/premake4/src/host/premake.h	(revision 11967)
+++ build/premake/premake4/src/host/premake.h	(working copy)
@@ -1,7 +1,7 @@
 /**
  * \file   premake.h
  * \brief  Program-wide constants and definitions.
- * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ * \author Copyright (c) 2002-2011 Jason Perkins and the Premake project
  */
 
 #define lua_c
@@ -15,7 +15,7 @@
 #if defined(__linux__)
 #define PLATFORM_LINUX    (1)
 #define PLATFORM_STRING   "linux"
-#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
 #define PLATFORM_BSD      (1)
 #define PLATFORM_STRING   "bsd"
 #elif defined(__APPLE__) && defined(__MACH__)
@@ -24,6 +24,9 @@
 #elif defined(__sun__) && defined(__svr4__)
 #define PLATFORM_SOLARIS  (1)
 #define PLATFORM_STRING   "solaris"
+#elif defined(__HAIKU__)
+#define PLATFORM_HAIKU    (1)
+#define PLATFORM_STRING   "haiku"
 #else
 #define PLATFORM_WINDOWS  (1) 
 #define PLATFORM_STRING   "windows"
@@ -52,6 +55,7 @@
 int os_chdir(lua_State* L);
 int os_copyfile(lua_State* L);
 int os_getcwd(lua_State* L);
+int os_getversion(lua_State* L);
 int os_isdir(lua_State* L);
 int os_isfile(lua_State* L);
 int os_matchdone(lua_State* L);
Index: build/premake/premake4/src/host/scripts.c
===================================================================
--- build/premake/premake4/src/host/scripts.c	(revision 11967)
+++ build/premake/premake4/src/host/scripts.c	(working copy)
@@ -4,9 +4,10 @@
 
 const char* builtin_scripts[] = {
 	/* base/os.lua */
-	"function os.executef(cmd, ...)\ncmd = string.format(cmd, unpack(arg))\nreturn os.execute(cmd)\nend\nfunction os.findlib(libname)\nlocal path, formats\nif os.is(\"windows\") then\nformats = { \"%s.dll\", \"%s\" }\npath = os.getenv(\"PATH\")\nelse\nif os.is(\"macosx\") then\nformats = { \"lib%s.dylib\", \"%s.dylib\" }\npath = os.getenv(\"DYLD_LIBRARY_PATH\")\nelse\nformats = { \"lib%s.so\", \"%s.so\" }\npath = os.getenv(\"LD_LIBRARY_PATH\") or \"\"\nio.input(\"/etc/ld.so.conf\")\nif io.input() then\nfor line in io.lines() do\npath = path .. \":\" .. line\nend\nio.input():close()\nend\nend\ntable.insert(formats, \"%s\")\npath = (path or \"\") .. \":/lib:/usr/lib:/usr/local/lib\"\nend\nfor _, fmt in ipairs(formats) do\nlocal name = string.format(fmt, libname)\nlocal result = os.pathsearch(name, path)\nif result then return result end\nend\nend\nfunction os.get()\nreturn _OPTIONS.os or _OS\nend\nfunction os.is(id)\nreturn (os.get():lower() == id:lower())\nend\nlocal function domatch(result, mask, wantfiles)\nif mas"
-	"k:startswith(\"./\") then\nmask = mask:sub(3)\nend\nlocal basedir = mask\nlocal starpos = mask:find(\"%*\")\nif starpos then\nbasedir = basedir:sub(1, starpos - 1)\nend\nbasedir = path.getdirectory(basedir)\nif (basedir == \".\") then basedir = \"\" end\nlocal recurse = mask:find(\"**\", nil, true)\nmask = path.wildcards(mask)\nlocal function matchwalker(basedir)\nlocal wildcard = path.join(basedir, \"*\")\nlocal m = os.matchstart(wildcard)\nwhile (os.matchnext(m)) do\nlocal isfile = os.matchisfile(m)\nif ((wantfiles and isfile) or (not wantfiles and not isfile)) then\nlocal fname = path.join(basedir, os.matchname(m))\nif fname:match(mask) == fname then\ntable.insert(result, fname)\nend\nend\nend\nos.matchdone(m)\nif recurse then\nm = os.matchstart(wildcard)\nwhile (os.matchnext(m)) do\nif not os.matchisfile(m) then\nlocal dirname = os.matchname(m)\nmatchwalker(path.join(basedir, dirname))\nend\nend\nos.matchdone(m)\nend\nend\nmatchwalker(basedir)\nend\nfunction os.matchdirs(...)\nlocal result = { }\nfor _, ma"
-	"sk in ipairs(arg) do\ndomatch(result, mask, false)\nend\nreturn result\nend\nfunction os.matchfiles(...)\nlocal result = { }\nfor _, mask in ipairs(arg) do\ndomatch(result, mask, true)\nend\nreturn result\nend\nlocal builtin_mkdir = os.mkdir\nfunction os.mkdir(p)\nlocal dir = iif(p:startswith(\"/\"), \"/\", \"\")\nfor part in p:gmatch(\"[^/]+\") do\ndir = dir .. part\nif (part ~= \"\" and not path.isabsolute(part) and not os.isdir(dir)) then\nlocal ok, err = builtin_mkdir(dir)\nif (not ok) then\nreturn nil, err\nend\nend\ndir = dir .. \"/\"\nend\nreturn true\nend\nlocal builtin_rmdir = os.rmdir\nfunction os.rmdir(p)\nlocal dirs = os.matchdirs(p .. \"/*\")\nfor _, dname in ipairs(dirs) do\nos.rmdir(dname)\nend\nlocal files = os.matchfiles(p .. \"/*\")\nfor _, fname in ipairs(files) do\nos.remove(fname)\nend\nbuiltin_rmdir(p)\nend\n",
+	"function os.executef(cmd, ...)\ncmd = string.format(cmd, unpack(arg))\nreturn os.execute(cmd)\nend\nfunction os.findlib(libname)\nlocal path, formats\nif os.is(\"windows\") then\nformats = { \"%s.dll\", \"%s\" }\npath = os.getenv(\"PATH\")\nelseif os.is(\"haiku\") then\nformats = { \"lib%s.so\", \"%s.so\" }\npath = os.getenv(\"LIBRARY_PATH\")\nelse\nif os.is(\"macosx\") then\nformats = { \"lib%s.dylib\", \"%s.dylib\" }\npath = os.getenv(\"DYLD_LIBRARY_PATH\")\nelse\nformats = { \"lib%s.so\", \"%s.so\" }\npath = os.getenv(\"LD_LIBRARY_PATH\") or \"\"\nio.input(\"/etc/ld.so.conf\")\nif io.input() then\nfor line in io.lines() do\npath = path .. \":\" .. line\nend\nio.input():close()\nend\nend\ntable.insert(formats, \"%s\")\npath = (path or \"\") .. \":/lib:/usr/lib:/usr/local/lib\"\nend\nfor _, fmt in ipairs(formats) do\nlocal name = string.format(fmt, libname)\nlocal result = os.pathsearch(name, path)\nif result then return result end\nend\nend\nfunction os.get()\nreturn _OPTIONS.os or _OS\nend\nfunction os.is(i"
+	"d)\nreturn (os.get():lower() == id:lower())\nend\nlocal function domatch(result, mask, wantfiles)\nif mask:startswith(\"./\") then\nmask = mask:sub(3)\nend\nlocal basedir = mask\nlocal starpos = mask:find(\"%*\")\nif starpos then\nbasedir = basedir:sub(1, starpos - 1)\nend\nbasedir = path.getdirectory(basedir)\nif (basedir == \".\") then basedir = \"\" end\nlocal recurse = mask:find(\"**\", nil, true)\nmask = path.wildcards(mask)\nlocal function matchwalker(basedir)\nlocal wildcard = path.join(basedir, \"*\")\nlocal m = os.matchstart(wildcard)\nwhile (os.matchnext(m)) do\nlocal isfile = os.matchisfile(m)\nif ((wantfiles and isfile) or (not wantfiles and not isfile)) then\nlocal fname = path.join(basedir, os.matchname(m))\nif fname:match(mask) == fname then\ntable.insert(result, fname)\nend\nend\nend\nos.matchdone(m)\nif recurse then\nm = os.matchstart(wildcard)\nwhile (os.matchnext(m)) do\nif not os.matchisfile(m) then\nlocal dirname = os.matchname(m)\nmatchwalker(path.join(basedir, dirname))\nend\nend\nos.mat"
+	"chdone(m)\nend\nend\nmatchwalker(basedir)\nend\nfunction os.matchdirs(...)\nlocal result = { }\nfor _, mask in ipairs(arg) do\ndomatch(result, mask, false)\nend\nreturn result\nend\nfunction os.matchfiles(...)\nlocal result = { }\nfor _, mask in ipairs(arg) do\ndomatch(result, mask, true)\nend\nreturn result\nend\nlocal builtin_mkdir = os.mkdir\nfunction os.mkdir(p)\nlocal dir = iif(p:startswith(\"/\"), \"/\", \"\")\nfor part in p:gmatch(\"[^/]+\") do\ndir = dir .. part\nif (part ~= \"\" and not path.isabsolute(part) and not os.isdir(dir)) then\nlocal ok, err = builtin_mkdir(dir)\nif (not ok) then\nreturn nil, err\nend\nend\ndir = dir .. \"/\"\nend\nreturn true\nend\nfunction os.outputof(cmd)\nlocal pipe = io.popen(cmd)\nlocal result = pipe:read('*a')\npipe:close()\nreturn result\nend\nlocal builtin_rmdir = os.rmdir\nfunction os.rmdir(p)\nlocal dirs = os.matchdirs(p .. \"/*\")\nfor _, dname in ipairs(dirs) do\nos.rmdir(dname)\nend\nlocal files = os.matchfiles(p .. \"/*\")\nfor _, fname in ipairs(files) do\nos."
+	"remove(fname)\nend\nbuiltin_rmdir(p)\nend\n",
 
 	/* base/path.lua */
 	"function path.getabsolute(p)\np = path.translate(p, \"/\")\nif (p == \"\") then p = \".\" end\nlocal result = iif (path.isabsolute(p), nil, os.getcwd())\nfor n, part in ipairs(p:explode(\"/\", true)) do\nif (part == \"\" and n == 1) then\nresult = \"/\"\nelseif (part == \"..\") then\nresult = path.getdirectory(result)\nelseif (part ~= \".\") then\nresult = path.join(result, part)\nend\nend\nresult = iif(result:endswith(\"/\"), result:sub(1, -2), result)\nreturn result\nend\nfunction path.getbasename(p)\nlocal name = path.getname(p)\nlocal i = name:findlast(\".\", true)\nif (i) then\nreturn name:sub(1, i - 1)\nelse\nreturn name\nend\nend\nfunction path.getdirectory(p)\nlocal i = p:findlast(\"/\", true)\nif (i) then\nif i > 1 then i = i - 1 end\nreturn p:sub(1, i)\nelse\nreturn \".\"\nend\nend\nfunction path.getdrive(p)\nlocal ch1 = p:sub(1,1)\nlocal ch2 = p:sub(2,2)\nif ch2 == \":\" then\nreturn ch1\nend\nend\nfunction path.getextension(p)\nlocal i = p:findlast(\".\", true)\nif (i) then\nreturn p:sub(i)\nelse\n"
@@ -298,4 +299,4 @@
 	"\npremake.action.call(action.trigger)\nprint(\"Done.\")\nreturn 0\nend\n",
 
 	0
-};
\ No newline at end of file
+};

