From 86a685089b703cd5d5747e897c69aae3cc2e6781 Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Mon, 21 May 2018 15:23:44 +0200
Subject: add support for Haiku


diff --git a/Makefile.am b/Makefile.am
index 3281c56..08d0993 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -147,8 +147,8 @@ EXTRA_DIST = \
 
 install-data-hook: install-delete-obsolete-files
 	$(mkinstalldirs) $(DESTDIR)$(bindir)
-	ln -sf $(codedir)/bakefile.py $(DESTDIR)$(bindir)/bakefile
-	ln -sf $(codedir)/bakefile_gen.py $(DESTDIR)$(bindir)/bakefile_gen
+	ln -r -sf $(codedir)/bakefile.py $(DESTDIR)$(bindir)/bakefile
+	ln -r -sf $(codedir)/bakefile_gen.py $(DESTDIR)$(bindir)/bakefile_gen
 	mv $(DESTDIR)$(codedir)/bakefile.py $(DESTDIR)$(codedir)/bakefile.py.x
 	mv $(DESTDIR)$(codedir)/bakefile_gen.py $(DESTDIR)$(codedir)/bakefile_gen.py.x
 	sed -e "s,#!/usr/bin/env python,#!$(PYTHON),g" $(DESTDIR)$(codedir)/bakefile.py.x >$(DESTDIR)$(codedir)/bakefile.py
diff --git a/autoconf/bakefile.m4 b/autoconf/bakefile.m4
index efa98ae..2636b8b 100644
--- a/autoconf/bakefile.m4
+++ b/autoconf/bakefile.m4
@@ -73,6 +73,7 @@ AC_DEFUN([AC_BAKEFILE_PLATFORM],
     PLATFORM_MACOS=0
     PLATFORM_MACOSX=0
     PLATFORM_BEOS=0
+    PLATFORM_HAIKU=0
 
     if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
         case "${BAKEFILE_HOST}" in
@@ -86,6 +87,9 @@ AC_DEFUN([AC_BAKEFILE_PLATFORM],
             *-*-beos* )
                 PLATFORM_BEOS=1
             ;;
+            *-*-haiku* )
+                PLATFORM_HAIKU=1
+            ;;
             powerpc-apple-macos* )
                 PLATFORM_MAC=1
                 PLATFORM_MACOS=1
@@ -109,6 +113,9 @@ AC_DEFUN([AC_BAKEFILE_PLATFORM],
             beos )
                 PLATFORM_BEOS=1
             ;;
+            *-*-haiku* )
+                PLATFORM_HAIKU=1
+            ;;
             * )
                 AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
             ;;
@@ -121,6 +128,7 @@ AC_DEFUN([AC_BAKEFILE_PLATFORM],
     AC_SUBST(PLATFORM_MACOS)
     AC_SUBST(PLATFORM_MACOSX)
     AC_SUBST(PLATFORM_BEOS)
+    AC_SUBST(PLATFORM_HAIKU)
 ])
 
 
@@ -146,8 +154,8 @@ AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
         fi
         ;;
 
-      i*86-*-beos* )
-        LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
+      i*86-*-beos* | i*86-*-haiku*)
+         LDFLAGS="-L$(shell finddir B_SYSTEM_LIB_DIRECTORY) $LDFLAGS"
         ;;
     esac
 ])
@@ -363,7 +371,7 @@ AC_DEFUN([AC_BAKEFILE_SHARED_LD],
         fi
       ;;
 
-      *-*-beos* )
+      *-*-beos* | i*86-*-haiku*)
         dnl can't use gcc under BeOS for shared library creation because it
         dnl complains about missing 'main'
         SHARED_LD_CC="${LD} -nostart -o"
diff --git a/rules/autoconf.bkl b/rules/autoconf.bkl
index 5db3c6c..3730847 100644
--- a/rules/autoconf.bkl
+++ b/rules/autoconf.bkl
@@ -76,6 +76,7 @@
     <option name="PLATFORM_MACOSX"/>
     <option name="PLATFORM_OS2"/>
     <option name="PLATFORM_BEOS"/>
+    <option name="PLATFORM_HAIKU"/>
 
     <option name="srcdir" never_empty="1"/>
     <option name="top_srcdir"/>
diff --git a/rules/common.bkl b/rules/common.bkl
index e483793..72be035 100644
--- a/rules/common.bkl
+++ b/rules/common.bkl
@@ -42,6 +42,7 @@
     <set var="PLATFORM_MACOSX" overwrite="0">0</set>
     <set var="PLATFORM_OS2" overwrite="0">0</set>
     <set var="PLATFORM_BEOS" overwrite="0">0</set>
+    <set var="PLATFORM_HAIKU" overwrite="0">0</set>
     <set var="PLATFORM_SYMBIAN" overwrite="0">0</set>
 
     <define-rule name="compilation_rule">
-- 
2.16.2

