Index: build/premake/extern_libs4.lua
===================================================================
--- build/premake/extern_libs4.lua	(revision 11943)
+++ build/premake/extern_libs4.lua	(working copy)
@@ -211,6 +211,10 @@
 			if os.is("windows") then
 				add_default_include_paths("boost")
 			end
+			if os.is("bsd") then
+				-- for OpenBSD
+				includedirs { "/usr/local/include" }
+			end
 		end,
 		link_settings = function()
 			if os.is("windows") then
@@ -356,6 +360,10 @@
 			if os.is("windows") then
 				add_default_include_paths("libpng")
 			end
+			if os.is("bsd") then
+				-- OpenBSD only
+				includedirs { "/usr/local/include/libpng" }
+			end
 		end,
 		link_settings = function()
 			if os.is("windows") then
Index: build/premake/premake4/build/gmake.unix/Premake4.make
===================================================================
--- build/premake/premake4/build/gmake.unix/Premake4.make	(revision 11943)
+++ build/premake/premake4/build/gmake.unix/Premake4.make	(working copy)
@@ -29,7 +29,7 @@
   CFLAGS    += $(CPPFLAGS) -Wall -Os
   CXXFLAGS  += $(CFLAGS) 
   LDFLAGS   += -s -rdynamic
-  LIBS      += -lm -ldl 
+  LIBS      += -lm 
   RESFLAGS  += $(DEFINES) $(INCLUDES) 
   LDDEPS    += 
   LINKCMD    = $(CC) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(LDDEPS) $(LIBS)
Index: source/lib/posix/posix_aio.h
===================================================================
--- source/lib/posix/posix_aio.h	(revision 11943)
+++ source/lib/posix/posix_aio.h	(working copy)
@@ -30,10 +30,22 @@
 
 #if OS_WIN
 # include "lib/sysdep/os/win/wposix/waio.h"
-#elif OS_ANDROID
+#elif OS_ANDROID || OS_OPENBSD
 // Android doesn't provide aio.h. We don't actually use aio on Linuxes (see
 // CONFIG2_FILE_ENABLE_AIO) but we use its symbols and structs, so define
 // them here
+# if OS_OPENBSD
+// OpenBSD 5.1 (latest version at time of writing) has no struct sigevent defined,
+// so we do this here.
+struct sigevent
+{
+	int sigev_notify;
+	int sigev_signo;
+	union sigval sigev_value;
+	void (*sigev_notify_function)(union sigval);
+	pthread_attr_t *sigev_notify_attributes;
+};
+# endif
 # define LIO_READ 0
 # define LIO_WRITE 1
 # define LIO_NOP 2
Index: source/lib/sysdep/os/bsd/bcpu.cpp
===================================================================
--- source/lib/sysdep/os/bsd/bcpu.cpp	(revision 11943)
+++ source/lib/sysdep/os/bsd/bcpu.cpp	(working copy)
@@ -28,6 +28,7 @@
 #include "lib/module_init.h"
 
 #include "valgrind.h"
+#include <sys/param.h>
 #include <sys/sysctl.h>
 
 size_t os_cpu_NumProcessors()
