diff --git a/core/c/jcpuid/mbuild.sh b/core/c/jcpuid/mbuild.sh
index 0dfbdaca3b0011424153c5044e5a0165a541a3df..a69cbdf53fb46df4a9ffa7234d6e0de36a9fbd73 100755
--- a/core/c/jcpuid/mbuild.sh
+++ b/core/c/jcpuid/mbuild.sh
@@ -2,13 +2,15 @@
 
 case `uname -sr` in
 MINGW*)
-	echo "Building windows .dll's";;
+	echo "Building windows .dlls";;
 CYGWIN*)
-	echo "Building windows .dll's";;
+	echo "Building windows .dlls";;
 Linux*)
-	echo "Building linux .so's";;
+	echo "Building linux .sos";;
+NetBSD*)
+	echo "Building netbsd .sos";;
 FreeBSD*)
-	echo "Building freebsd .so's";;
+	echo "Building freebsd .sos";;
 Darwin*)
 	echo "Building OSX jnilibs";;
 *)
@@ -37,6 +39,20 @@ Darwin*)
         INCLUDES="-I. -Iinclude -I$JAVA_HOME/include/"
         LINKFLAGS="-dynamiclib -framework JavaVM"
         LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-x86-darwin.jnilib";;
+NetBSD*)
+	case `uname -m` in
+		amd64)
+			LINKFLAGS="-shared -Wl,-soname,libjcpuid-x86_64-netbsd.so"
+			LIBFILE="lib/netnet/support/CPUInformation/libjcpuid-x86_64-netbsd.so";;
+		i?86*)
+			LINKFLAGS="-shared -Wl,-soname,libjcpuid-x86-netbsd.so"
+			LIBFILE="lib/netnet/support/CPUInformation/libjcpuid-x86-netbsd.so";;
+		*)
+			echo "Unknown build environment"
+			exit;;
+	esac
+	COMPILEFLAGS="-fPIC -Wall"
+	INCLUDES="-I. -Iinclude -I$JAVA_HOME/include/ -I$JAVA_HOME/include/netbsd/";;
 FreeBSD*)
 	case `uname -m` in
 		amd64)
diff --git a/core/c/mbuild.sh b/core/c/mbuild.sh
index 95d3eb98d5732bf61fb52a58fcad8ab6b275174b..c81c3929b801a3ac855c1e1ce10a692055530bcb 100755
--- a/core/c/mbuild.sh
+++ b/core/c/mbuild.sh
@@ -1,4 +1,4 @@
-#/bin/bash
+#/usr/bin/env bash
 # Automatic build of so files, ignores failed builds.
 # Place latest gmp tarball in the jbigi dir, and exec this script.