From f7ff33fe121102ad98002de146f4265c185ed3a2 Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Fri, 9 Aug 2013 17:46:35 +0200
Subject: Add support for the Haiku platform


diff --git a/engine/SCons/Platform/__init__.py b/engine/SCons/Platform/__init__.py
index 25ea93e..bda7cb1 100644
--- a/engine/SCons/Platform/__init__.py
+++ b/engine/SCons/Platform/__init__.py
@@ -78,6 +78,8 @@ def platform_default():
             return 'aix'
         elif sys.platform.find('darwin') != -1:
             return 'darwin'
+        elif sys.platform.find('haiku') != -1:
+            return 'haiku'
         else:
             return 'posix'
     elif os.name == 'os2':
diff --git a/engine/SCons/Platform/haiku.py b/engine/SCons/Platform/haiku.py
new file mode 100644
index 0000000..5c802dd
--- /dev/null
+++ b/engine/SCons/Platform/haiku.py
@@ -0,0 +1,69 @@
+"""SCons.Platform.haiku
+
+Platform-specific initialization for Haiku systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = ""
+
+import commands
+import os
+import posix
+
+def findDir(identifier):
+	return commands.getoutput('finddir %s' % identifier)
+
+def generate(env):
+	posix.generate(env)
+
+	# determine, if building for the secondary architecture
+	secondaryArch = os.environ.get('HAIKU_SECONDARY_ARCH')
+	archSubDir = '/' + secondaryArch if secondaryArch else ''
+
+	# PATH
+	pathDescriptions = [
+		('B_USER_NONPACKAGED_BIN_DIRECTORY', None),
+		('B_USER_CONFIG_DIRECTORY', 'bin'),
+		('B_COMMON_NONPACKAGED_BIN_DIRECTORY', None),
+		('B_COMMON_BIN_DIRECTORY', None),
+		('B_SYSTEM_BIN_DIRECTORY', None)
+		]
+
+	paths = []
+	for pathConstant, subDir in pathDescriptions:
+		path = findDir(pathConstant)
+		if subDir:
+			path += '/' + subDir
+		paths.append(path)
+
+	if secondaryArch:
+		# prepend the secondary arch subdirectories
+		paths = [path + archSubDir for path in paths] + paths
+
+	env['ENV']['PATH'] = ':'.join(paths)
-- 
1.8.3.4


From 9432a1a69d13d1534f6c4d96081cddcb7c566387 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sun, 17 Aug 2014 13:20:45 +0000
Subject: Haiku patch


diff --git a/engine/SCons/Tool/__init__.py b/engine/SCons/Tool/__init__.py
index b946507..d1a74ba 100644
--- a/engine/SCons/Tool/__init__.py
+++ b/engine/SCons/Tool/__init__.py
@@ -305,7 +305,7 @@ symlinks for the platform we are on"""
 
     if version:
         # set the shared library link flags
-        if platform == 'posix':
+        if platform == 'posix' or platform == 'haiku':
             shlink_flags += [ '-Wl,-Bsymbolic' ]
             # OpenBSD doesn't usually use SONAME for libraries
             if not sys.platform.startswith('openbsd'):
diff --git a/engine/SCons/Tool/link.py b/engine/SCons/Tool/link.py
index f6e883f..ed39ab3 100644
--- a/engine/SCons/Tool/link.py
+++ b/engine/SCons/Tool/link.py
@@ -98,7 +98,7 @@ def shlib_emitter_names(target, source, env):
             # We need a version of the form x.y.z to proceed
             raise ValueError
         if version:
-            if platform == 'posix':
+            if platform == 'posix' or platform == 'haiku':
                 versionparts = version.split('.')
                 name = target[0].name
                 # generate library name with the version number
-- 
1.8.3.4

