From be86afe59202c432150ee2e38c4e2db6c00de481 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Thu, 13 Jun 2019 20:55:28 +0200
Subject: [PATCH] Haiku patches

---
 build/gmake.haiku/Makefile   |  34 +++
 build/gmake.haiku/genie.make | 486 +++++++++++++++++++++++++++++++++++
 makefile                     |   8 +-
 scripts/genie.lua            |   5 +
 scripts/release.lua          |   1 +
 src/base/cmdline.lua         |   1 +
 src/base/os.lua              |   3 +
 src/host/premake.h           |   3 +
 8 files changed, 540 insertions(+), 1 deletion(-)
 create mode 100644 build/gmake.haiku/Makefile
 create mode 100644 build/gmake.haiku/genie.make

diff --git a/build/gmake.haiku/Makefile b/build/gmake.haiku/Makefile
new file mode 100644
index 0000000..ff32cf2
--- /dev/null
+++ b/build/gmake.haiku/Makefile
@@ -0,0 +1,34 @@
+# GNU Make solution makefile autogenerated by GENie
+# Type "make help" for usage help
+
+ifndef config
+  config=release
+endif
+export config
+
+PROJECTS := genie
+
+.PHONY: all clean help $(PROJECTS)
+
+all: $(PROJECTS)
+
+genie:
+	@echo "==== Building genie ($(config)) ===="
+	@${MAKE} --no-print-directory -C . -f genie.make
+
+clean:
+	@${MAKE} --no-print-directory -C . -f genie.make clean
+
+help:
+	@echo "Usage: make [config=name] [target]"
+	@echo ""
+	@echo "CONFIGURATIONS:"
+	@echo "   release"
+	@echo "   debug"
+	@echo ""
+	@echo "TARGETS:"
+	@echo "   all (default)"
+	@echo "   clean"
+	@echo "   genie"
+	@echo ""
+	@echo "For more information, see https://github.com/bkaradzic/genie"
diff --git a/build/gmake.haiku/genie.make b/build/gmake.haiku/genie.make
new file mode 100644
index 0000000..53d5c53
--- /dev/null
+++ b/build/gmake.haiku/genie.make
@@ -0,0 +1,486 @@
+# GNU Make project makefile autogenerated by GENie
+ifndef config
+  config=release
+endif
+
+ifndef verbose
+  SILENT = @
+endif
+
+SHELLTYPE := msdos
+ifeq (,$(ComSpec)$(COMSPEC))
+  SHELLTYPE := posix
+endif
+ifeq (/bin,$(findstring /bin,$(SHELL)))
+  SHELLTYPE := posix
+endif
+ifeq (/bin,$(findstring /bin,$(MAKESHELL)))
+  SHELLTYPE := posix
+endif
+
+ifeq (posix,$(SHELLTYPE))
+  MKDIR = $(SILENT) mkdir -p "$(1)"
+  COPY  = $(SILENT) cp -fR "$(1)" "$(2)"
+  RM    = $(SILENT) rm -f "$(1)"
+else
+  MKDIR = $(SILENT) mkdir "$(subst /,\\,$(1))" 2> nul || exit 0
+  COPY  = $(SILENT) copy /Y "$(subst /,\\,$(1))" "$(subst /,\\,$(2))"
+  RM    = $(SILENT) del /F "$(subst /,\\,$(1))" 2> nul || exit 0
+endif
+
+CC  = gcc
+CXX = g++
+AR  = ar
+
+ifndef RESCOMP
+  ifdef WINDRES
+    RESCOMP = $(WINDRES)
+  else
+    RESCOMP = windres
+  endif
+endif
+
+MAKEFILE = genie.make
+
+ifeq ($(config),release)
+  OBJDIR              = obj/Release
+  TARGETDIR           = ../../bin/haiku
+  override TARGET              = $(TARGETDIR)/genie
+  DEFINES            += -DNDEBUG -DLUA_COMPAT_MODULE -DLUA_USE_POSIX -DLUA_USE_DLOPEN
+  INCLUDES           += -I"../../src/host/lua-5.3.0/src"
+  ALL_CPPFLAGS       += $(CPPFLAGS) -MMD -MP -MP $(DEFINES) $(INCLUDES)
+  ALL_ASMFLAGS       += $(ASMFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Wall -Wextra -Os
+  ALL_CFLAGS         += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Wall -Wextra -Os
+  ALL_CXXFLAGS       += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Wall -Wextra -Os
+  ALL_OBJCFLAGS      += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Wall -Wextra -Os
+  ALL_OBJCPPFLAGS    += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Wall -Wextra -Os
+  ALL_RESFLAGS       += $(RESFLAGS) $(DEFINES) $(INCLUDES)
+  ALL_LDFLAGS        += $(LDFLAGS) -L. -s
+  LDDEPS             +=
+  LIBS               += $(LDDEPS) -lm
+  EXTERNAL_LIBS      +=
+  LINKCMD             = $(CC) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
+  OBJECTS := \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lapi.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lauxlib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lbaselib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lbitlib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lcode.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lcorolib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lctype.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ldblib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ldebug.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ldo.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ldump.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lfunc.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lgc.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/linit.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/liolib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/llex.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lmathlib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lmem.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/loadlib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lobject.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lopcodes.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/loslib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lparser.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lstate.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lstring.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lstrlib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ltable.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ltablib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ltm.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lundump.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lutf8lib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lvm.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lzio.o \
+	$(OBJDIR)/src/host/os_chdir.o \
+	$(OBJDIR)/src/host/os_copyfile.o \
+	$(OBJDIR)/src/host/os_getcwd.o \
+	$(OBJDIR)/src/host/os_is64bit.o \
+	$(OBJDIR)/src/host/os_isdir.o \
+	$(OBJDIR)/src/host/os_isfile.o \
+	$(OBJDIR)/src/host/os_match.o \
+	$(OBJDIR)/src/host/os_mkdir.o \
+	$(OBJDIR)/src/host/os_pathsearch.o \
+	$(OBJDIR)/src/host/os_rmdir.o \
+	$(OBJDIR)/src/host/os_stat.o \
+	$(OBJDIR)/src/host/os_ticks.o \
+	$(OBJDIR)/src/host/os_uuid.o \
+	$(OBJDIR)/src/host/path_getabsolute.o \
+	$(OBJDIR)/src/host/path_getrelative.o \
+	$(OBJDIR)/src/host/path_helpers.o \
+	$(OBJDIR)/src/host/path_isabsolute.o \
+	$(OBJDIR)/src/host/premake.o \
+	$(OBJDIR)/src/host/premake_main.o \
+	$(OBJDIR)/src/host/scripts.o \
+	$(OBJDIR)/src/host/string_endswith.o \
+	$(OBJDIR)/src/host/string_hash.o \
+
+  define PREBUILDCMDS
+  endef
+  define PRELINKCMDS
+  endef
+  define POSTBUILDCMDS
+  endef
+endif
+
+ifeq ($(config),debug)
+  OBJDIR              = obj/Debug
+  TARGETDIR           = ../../bin/haiku
+  override TARGET              = $(TARGETDIR)/genie
+  DEFINES            += -D_DEBUG -DLUA_COMPAT_MODULE -DLUA_USE_POSIX -DLUA_USE_DLOPEN
+  INCLUDES           += -I"../../src/host/lua-5.3.0/src"
+  ALL_CPPFLAGS       += $(CPPFLAGS) -MMD -MP -MP $(DEFINES) $(INCLUDES)
+  ALL_ASMFLAGS       += $(ASMFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Wall -Wextra -g
+  ALL_CFLAGS         += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Wall -Wextra -g
+  ALL_CXXFLAGS       += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Wall -Wextra -g
+  ALL_OBJCFLAGS      += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Wall -Wextra -g
+  ALL_OBJCPPFLAGS    += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Wall -Wextra -g
+  ALL_RESFLAGS       += $(RESFLAGS) $(DEFINES) $(INCLUDES)
+  ALL_LDFLAGS        += $(LDFLAGS) -L.
+  LDDEPS             +=
+  LIBS               += $(LDDEPS) -lm
+  EXTERNAL_LIBS      +=
+  LINKCMD             = $(CC) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
+  OBJECTS := \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lapi.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lauxlib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lbaselib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lbitlib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lcode.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lcorolib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lctype.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ldblib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ldebug.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ldo.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ldump.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lfunc.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lgc.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/linit.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/liolib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/llex.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lmathlib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lmem.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/loadlib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lobject.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lopcodes.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/loslib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lparser.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lstate.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lstring.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lstrlib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ltable.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ltablib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/ltm.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lundump.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lutf8lib.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lvm.o \
+	$(OBJDIR)/src/host/lua-5.3.0/src/lzio.o \
+	$(OBJDIR)/src/host/os_chdir.o \
+	$(OBJDIR)/src/host/os_copyfile.o \
+	$(OBJDIR)/src/host/os_getcwd.o \
+	$(OBJDIR)/src/host/os_is64bit.o \
+	$(OBJDIR)/src/host/os_isdir.o \
+	$(OBJDIR)/src/host/os_isfile.o \
+	$(OBJDIR)/src/host/os_match.o \
+	$(OBJDIR)/src/host/os_mkdir.o \
+	$(OBJDIR)/src/host/os_pathsearch.o \
+	$(OBJDIR)/src/host/os_rmdir.o \
+	$(OBJDIR)/src/host/os_stat.o \
+	$(OBJDIR)/src/host/os_ticks.o \
+	$(OBJDIR)/src/host/os_uuid.o \
+	$(OBJDIR)/src/host/path_getabsolute.o \
+	$(OBJDIR)/src/host/path_getrelative.o \
+	$(OBJDIR)/src/host/path_helpers.o \
+	$(OBJDIR)/src/host/path_isabsolute.o \
+	$(OBJDIR)/src/host/premake.o \
+	$(OBJDIR)/src/host/premake_main.o \
+	$(OBJDIR)/src/host/scripts.o \
+	$(OBJDIR)/src/host/string_endswith.o \
+	$(OBJDIR)/src/host/string_hash.o \
+
+  define PREBUILDCMDS
+  endef
+  define PRELINKCMDS
+  endef
+  define POSTBUILDCMDS
+  endef
+endif
+
+OBJDIRS := \
+	$(OBJDIR) \
+	$(OBJDIR)/src/host \
+	$(OBJDIR)/src/host/lua-5.3.0/src \
+
+RESOURCES := \
+
+.PHONY: clean prebuild prelink
+
+all: $(OBJDIRS) $(TARGETDIR) prebuild prelink $(TARGET)
+	@:
+
+$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(EXTERNAL_LIBS) $(RESOURCES) | $(TARGETDIR) $(OBJDIRS)
+	@echo Linking genie
+	$(SILENT) $(LINKCMD)
+	$(POSTBUILDCMDS)
+
+$(TARGETDIR):
+	@echo Creating $(TARGETDIR)
+	-$(call MKDIR,$(TARGETDIR))
+
+$(OBJDIRS):
+	@echo Creating $(@)
+	-$(call MKDIR,$@)
+
+clean:
+	@echo Cleaning genie
+ifeq (posix,$(SHELLTYPE))
+	$(SILENT) rm -f  $(TARGET)
+	$(SILENT) rm -rf $(OBJDIR)
+else
+	$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
+	$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
+endif
+
+prebuild:
+	$(PREBUILDCMDS)
+
+prelink:
+	$(PRELINKCMDS)
+
+ifneq (,$(PCH))
+$(GCH): $(PCH) $(MAKEFILE) | $(OBJDIR)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) -x c-header $(DEFINES) $(INCLUDES) -o "$@" -c "$<"
+
+$(GCH_OBJC): $(PCH) $(MAKEFILE) | $(OBJDIR)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_OBJCFLAGS) -x objective-c-header $(DEFINES) $(INCLUDES) -o "$@" -c "$<"
+endif
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lapi.o: ../../src/host/lua-5.3.0/src/lapi.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lauxlib.o: ../../src/host/lua-5.3.0/src/lauxlib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lbaselib.o: ../../src/host/lua-5.3.0/src/lbaselib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lbitlib.o: ../../src/host/lua-5.3.0/src/lbitlib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lcode.o: ../../src/host/lua-5.3.0/src/lcode.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lcorolib.o: ../../src/host/lua-5.3.0/src/lcorolib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lctype.o: ../../src/host/lua-5.3.0/src/lctype.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/ldblib.o: ../../src/host/lua-5.3.0/src/ldblib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/ldebug.o: ../../src/host/lua-5.3.0/src/ldebug.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/ldo.o: ../../src/host/lua-5.3.0/src/ldo.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/ldump.o: ../../src/host/lua-5.3.0/src/ldump.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lfunc.o: ../../src/host/lua-5.3.0/src/lfunc.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lgc.o: ../../src/host/lua-5.3.0/src/lgc.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/linit.o: ../../src/host/lua-5.3.0/src/linit.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/liolib.o: ../../src/host/lua-5.3.0/src/liolib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/llex.o: ../../src/host/lua-5.3.0/src/llex.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lmathlib.o: ../../src/host/lua-5.3.0/src/lmathlib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lmem.o: ../../src/host/lua-5.3.0/src/lmem.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/loadlib.o: ../../src/host/lua-5.3.0/src/loadlib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lobject.o: ../../src/host/lua-5.3.0/src/lobject.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lopcodes.o: ../../src/host/lua-5.3.0/src/lopcodes.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/loslib.o: ../../src/host/lua-5.3.0/src/loslib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lparser.o: ../../src/host/lua-5.3.0/src/lparser.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lstate.o: ../../src/host/lua-5.3.0/src/lstate.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lstring.o: ../../src/host/lua-5.3.0/src/lstring.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lstrlib.o: ../../src/host/lua-5.3.0/src/lstrlib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/ltable.o: ../../src/host/lua-5.3.0/src/ltable.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/ltablib.o: ../../src/host/lua-5.3.0/src/ltablib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/ltm.o: ../../src/host/lua-5.3.0/src/ltm.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lundump.o: ../../src/host/lua-5.3.0/src/lundump.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lutf8lib.o: ../../src/host/lua-5.3.0/src/lutf8lib.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lvm.o: ../../src/host/lua-5.3.0/src/lvm.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/lua-5.3.0/src/lzio.o: ../../src/host/lua-5.3.0/src/lzio.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_chdir.o: ../../src/host/os_chdir.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_copyfile.o: ../../src/host/os_copyfile.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_getcwd.o: ../../src/host/os_getcwd.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_is64bit.o: ../../src/host/os_is64bit.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_isdir.o: ../../src/host/os_isdir.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_isfile.o: ../../src/host/os_isfile.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_match.o: ../../src/host/os_match.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_mkdir.o: ../../src/host/os_mkdir.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_pathsearch.o: ../../src/host/os_pathsearch.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_rmdir.o: ../../src/host/os_rmdir.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_stat.o: ../../src/host/os_stat.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_ticks.o: ../../src/host/os_ticks.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/os_uuid.o: ../../src/host/os_uuid.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/path_getabsolute.o: ../../src/host/path_getabsolute.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/path_getrelative.o: ../../src/host/path_getrelative.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/path_helpers.o: ../../src/host/path_helpers.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/path_isabsolute.o: ../../src/host/path_isabsolute.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/premake.o: ../../src/host/premake.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/premake_main.o: ../../src/host/premake_main.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/scripts.o: ../../src/host/scripts.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/string_endswith.o: ../../src/host/string_endswith.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+$(OBJDIR)/src/host/string_hash.o: ../../src/host/string_hash.c $(GCH) $(MAKEFILE)
+	@echo $(notdir $<)
+	$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -c "$<"
+
+-include $(OBJECTS:%.o=%.d)
+ifneq (,$(PCH))
+  -include $(OBJDIR)/$(notdir $(PCH)).d
+  -include $(OBJDIR)/$(notdir $(PCH))_objc.d
+endif
diff --git a/makefile b/makefile
index 7064ec9..02939d6 100644
--- a/makefile
+++ b/makefile
@@ -4,7 +4,7 @@
 #
 
 UNAME := $(shell uname)
-ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin SunOS FreeBSD GNU/kFreeBSD NetBSD OpenBSD GNU))
+ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin SunOS FreeBSD GNU/kFreeBSD NetBSD OpenBSD GNU Haiku))
 ifeq ($(UNAME),$(filter $(UNAME),Darwin))
 OS=darwin
 else
@@ -14,10 +14,14 @@ else
 ifeq ($(UNAME),$(filter $(UNAME),FreeBSD GNU/kFreeBSD NetBSD OpenBSD))
 OS=bsd
 else
+ifeq ($(UNAME),$(filter $(UNAME),Haiku))
+OS=haiku
+else
 OS=linux
 endif
 endif
 endif
+endif
 else
 OS=windows
 endif
@@ -42,6 +46,7 @@ projgen:
 	$(SILENT) $(GENIE) --to=../build/gmake.linux   --os=linux gmake
 	$(SILENT) $(GENIE) --to=../build/gmake.darwin  --os=macosx --platform=universal32 gmake
 	$(SILENT) $(GENIE) --to=../build/gmake.freebsd --os=bsd gmake
+	$(SILENT) $(GENIE) --to=../build/gmake.haiku   --os=haiku gmake
 
 rebuild:
 	$(SILENT) $(MAKE) -C build/gmake.$(OS) clean all
