From 3f9d50e146abb2e937adf2d6e0fc7dad9634b20e Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sat, 30 Nov 2013 12:14:54 +0100
Subject: Import Allegro 4.4.1.1 fixes that were not upstreamed.


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 245be10..08a2a32 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -291,7 +291,7 @@ if(APPLE)
     endif(COMPILER_GCC)
 endif(APPLE)
 
-if(BEOS)
+if(BEOS OR HAIKU)
     if(CMAKE_SYSTEM_NAME STREQUAL Haiku)
         set(ALLEGRO_HAIKU 1)
     else(CMAKE_SYSTEM_NAME STREQUAL Haiku)
@@ -300,9 +300,9 @@ if(BEOS)
     set(WFLAGS "-W -Wall -Wno-unused -Wno-multichar")
     set(WFLAGS_C_ONLY "")
     set(WFLAGS_CXX_ONLY "-Wno-ctor-dtor-privacy")
-endif(BEOS)
+endif()
 
-if(UNIX AND NOT APPLE AND NOT BEOS)
+if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
     set(ALLEGRO_UNIX 1)
 endif()
 
@@ -628,10 +628,10 @@ endif(WIN32)
 
 # -- Haiku/BeOS --
 
-if(BEOS)
+if(BEOS OR HAIKU)
     list(APPEND PLATFORM_SOURCES ${ALLEGRO_SRC_BEOS_FILES})
     list(APPEND PLATFORM_LIBS game midi device)
-endif(BEOS)
+endif()
 
 # -- Mac OS X --
 
diff --git a/cmake/Common.cmake b/cmake/Common.cmake
index 41822dd..1b56e1b 100644
--- a/cmake/Common.cmake
+++ b/cmake/Common.cmake
@@ -43,7 +43,11 @@ endfunction(install_our_library)
 function(install_our_headers)
     foreach(hdr ${ARGN})
         get_source_file_property(LOC ${hdr} MACOSX_PACKAGE_LOCATION)
-        string(REGEX REPLACE "^Headers" "include" LOC ${LOC})
+		if(HAIKU)
+        	string(REGEX REPLACE "^Headers" "develop/headers" LOC ${LOC})
+		else()
+        	string(REGEX REPLACE "^Headers" "include" LOC ${LOC})
+		endif()
         install(FILES ${hdr} DESTINATION ${LOC})
     endforeach()
 endfunction(install_our_headers)
diff --git a/src/beos/bsysapi.cpp b/src/beos/bsysapi.cpp
index c6e4dad..a7c9d46 100644
--- a/src/beos/bsysapi.cpp
+++ b/src/beos/bsysapi.cpp
@@ -128,7 +128,7 @@ static int32 system_thread(void *data)
       using_custom_allegro_app = false;
 
       term = getenv("TERM");
-      if (!strcmp(term, "dumb")) {
+      if (!term || !strcmp(term, "dumb")) {
          /* The TERM environmental variable is set to "dumb" if the app was
           * not started from a terminal.
           */
-- 
1.8.3.4