Index: source/lib/sysdep/os.h
===================================================================
--- source/lib/sysdep/os.h	(revision 11943)
+++ source/lib/sysdep/os.h	(working copy)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Wildfire Games
+/* Copyright (c) 2012 Wildfire Games
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -68,6 +68,10 @@
 // BSD
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD_kernel__)
 # define OS_BSD 1
+// OpenBSD has no aio.h so and we need a way to disable it for it only
+# if defined(__OpenBSD__)
+#  define OS_OPENBSD 1
+# endif
 #else
 # define OS_BSD 0
 #endif
Index: source/lib/secure_crt.cpp
===================================================================
--- source/lib/secure_crt.cpp	(revision 11943)
+++ source/lib/secure_crt.cpp	(working copy)
@@ -106,7 +106,7 @@
 // self-test and the t* defines (needed for test).
 #if EMULATE_SECURE_CRT
 
-#if !OS_UNIX || OS_MACOSX
+#if !OS_UNIX || OS_MACOSX || OS_OPENBSD
 // return length [in characters] of a string, not including the trailing
 // null character. to protect against access violations, only the
 // first <max_len> characters are examined; if the null character is
Index: source/lib/secure_crt.h
===================================================================
--- source/lib/secure_crt.h	(revision 11943)
+++ source/lib/secure_crt.h	(working copy)
@@ -47,7 +47,7 @@
 #if EMULATE_SECURE_CRT
 
 // (conflicts with glibc definitions)
-#if !OS_UNIX || OS_MACOSX
+#if !OS_UNIX || OS_MACOSX || OS_OPENBSD
 // return length [in characters] of a string, not including the trailing
 // null character. to protect against access violations, only the
 // first <max_len> characters are examined; if the null character is
Index: source/lib/config2.h
===================================================================
--- source/lib/config2.h	(revision 11943)
+++ source/lib/config2.h	(working copy)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Wildfire Games
+/* Copyright (c) 2012 Wildfire Games
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -73,7 +73,8 @@
 #ifndef CONFIG2_FILE_ENABLE_AIO
 // work around a bug introduced in Linux 2.6.38
 // (http://www.wildfiregames.com/forum/index.php?showtopic=14561&view=findpost&p=217710)
-# if OS_LINUX
+// OpenBSD doesn't provide aio.h so we disable its use
+# if OS_LINUX || OS_OPENBSD
 #  define CONFIG2_FILE_ENABLE_AIO 0
 # else
 #  define CONFIG2_FILE_ENABLE_AIO 1
Index: source/ps/Profiler2GPU.cpp
===================================================================
--- source/ps/Profiler2GPU.cpp	(revision 11943)
+++ source/ps/Profiler2GPU.cpp	(working copy)
@@ -871,4 +871,4 @@
 void CProfiler2GPU::RegionEnter(const char* UNUSED(id)) { }
 void CProfiler2GPU::RegionLeave(const char* UNUSED(id)) { }
 
-#endif
\ No newline at end of file
+#endif
Index: source/ps/CStrIntern.h
===================================================================
--- source/ps/CStrIntern.h	(revision 11943)
+++ source/ps/CStrIntern.h	(working copy)
@@ -83,4 +83,4 @@
 	CStrInternInternals* m;
 };
 
-#endif // INCLUDED_CSTRINTERN
\ No newline at end of file
+#endif // INCLUDED_CSTRINTERN
Index: source/ps/Font.cpp
===================================================================
--- source/ps/Font.cpp	(revision 11943)
+++ source/ps/Font.cpp	(working copy)
@@ -81,4 +81,4 @@
 Handle CFont::GetTexture()
 {
 	return unifont_get_texture(h);
-}
\ No newline at end of file
+}
Index: source/maths/Brush.cpp
===================================================================
--- source/maths/Brush.cpp	(revision 11943)
+++ source/maths/Brush.cpp	(working copy)
@@ -413,4 +413,4 @@
 
 		faceStartIdx = j + 1;
 	}
-}
\ No newline at end of file
+}
Index: libraries/nvtt/issue176.patch
===================================================================
--- libraries/nvtt/issue176.patch	(revision 0)
+++ libraries/nvtt/issue176.patch	(working copy)
@@ -0,0 +1,105 @@
+Index: src/src/nvcore/nvcore.h
+===================================================================
+--- src/src/nvcore/nvcore.h	(revision 11943)
++++ src/src/nvcore/nvcore.h	(working copy)
+@@ -41,6 +41,9 @@
+ #elif defined POSH_OS_FREEBSD
+ #	define NV_OS_FREEBSD 1
+ #	define NV_OS_UNIX 1
++#elif defined POSH_OS_OPENBSD
++#	define NV_OS_OPENBSD 1
++#	define NV_OS_UNIX 1
+ #elif defined POSH_OS_CYGWIN32
+ #	define NV_OS_CYGWIN 1
+ #elif defined POSH_OS_MINGW
+@@ -178,7 +181,7 @@
+ #elif NV_CC_GNUC
+ #	if NV_OS_LINUX
+ #		include "DefsGnucLinux.h"
+-#	elif NV_OS_DARWIN || NV_OS_FREEBSD
++#	elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
+ #		include "DefsGnucDarwin.h"
+ #	elif NV_OS_MINGW
+ #		include "DefsGnucWin32.h"
+Index: src/src/nvcore/Debug.cpp
+===================================================================
+--- src/src/nvcore/Debug.cpp	(revision 11943)
++++ src/src/nvcore/Debug.cpp	(working copy)
+@@ -27,7 +27,7 @@
+ #	include <signal.h>
+ #endif
+ 
+-#if NV_OS_LINUX || NV_OS_DARWIN || NV_OS_FREEBSD
++#if NV_OS_LINUX || NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
+ #	include <unistd.h>	// getpid
+ #endif
+ 
+@@ -38,10 +38,13 @@
+ #	endif
+ #endif
+ 
+-#if NV_OS_DARWIN || NV_OS_FREEBSD
++#if NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
+ #	include <sys/types.h>
++#	include <sys/param.h>
+ #	include <sys/sysctl.h>	// sysctl
+-#	include <sys/ucontext.h>
++#	if !NV_OS_OPENBSD
++#		include <sys/ucontext.h>
++#	endif
+ #	undef HAVE_EXECINFO_H
+ #	if defined(HAVE_EXECINFO_H) // only after OSX 10.5
+ #		include <execinfo.h> // backtrace
+@@ -210,6 +213,14 @@
+ 			ucontext_t * ucp = (ucontext_t *)secret;
+ 			return (void *)ucp->uc_mcontext.mc_eip;
+ #		endif
++#	elif NV_OS_OPENBSD
++#		if NV_CPU_X86_64
++			ucontext_t * ucp = (ucontext_t *)secret;
++			return (void *)ucp->sc_rip;
++#		elif NV_CPU_X86
++			ucontext_t * ucp = (ucontext_t *)secret;
++			return (void *)ucp->sc_eip;
++#		endif
+ #	else
+ #		if NV_CPU_X86_64
+ 			// #define REG_RIP REG_INDEX(rip) // seems to be 16
+Index: src/src/nvcore/poshlib/posh.h
+===================================================================
+--- src/src/nvcore/poshlib/posh.h	(revision 11943)
++++ src/src/nvcore/poshlib/posh.h	(working copy)
+@@ -298,6 +298,11 @@
+ #  define POSH_OS_STRING "FreeBSD"
+ #endif
+ 
++#if defined __OpenBSD__
++#  define POSH_OS_OPENBSD 1
++#  define POSH_OS_STRING "OpenBSD"
++#endif
++
+ #if defined __CYGWIN32__
+ #  define POSH_OS_CYGWIN32 1
+ #  define POSH_OS_STRING "Cygwin"
+Index: src/src/nvmath/nvmath.h
+===================================================================
+--- src/src/nvmath/nvmath.h	(revision 11943)
++++ src/src/nvmath/nvmath.h	(working copy)
+@@ -115,7 +115,7 @@
+ {
+ #if NV_OS_WIN32
+ 	return _finite(f) != 0;
+-#elif NV_OS_DARWIN || NV_OS_FREEBSD
++#elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
+ 	return isfinite(f);
+ #elif NV_OS_LINUX
+ 	return finitef(f);
+@@ -130,7 +130,7 @@
+ {
+ #if NV_OS_WIN32
+ 	return _isnan(f) != 0;
+-#elif NV_OS_DARWIN || NV_OS_FREEBSD
++#elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
+ 	return isnan(f);
+ #elif NV_OS_LINUX
+ 	return isnanf(f);
Index: libraries/nvtt/src/src/nvcore/nvcore.h
===================================================================
--- libraries/nvtt/src/src/nvcore/nvcore.h	(revision 11943)
+++ libraries/nvtt/src/src/nvcore/nvcore.h	(working copy)
@@ -41,6 +41,9 @@
 #elif defined POSH_OS_FREEBSD
 #	define NV_OS_FREEBSD 1
 #	define NV_OS_UNIX 1
+#elif defined POSH_OS_OPENBSD
+#	define NV_OS_OPENBSD 1
+#	define NV_OS_UNIX 1
 #elif defined POSH_OS_CYGWIN32
 #	define NV_OS_CYGWIN 1
 #elif defined POSH_OS_MINGW
@@ -178,7 +181,7 @@
 #elif NV_CC_GNUC
 #	if NV_OS_LINUX
 #		include "DefsGnucLinux.h"
-#	elif NV_OS_DARWIN || NV_OS_FREEBSD
+#	elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
 #		include "DefsGnucDarwin.h"
 #	elif NV_OS_MINGW
 #		include "DefsGnucWin32.h"
Index: libraries/nvtt/src/src/nvcore/Debug.cpp
===================================================================
--- libraries/nvtt/src/src/nvcore/Debug.cpp	(revision 11943)
+++ libraries/nvtt/src/src/nvcore/Debug.cpp	(working copy)
@@ -27,7 +27,7 @@
 #	include <signal.h>
 #endif
 
-#if NV_OS_LINUX || NV_OS_DARWIN || NV_OS_FREEBSD
+#if NV_OS_LINUX || NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
 #	include <unistd.h>	// getpid
 #endif
 
@@ -38,10 +38,13 @@
 #	endif
 #endif
 
-#if NV_OS_DARWIN || NV_OS_FREEBSD
+#if NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
 #	include <sys/types.h>
+#	include <sys/param.h>
 #	include <sys/sysctl.h>	// sysctl
-#	include <sys/ucontext.h>
+#	if !NV_OS_OPENBSD
+#		include <sys/ucontext.h>
+#	endif
 #	undef HAVE_EXECINFO_H
 #	if defined(HAVE_EXECINFO_H) // only after OSX 10.5
 #		include <execinfo.h> // backtrace
@@ -210,6 +213,14 @@
 			ucontext_t * ucp = (ucontext_t *)secret;
 			return (void *)ucp->uc_mcontext.mc_eip;
 #		endif
+#	elif NV_OS_OPENBSD
+#		if NV_CPU_X86_64
+			ucontext_t * ucp = (ucontext_t *)secret;
+			return (void *)ucp->sc_rip;
+#		elif NV_CPU_X86
+			ucontext_t * ucp = (ucontext_t *)secret;
+			return (void *)ucp->sc_eip;
+#		endif
 #	else
 #		if NV_CPU_X86_64
 			// #define REG_RIP REG_INDEX(rip) // seems to be 16
Index: libraries/nvtt/src/src/nvcore/poshlib/posh.h
===================================================================
--- libraries/nvtt/src/src/nvcore/poshlib/posh.h	(revision 11943)
+++ libraries/nvtt/src/src/nvcore/poshlib/posh.h	(working copy)
@@ -298,6 +298,11 @@
 #  define POSH_OS_STRING "FreeBSD"
 #endif
 
+#if defined __OpenBSD__
+#  define POSH_OS_OPENBSD 1
+#  define POSH_OS_STRING "OpenBSD"
+#endif
+
 #if defined __CYGWIN32__
 #  define POSH_OS_CYGWIN32 1
 #  define POSH_OS_STRING "Cygwin"
Index: libraries/nvtt/src/src/nvmath/nvmath.h
===================================================================
--- libraries/nvtt/src/src/nvmath/nvmath.h	(revision 11943)
+++ libraries/nvtt/src/src/nvmath/nvmath.h	(working copy)
@@ -115,7 +115,7 @@
 {
 #if NV_OS_WIN32
 	return _finite(f) != 0;
-#elif NV_OS_DARWIN || NV_OS_FREEBSD
+#elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
 	return isfinite(f);
 #elif NV_OS_LINUX
 	return finitef(f);
@@ -130,7 +130,7 @@
 {
 #if NV_OS_WIN32
 	return _isnan(f) != 0;
-#elif NV_OS_DARWIN || NV_OS_FREEBSD
+#elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
 	return isnan(f);
 #elif NV_OS_LINUX
 	return isnanf(f);
Index: libraries/nvtt/README.txt
===================================================================
--- libraries/nvtt/README.txt	(revision 11943)
+++ libraries/nvtt/README.txt	(working copy)
@@ -6,6 +6,7 @@
   r907.patch and r1025.patch (from NVTT SVN - fixes build on FreeBSD)
   rpath.patch (fixes .so file search paths for bundled copy)
   issue139.patch (fixes http://code.google.com/p/nvidia-texture-tools/issues/detail?id=139)
+  issue176.patch (partially from http:/code.google.com/p/nvidia-texture-tools/issues/detail?id=176 - fixes build on OpenBSD)
   png-api.patch (partially from NVTT SVN r1248 - fixes build with libpng 1.5)
   cmake-freebsd.patch (fixes build on FreeBSD)
   gcc47-unistd.patch (fixes build on GCC 4.7)
Index: libraries/enet/build.sh
===================================================================
--- libraries/enet/build.sh	(revision 11943)
+++ libraries/enet/build.sh	(working copy)
@@ -18,13 +18,19 @@
 
 mkdir -p lib/
 
-if [ "`uname -s`" = "Darwin" ]
-then
-  # Fix libtool's use of an absolute path
-  install_name_tool -id @executable_path/libenet.1.dylib src/.libs/libenet.1.dylib
-  cp src/.libs/libenet.dylib lib/
-  cp src/.libs/libenet.1.dylib ../../binaries/system/
-else
-  cp src/.libs/libenet.so lib/
-  cp src/.libs/libenet.so.1 ../../binaries/system/
-fi
+case "`uname -s`" in
+  "Darwin" )
+    # Fix libtool's use of an absolute path
+    install_name_tool -id @executable_path/libenet.1.dylib src/.libs/libenet.1.dylib
+    cp src/.libs/libenet.dylib lib/
+    cp src/.libs/libenet.1.dylib ../../binaries/system/
+    ;;
+  "OpenBSD" )
+    cp src/.libs/libenet.so.1.* lib/
+    cp src/.libs/libenet.so.1.* ../../binaries/system/libenet.so.1
+    ;;
+  * )
+    cp src/.libs/libenet.so lib/
+    cp src/.libs/libenet.so.1 ../../binaries/system/
+    ;;
+esac