@@ -56,6 +61,7 @@ release-linux: $(GENIE)
 	$(SILENT) $(MAKE) -C build/gmake.darwin  clean all CC=x86_64-apple-darwin15-clang
 	$(SILENT) $(MAKE) -C build/gmake.linux   clean all
 	$(SILENT) $(MAKE) -C build/gmake.windows clean all CC=x86_64-w64-mingw32-gcc
+	$(SILENT) $(MAKE) -C build/gmake.haiku   clean all
 	$(SILENT) git checkout src/host/version.h
 
 release: release-$(OS)
diff --git a/scripts/genie.lua b/scripts/genie.lua
index 7e64ad9..b20f5c7 100644
--- a/scripts/genie.lua
+++ b/scripts/genie.lua
@@ -86,6 +86,11 @@
 			buildoptions { "-mmacosx-version-min=10.6" }
 			linkoptions  { "-mmacosx-version-min=10.6" }
 
+		configuration "haiku"
+			targetdir   "../bin/haiku"
+			defines     { "LUA_USE_POSIX", "LUA_USE_DLOPEN" }
+			links       { "root" }
+
 		configuration {}
 
 
diff --git a/scripts/release.lua b/scripts/release.lua
index f320091..15aa073 100644
--- a/scripts/release.lua
+++ b/scripts/release.lua
@@ -40,6 +40,7 @@ function dorelease()
 	exec(_PREMAKE_COMMAND .. " /to=../build/gmake.windows /os=windows gmake")
 	exec(_PREMAKE_COMMAND .. " /to=../build/gmake.linux /os=linux gmake")
 	exec(_PREMAKE_COMMAND .. " /to=../build/gmake.darwin /os=macosx /platform=universal32 gmake")
