From cbe10814911be2ea285d73d455065e430bf6c92a Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 29 Nov 2013 21:27:01 +0100
Subject: applying patch allegro-4.4.1.1.patch


diff --git a/src/beos/bdwindow.cpp b/src/beos/bdwindow.cpp
index 2ef8460..28c9678 100644
--- a/src/beos/bdwindow.cpp
+++ b/src/beos/bdwindow.cpp
@@ -413,9 +413,9 @@ static struct BITMAP *_be_gfx_bdirectwindow_init(GFX_DRIVER *drv, int w, int h,
    }
 
 #ifdef ALLEGRO_NO_ASM
-   bmp->read_bank = _be_gfx_bwindow_read_write_bank;
-   bmp->write_bank = _be_gfx_bwindow_read_write_bank;
-   _screen_vtable.unwrite_bank = _be_gfx_bwindow_unwrite_bank;
+    bmp->read_bank = (void *)_be_gfx_bwindow_read_write_bank;
+    bmp->write_bank = (void *)_be_gfx_bwindow_read_write_bank;
+    _screen_vtable.unwrite_bank = (void *)_be_gfx_bwindow_unwrite_bank;
 #else
    bmp->read_bank = _be_gfx_bwindow_read_write_bank_asm;
    bmp->write_bank = _be_gfx_bwindow_read_write_bank_asm;
diff --git a/src/beos/bwindow.cpp b/src/beos/bwindow.cpp
index d89e1d4..61a1885 100644
--- a/src/beos/bwindow.cpp
+++ b/src/beos/bwindow.cpp
@@ -347,9 +347,9 @@ extern "C" struct BITMAP *be_gfx_bwindow_init(int w, int h, int v_w, int v_h, in
    }
    
 #ifdef ALLEGRO_NO_ASM
-   bmp->read_bank = _be_gfx_bwindow_read_write_bank;
-   bmp->write_bank = _be_gfx_bwindow_read_write_bank;
-   _screen_vtable.unwrite_bank = _be_gfx_bwindow_unwrite_bank;
+   bmp->read_bank = (void *)_be_gfx_bwindow_read_write_bank;
+   bmp->write_bank = (void *)_be_gfx_bwindow_read_write_bank;
+   _screen_vtable.unwrite_bank = (void *)_be_gfx_bwindow_unwrite_bank;
 #else
    bmp->read_bank = _be_gfx_bwindow_read_write_bank_asm;
    bmp->write_bank = _be_gfx_bwindow_read_write_bank_asm;
diff --git a/src/beos/bwscreen.cpp b/src/beos/bwscreen.cpp
index af22981..4aeda05 100644
--- a/src/beos/bwscreen.cpp
+++ b/src/beos/bwscreen.cpp
@@ -363,9 +363,9 @@ static struct BITMAP *_be_gfx_bwindowscreen_init(GFX_DRIVER *drv, int w, int h,
 
 #ifdef ALLEGRO_NO_ASM
    if (gfx_capabilities) {
-      bmp->write_bank = be_gfx_bwindowscreen_read_write_bank;
-      bmp->read_bank  = be_gfx_bwindowscreen_read_write_bank;
-      _screen_vtable.unwrite_bank = be_gfx_bwindowscreen_unwrite_bank;
+      bmp->write_bank = (void *)be_gfx_bwindowscreen_read_write_bank;
+      bmp->read_bank  = (void *)be_gfx_bwindowscreen_read_write_bank;
+      _screen_vtable.unwrite_bank = (void *)be_gfx_bwindowscreen_unwrite_bank;
    }
 #else
    if (gfx_capabilities) {
diff --git a/src/file.c b/src/file.c
index 654e632..7d56d8f 100644
--- a/src/file.c
+++ b/src/file.c
@@ -31,6 +31,10 @@
 #include "allegro.h"
 #include "allegro/internal/aintern.h"
 
+#ifdef ALLEGRO_HAIKU
+   #define O_BINARY 0
+#endif
+
 #ifndef ALLEGRO_MPW
    #include <sys/stat.h>
 #endif
-- 
1.8.3.4


From e3cc30c9d162fff9e1b74985da390969eea932e8 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sat, 30 Nov 2013 11:16:32 +0100
Subject: Allegro: fix recipe following CMake changes

* Our CMake doesn't define BEOS anymore, so have Allegro build accept
HAIKU as well.
* Fix some hardcoded installation paths.
* Add a missing zlib include, I guess because of a newer libpng.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 103d012..7e83070 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -280,7 +280,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)
@@ -288,9 +288,9 @@ if(BEOS)
     endif(CMAKE_SYSTEM_NAME STREQUAL Haiku)
     set(WFLAGS "-W -Wall -Wno-unused -Wno-multichar -Wno-ctor-dtor-privacy")
     set(WFLAGS_C_ONLY "")
-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()
 
@@ -582,10 +582,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/addons/loadpng/loadpng.c b/addons/loadpng/loadpng.c
index 33f5527..9253260 100644
--- a/addons/loadpng/loadpng.c
+++ b/addons/loadpng/loadpng.c
@@ -9,6 +9,7 @@
 #include <allegro.h>
 #include <allegro/internal/aintern.h>
 #include "loadpng.h"
+#include <zlib.h>
 
 /* We need internals _color_load_depth and _fixup_loaded_bitmap.  The
  * first can be replaced by the new get_color_depth() function which
diff --git a/cmake/Common.cmake b/cmake/Common.cmake
index 654c01c..2a9b171 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)
-- 
1.8.3.4


From 8a85c675661240b48a07625473da010646ea6e17 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sat, 30 Nov 2013 11:36:07 +0100
Subject: Avoid a crash when not started from terminal.

BeOS seems to set TERM environment variable to "dumb", but we don't.

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

