From c7705cf4c57cfde854547a12ad380ef6b02a81ef Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 15 Jul 2014 10:39:30 -0400
Subject: [PATCH] Add minimal Haiku support; based on Adrien's patch.

---
 configure.py       | 7 +------
 platform_helper.py | 7 ++++++-
 src/util.cc        | 2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/configure.py b/configure.py
index 64123a0..d49a77d 100755
--- a/configure.py
+++ b/configure.py
@@ -247,12 +247,7 @@ if not platform.is_windows() and not platform.is_solaris():
 
 n.comment('the depfile parser and ninja lexers are generated using re2c.')
 def has_re2c():
-    import subprocess
-    try:
-        proc = subprocess.Popen(['re2c', '-V'], stdout=subprocess.PIPE)
-        return int(proc.communicate()[0], 10) >= 1103
-    except OSError:
-        return False
+    return False
 if has_re2c():
     n.rule('re2c',
            command='re2c -b -i --no-generation-date -o $out $in',
diff --git a/platform_helper.py b/platform_helper.py
index bc3a125..efc0887 100644
--- a/platform_helper.py
+++ b/platform_helper.py
@@ -19,7 +19,7 @@ import sys
 
 def platforms():
     return ['linux', 'darwin', 'freebsd', 'openbsd', 'solaris', 'sunos5',
-            'mingw', 'msvc', 'gnukfreebsd', 'bitrig']
+            'mingw', 'msvc', 'gnukfreebsd8', 'bitrig', 'haiku']
 
 class Platform(object):
     def __init__(self, platform):
@@ -43,6 +43,8 @@ class Platform(object):
             self._platform = 'msvc'
         elif self._platform.startswith('bitrig'):
             self._platform = 'bitrig'
+        elif self._platform.startswith('haiku'):
+            self._platform = 'haiku'
 
     def platform(self):
         return self._platform
@@ -81,3 +83,6 @@ class Platform(object):
 
     def is_bitrig(self):
         return self._platform == 'bitrig'
+
+    def is_haiku(self):
+        return self._platform == 'haiku'
diff --git a/src/util.cc b/src/util.cc
index 484b0c1..dae7e3f 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -414,7 +414,7 @@ int GetProcessorCount() {
 #endif
 }
 
-#if defined(_WIN32) || defined(__CYGWIN__)
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(__HAIKU__)
 double GetLoadAverage() {
   // TODO(nicolas.despres@gmail.com): Find a way to implement it on Windows.
   // Remember to also update Usage() when this is fixed.
-- 
1.8.3.4

