diff --git otp_src_R16B03/erts/configure otp_src_R16B03-haiku/erts/configure
--- otp_src_R16B03/erts/configure
+++ otp_src_R16B03-haiku/erts/configure
@@ -6648,7 +6648,7 @@ if test "${ac_cv_lib_m_sin+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
+LIBS=" $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -6711,7 +6711,7 @@ if test $ac_cv_lib_m_sin = yes; then
 #define HAVE_LIBM 1
 _ACEOF
 
-  LIBS="-lm $LIBS"
+  LIBS=" $LIBS"
 
 fi
 
@@ -17872,7 +17872,9 @@ echo "${ECHO_T}$gcc_dw_cmpxchg_asm" >&6
     if test "$gcc_dw_cmpxchg_asm" = "yes"; then
 
 cat >>confdefs.h <<\_ACEOF
-#define ETHR_GCC_HAVE_DW_CMPXCHG_ASM_SUPPORT 1
+#undef ETHR_GCC_HAVE_DW_CMPXCHG_ASM_SUPPORT
+#undef ERTS_SMP
+#undef USE_THREADS
 _ACEOF
 
     fi;;
diff --git otp_src_R16B03/erts/emulator/sys/unix/sys.c otp_src_R16B03-haiku/erts/emulator/sys/unix/sys.c
--- otp_src_R16B03/erts/emulator/sys/unix/sys.c
+++ otp_src_R16B03-haiku/erts/emulator/sys/unix/sys.c
@@ -767,7 +767,7 @@ prepare_crash_dump(int secs)
 	if (nice_val > 39) {
 	    nice_val = 39;
 	}
-	erts_silence_warn_unused_result(nice(nice_val));
+	erts_silence_warn_unused_result(nice_val);
     }
 
     UnUseTmpHeapNoproc(NUFBUF);
diff --git otp_src_R16B03/erts/epmd/src/Makefile.in otp_src_R16B03-haiku/erts/epmd/src/Makefile.in
--- otp_src_R16B03/erts/epmd/src/Makefile.in
+++ otp_src_R16B03-haiku/erts/epmd/src/Makefile.in
@@ -64,7 +64,7 @@ else
 ifeq ($(findstring vxworks,$(TARGET)),vxworks)
 ERTS_INTERNAL_LIBS=-L../../lib/internal/$(TARGET) -lerts_internal$(ERTS_LIB_TYPEMARKER) @ERTS_INTERNAL_X_LIBS@
 else
-ERTS_INTERNAL_LIBS=-L../../lib/internal/$(TARGET) -lerts_internal$(ERTS_LIB_TYPEMARKER) @ERTS_INTERNAL_X_LIBS@ -lm
+ERTS_INTERNAL_LIBS=-L../../lib/internal/$(TARGET) -lerts_internal$(ERTS_LIB_TYPEMARKER) @ERTS_INTERNAL_X_LIBS@ 
 endif
 endif
 
diff --git otp_src_R16B03/erts/etc/common/Makefile.in otp_src_R16B03-haiku/erts/etc/common/Makefile.in
--- otp_src_R16B03/erts/etc/common/Makefile.in
+++ otp_src_R16B03-haiku/erts/etc/common/Makefile.in
@@ -91,7 +91,7 @@ endif
 ifeq ($(TARGET),win32)
 ERTS_INTERNAL_LIBS=-L../../lib/internal/$(TARGET) -lerts_internal_r$(ERTS_LIB_TYPEMARKER) @ERTS_INTERNAL_X_LIBS@
 else
-ERTS_INTERNAL_LIBS=-L../../lib/internal/$(TARGET) -lerts_internal$(ERTS_LIB_TYPEMARKER) @ERTS_INTERNAL_X_LIBS@ -lm
+ERTS_INTERNAL_LIBS=-L../../lib/internal/$(TARGET) -lerts_internal$(ERTS_LIB_TYPEMARKER) @ERTS_INTERNAL_X_LIBS@ 
 endif
 
 ERTS_LIB = $(ERL_TOP)/erts/lib_src/obj/$(TARGET)/$(TYPE)/MADE
diff --git otp_src_R16B03/erts/etc/common/erlexec.c otp_src_R16B03-haiku/erts/etc/common/erlexec.c
--- otp_src_R16B03/erts/etc/common/erlexec.c
+++ otp_src_R16B03-haiku/erts/etc/common/erlexec.c
@@ -1989,7 +1989,7 @@ initial_argv_massage(int *argc, char ***argv)
 
     vix = 0;
 
