diff --git a/Makefile b/Makefile
index 204512b..966f320 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 
 INSTALL_PREFIX = /usr/local
 
-CFLAGS = -Wall -O3 -fPIC -fomit-frame-pointer -I vm -D_GNU_SOURCE
+CFLAGS = -Wall -O3 -v -fPIC -fomit-frame-pointer -I vm -D_GNU_SOURCE
 EXTFLAGS = -pthread
 MAKESO = $(CC) -shared -WBsymbolic
 LIBNEKO_NAME = libneko.so
@@ -37,7 +37,7 @@ NEKO_EXEC = LD_LIBRARY_PATH=../bin:${LD_LIBRARY_PATH} NEKOPATH=../boot:../bin ..
 # For MINGW/MSYS
 
 ifeq (${WIN32}, 1)
-CFLAGS = -g -Wall -O3 -momit-leaf-frame-pointer -I vm -I /usr/local/include
+CFLAGS = -g -Wall -v -O3 -momit-leaf-frame-pointer -I vm -I /usr/local/include
 EXTFLAGS =
 MAKESO = $(CC) -O -shared
 LIBNEKO_NAME = neko.dll
@@ -66,7 +66,7 @@ ifeq (${OSX_UNIVERSAL}, 1)
 
 export MACOSX_DEPLOYMENT_TARGET_i386=10.4
 export MACOSX_DEPLOYMENT_TARGET_ppc=10.3
-CFLAGS += -arch ppc -arch i386 -L/usr/local/lib
+CFLAGS += -arch ppc -arch i386 -L/usr/local/lib -L/opt/local/lib -I/opt/local/include
 UNIV = libs/include/osx_universal
 #linking to shared lib (.a) explicitly:
 LIBNEKO_DEPS = ${UNIV}/libgc.a  -lSystemStubs
diff --git a/libs/common/osdef.h b/libs/common/osdef.h
index 06edebd..71b7c4b 100644
--- a/libs/common/osdef.h
+++ b/libs/common/osdef.h
@@ -45,6 +45,8 @@
 #	define LITTLE_ENDIAN 1
 #	define BIG_ENDIAN 2
 #	define BYTE_ORDER LITTLE_ENDIAN
+#elif defined(OS_MAC) || defined(OS_BSD)
+#	include <machine/endian.h>
 #else
 #	include <endian.h>
 #endif
diff --git a/libs/common/sha1.c b/libs/common/sha1.c
index 4e7c835..2ea7413 100644
--- a/libs/common/sha1.c
+++ b/libs/common/sha1.c
@@ -26,7 +26,7 @@
 // original code by Steve Reid
 
 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
-#if IS_BIG_ENDIAN
+#ifdef IS_BIG_ENDIAN
 #	define blk0(i) block[i]
 #else
 #	define blk0(i) (block[i] = (rol(block[i],24)&0xFF00FF00) \
diff --git a/libs/mysql/my_proto/my_api.c b/libs/mysql/my_proto/my_api.c
index 54411dd..ff0803c 100644
--- a/libs/mysql/my_proto/my_api.c
+++ b/libs/mysql/my_proto/my_api.c
@@ -18,7 +18,10 @@
 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
 /*																			*/
 /* ************************************************************************ */
-#include <malloc.h>
+#include "osdef.h"
+#ifndef OS_MAC
+#	include <malloc.h>
+#endif
 #include <memory.h>
 #include <stdio.h>
 #include "my_proto.h"
diff --git a/vm/jit_x86.c b/vm/jit_x86.c
index bb34264..d4f7c2d 100644
--- a/vm/jit_x86.c
+++ b/vm/jit_x86.c
@@ -17,7 +17,9 @@
 #include "vm.h"
 #include "neko_mod.h"
 #include "objtable.h"
-#include <malloc.h>
+#ifndef NEKO_MAC
+#	include <malloc.h>
+#endif
 #include <string.h>
 #include <math.h>
 #include <stdio.h>
diff --git a/vm/threads.c b/vm/threads.c
index 981e791..de12247 100644
--- a/vm/threads.c
+++ b/vm/threads.c
@@ -14,6 +14,9 @@
 /* Lesser General Public License or the LICENSE file for more details.		*/
 /*																			*/
 /* ************************************************************************ */
+
+// dlfcn.h must be included before vm (atleast if it's osx) so the bool type won't be redefined.
+#include <dlfcn.h>
 #include "vm.h"
 #include <string.h>
 
@@ -86,7 +89,7 @@ typedef struct {
 #ifdef NEKO_WINDOWS
 #	define THREAD_FUN DWORD WINAPI
 #else
-#	define THREAD_FUN void*
+#	define THREAD_FUN void *
 #endif
 
 typedef int (*rec)( int, void * );