+	exec(_PREMAKE_COMMAND .. " /to=../build/gmake.haiku /os=haiku gmake")
 
 	print("")
 	print( "Finished.")
diff --git a/src/base/cmdline.lua b/src/base/cmdline.lua
index c3357b7..dcdc637 100644
--- a/src/base/cmdline.lua
+++ b/src/base/cmdline.lua
@@ -57,6 +57,7 @@
 			{ "macosx",   "Apple Mac OS X" },
 			{ "solaris",  "Solaris" },
 			{ "windows",  "Microsoft Windows" },
+			{ "haiku",    "Haiku" },
 		}
 	}
 
diff --git a/src/base/os.lua b/src/base/os.lua
index ae88c0a..b2c1cfa 100644
--- a/src/base/os.lua
+++ b/src/base/os.lua
@@ -66,6 +66,9 @@
 			if os.is("macosx") then
 				formats = { "lib%s.dylib", "%s.dylib" }
 				path = os.getenv("DYLD_LIBRARY_PATH")
+			elseif os.is("haiku") then
+				formats = { "lib%s.so", "%s.so" }
+				path = os.getenv("LIBRARY_PATH")
 			else
 				formats = { "lib%s.so", "%s.so" }
 				path = os.getenv("LD_LIBRARY_PATH") or ""
diff --git a/src/host/premake.h b/src/host/premake.h
index f0782db..5a3a636 100644
--- a/src/host/premake.h
+++ b/src/host/premake.h
@@ -27,6 +27,9 @@
 #elif defined(__OS2__)
 #define PLATFORM_OS2      (1)
 #define PLATFORM_STRING   "os2"
+#elif defined(__HAIKU__)
+#define PLATFORM_HAIKU      (1)
+#define PLATFORM_STRING   "haiku"
 #else
 #define PLATFORM_WINDOWS  (1)
 #define PLATFORM_STRING   "windows"
-- 
2.21.0

