From 40fa92950357dfe54b1daf2306dda354110f26ef Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Thu, 14 Nov 2013 21:46:53 +0100
Subject: Make tecmake aware of Haiku and the lack of libm.


diff --git a/tec_uname b/tec_uname
index cc89349..fc982e0 100755
--- a/tec_uname
+++ b/tec_uname
@@ -148,6 +148,11 @@ ComputeSystemPaths()
 
   TEC_SYSTEM_INC=/usr/include
   
+  if [ $TEC_SYSNAME == Haiku ]; then
+  	TEC_SYSTEM_LIB=`finddir B_SYSTEM_LIB_DIRECTORY`
+  	TEC_SYSTEM_INC=`finddir B_SYSTEM_HEADERS_DIRECTORY`
+  fi
+
   TEC_LUA_LIB=$TEC_SYSTEM_LIB/lua/$LUA_VER
 }
 
diff --git a/tecmake.mak b/tecmake.mak
index f799a07..c955869 100755
--- a/tecmake.mak
+++ b/tecmake.mak
@@ -26,6 +26,9 @@ ifndef TEC_UNAME
   TEC_SYSARCH:=$(shell uname -m)
 
   # Fixes
+  ifeq ($(TEC_SYSNAME), Haiku)
+    TEC_SYSARCH:=$(shell uname -p)
+  endif
   ifeq ($(TEC_SYSNAME), SunOS)
     TEC_SYSARCH:=$(shell uname -p)
   endif
@@ -526,6 +529,11 @@ ifneq ($(findstring Linux, $(TEC_UNAME)), )
   endif
 endif
 
+ifneq ($(findstring Haiku, $(TEC_UNAME)), )
+  UNIX_POSIX = Yes
+  STDLDFLAGS := -shared -Wl,-soname=lib$(TARGETNAME).so
+endif
+
 ifneq ($(findstring IRIX, $(TEC_UNAME)), )
   UNIX_POSIX = Yes
   ifndef NO_LOCAL_LD
@@ -1177,7 +1185,9 @@ ifdef USE_X11
   STDINCS += $(X11_INC)
 endif
 
-LIBS += m
+ifneq "$(TEC_SYSNAME)" "Haiku"
+  LIBS += m
+endif
 
 ifneq ($(findstring cygw, $(TEC_UNAME)), )
   WIN_OTHER := Yes
-- 
1.8.3.4


From 42565b425877585c937807201a9a0766f4286977 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 17 Nov 2013 13:11:00 +0100
Subject: im: do not build zlib and use system one.

Also adjust the tests to look for the system zlib.

diff --git a/src/Makefile b/src/Makefile
index 12153b5..11d90ed 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -7,7 +7,7 @@ endif
 
 .PHONY: do_all im_zlib im im_jp2 im_process im_fftw imlua3 imlua5 imlua_jp2 imlua_process5 imlua_fftw5 $(WINLIBS)
 #do_all: im im_jp2 im_process im_fftw imlua3 imlua5 imlua_jp2 imlua_process5 imlua_fftw5
-do_all: im_zlib im im_jp2 im_process im_process_omp im_fftw imlua5 imlua_jp2 imlua_process5 imlua_process_omp5 imlua_fftw5 $(WINLIBS)
+do_all: im im_jp2 im_process im_process_omp im_fftw imlua5 imlua_jp2 imlua_process5 imlua_process_omp5 imlua_fftw5 $(WINLIBS)
 
 im_zlib:
 	@$(TECMAKE_CMD) MF=im_zlib
diff --git a/test/im_copy.mak b/test/im_copy.mak
index 15867ee..fe4bbb5 100755
--- a/test/im_copy.mak
+++ b/test/im_copy.mak
@@ -8,8 +8,6 @@ USE_IM = Yes
 
 IM = ..
 
-USE_STATIC = Yes
-
 ifneq ($(findstring Win, $(TEC_SYSNAME)), )
   LIBS = im_wmv im_avi vfw32 wmvcore
 endif
diff --git a/test/im_info.mak b/test/im_info.mak
index 211e7af..32aeabb 100755
--- a/test/im_info.mak
+++ b/test/im_info.mak
@@ -7,5 +7,3 @@ SRC = im_info.cpp
 USE_IM = Yes
 
 IM = ..
-
-USE_STATIC = Yes
diff --git a/test/im_view.mak b/test/im_view.mak
index 45e4363..66699c7 100644
--- a/test/im_view.mak
+++ b/test/im_view.mak
@@ -10,5 +10,3 @@ USE_IUP3 = Yes
 USE_IM = Yes
 
 IM = ..
-
-USE_STATIC = Yes
-- 
1.8.3.4


From 7345811a3dc6a7f47efb0c47df974ca2f8ede0d8 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 17 Nov 2013 14:19:01 +0100
Subject: Fix off-by-one error in im_copy test.


diff --git a/test/im_copy.cpp b/test/im_copy.cpp
old mode 100755
new mode 100644
index f664ad2..c6d70d6
--- a/test/im_copy.cpp
+++ b/test/im_copy.cpp
@@ -74,11 +74,11 @@ int main(int argc, char* argv[])
   int image_count;
   imFileGetInfo(ifile, format, compression, &image_count);
 
-  ofile = imFileNew(argv[2], (argc < 3)? format: argv[3], &error);
+  ofile = imFileNew(argv[2], (argc < 4)? format: argv[3], &error);
   if (!ofile)
     goto man_error;
 
-  if (argc < 4)
+  if (argc < 5)
     imFileSetInfo(ofile, compression);
   else
     imFileSetInfo(ofile, argv[4]);
-- 
1.8.3.4