-    av = build_args_from_env("ERL_" OTP_SYSTEM_VERSION "_FLAGS");
+    av = build_args_from_env("ERL_HAIKU_FLAGS");
     if (av)
 	avv[vix++].argv = av;
 
diff --git otp_src_R16B03/erts/include/internal/ethread.h otp_src_R16B03-haiku/erts/include/internal/ethread.h
--- otp_src_R16B03/erts/include/internal/ethread.h
+++ otp_src_R16B03-haiku/erts/include/internal/ethread.h
@@ -26,9 +26,7 @@
 #ifndef ETHREAD_H__
 #define ETHREAD_H__
 
-#ifndef ETHR_HAVE_ETHREAD_DEFINES
-#  include "ethread_header_config.h"
-#endif
+#include "ethread_header_config.h"
 
 #include <stdlib.h>
 #include "erl_errno.h"
diff --git otp_src_R16B03/erts/include/internal/i386/ethr_dw_atomic.h otp_src_R16B03-haiku/erts/include/internal/i386/ethr_dw_atomic.h
--- otp_src_R16B03/erts/include/internal/i386/ethr_dw_atomic.h
+++ otp_src_R16B03-haiku/erts/include/internal/i386/ethr_dw_atomic.h
@@ -25,6 +25,8 @@
 #ifndef ETHR_X86_DW_ATOMIC_H__
 #define ETHR_X86_DW_ATOMIC_H__
 
+#include "ethread_header_config.h"
+
 #ifdef ETHR_GCC_HAVE_DW_CMPXCHG_ASM_SUPPORT
 
 #define ETHR_HAVE_NATIVE_DW_ATOMIC
diff --git otp_src_R16B03/lib/asn1/c_src/Makefile otp_src_R16B03-haiku/lib/asn1/c_src/Makefile
--- otp_src_R16B03/lib/asn1/c_src/Makefile
+++ otp_src_R16B03-haiku/lib/asn1/c_src/Makefile
@@ -67,7 +67,7 @@ CLIB_FLAGS =
 LN=cp
 else
 NIF_SHARED_OBJ_FILE = $(LIBDIR)/asn1_erl_nif.so
-CLIB_FLAGS = -lc
+CLIB_FLAGS = 
 LN= ln -s
 endif
 
diff --git otp_src_R16B03/lib/runtime_tools/c_src/Makefile.in otp_src_R16B03-haiku/lib/runtime_tools/c_src/Makefile.in
--- otp_src_R16B03/lib/runtime_tools/c_src/Makefile.in
+++ otp_src_R16B03-haiku/lib/runtime_tools/c_src/Makefile.in
@@ -149,10 +149,10 @@ $(OBJDIR)/%.o: %.c
 	$(V_CC) -c -o $@ $(ALL_CFLAGS) $<
 
 $(LIBDIR)/trace_ip_drv.so: $(TRACE_IP_DRV_OBJS)
-	$(V_LD) $(LDFLAGS) -o $@ $^ -lc $(LIBS)
+	$(V_LD) $(LDFLAGS) -o $@ $^ $(LIBS)
 
 $(LIBDIR)/trace_file_drv.so: $(TRACE_FILE_DRV_OBJS)
-	$(V_LD) $(LDFLAGS) -o $@ $^ -lc $(LIBS)
+	$(V_LD) $(LDFLAGS) -o $@ $^ $(LIBS)
 
 $(LIBDIR)/trace_ip_drv.dll: $(TRACE_IP_DRV_OBJS)
 	$(V_LD) $(LDFLAGS) -o $@ $^ $(LIBS)
diff --git otp_src_R16B03/lib/erl_interface/src/connect/ei_connect.c otp_src_R16B03-haiku/lib/erl_interface/src/connect/ei_connect.c
--- otp_src_R16B03/lib/erl_interface/src/connect/ei_connect.c
+++ otp_src_R16B03-haiku/lib/erl_interface/src/connect/ei_connect.c
@@ -1149,6 +1149,8 @@ static unsigned int gen_challenge(void)
 
 #else  /* some unix */
 
+int gethostid() { return 108; }
+
 static unsigned int gen_challenge(void)
 {
     struct {
