From 0b0590688b815e88cb019d4b807519f689024534 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Thu, 21 Feb 2019 16:46:08 +0100
Subject: gcc2 fixes


diff --git a/src/cd_util.c b/src/cd_util.c
index 80d38f1..b5b5759 100644
--- a/src/cd_util.c
+++ b/src/cd_util.c
@@ -841,12 +841,13 @@ int cdStrTmpFileName(char* filename)
   free(tmp);
 #else
   char* dirname = getenv("TMPDIR");
+  int fd;
   if (!dirname) dirname = "/tmp";
   if (strlen(dirname) >= 10240-10)
     return 0;
   strcpy(filename, dirname);
   strcat(filename, "/~cdXXXXXX");
-  int fd = mkstemp(filename);
+  fd = mkstemp(filename);
   if (fd == -1)
     return 0;
   close(fd);
-- 
2.19.1


From b7443a55907fdd203c44938dcdc98c31de2c7ba0 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Thu, 21 Feb 2019 16:49:26 +0100
Subject: Do not link xrender on Haiku


diff --git a/src/cdcontextplus.mak b/src/cdcontextplus.mak
index 2ddfe52..76562b2 100644
--- a/src/cdcontextplus.mak
+++ b/src/cdcontextplus.mak
@@ -20,11 +20,13 @@ else
     CHECK_GTK = Yes
     SRC = cairo/cdcairoplus.c 
   else
-    CHECK_XRENDER = Yes
-    SRC = xrender/cdxrender.c xrender/cdxrplus.c
-    LIBS = Xrender Xft
-    USE_X11 = Yes
-    INCLUDES += x11
+   ifeq ($(findstring Haiku, $(TEC_SYSNAME)), )
+      CHECK_XRENDER = Yes
+      SRC = xrender/cdxrender.c xrender/cdxrplus.c
+      LIBS = Xrender Xft
+      USE_X11 = Yes
+      INCLUDES += x11
+	endif
   endif
 endif
 
diff --git a/src/cdluacontextplus5.mak b/src/cdluacontextplus5.mak
index ee08381..f8a62e4 100644
--- a/src/cdluacontextplus5.mak
+++ b/src/cdluacontextplus5.mak
@@ -12,10 +12,12 @@ LIBS = cdcontextplus
 ifneq ($(findstring Win, $(TEC_SYSNAME)), )
   CHECK_GDIPLUS = Yes
 else
-  ifdef GTK_DEFAULT
-    CHECK_GTK = Yes
-  else
-    CHECK_XRENDER = Yes
+  ifeq ($(findstring Haiku, $(TEC_SYSNAME)), )
+    ifdef GTK_DEFAULT
+      CHECK_GTK = Yes
+    else
+      CHECK_XRENDER = Yes
+    endif
   endif
 endif
 
-- 
2.19.1


From 8c677268d4272342681450c25996093d70acf1d0 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Thu, 21 Feb 2019 16:51:58 +0100
Subject: Use iconv on Haiku

The fallback is glib, which we prefer to avoid.


diff --git a/src/config.mak b/src/config.mak
index f382141..7a29b8b 100644
--- a/src/config.mak
+++ b/src/config.mak
@@ -134,6 +134,7 @@ else
       LIBS += fontconfig
     endif
   else ifdef USE_HAIKU
+    DEFINES += USE_ICONV
     SRC += $(SRCHAIKU) $(SRCNULL)
     LIBS += fontconfig
   else
-- 
2.19.1


From 696f47e419a7a92e528bbe2f2367773fcca0038f Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Thu, 21 Feb 2019 16:56:04 +0100
Subject: Adjust search paths for Haiku


diff --git a/tecmake.mak b/tecmake.mak
index 524b7ec..a599c3d 100644
--- a/tecmake.mak
+++ b/tecmake.mak
@@ -582,6 +582,10 @@ ifneq ($(findstring MacOS, $(TEC_UNAME)), )
   FREETYPE_INC := /sw/include/freetype2
 endif
 
+ifneq ($(findstring Haiku, $(TEC_UNAME)), )
+  FREETYPE_INC := $(shell pkg-config --cflags-only-I freetype2 | cut -b 3-)
+endif
+
 # Definitions for GTK
 ifdef GTK_BASE
   GTK := $(GTK_BASE)
@@ -653,6 +657,11 @@ ifneq ($(findstring CentOS, $(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
@@ -1043,7 +1052,12 @@ ifdef USE_LUA
     endif
   endif
 
-  LUA_INC ?= $(LUA)/include
+  ifneq ($(findstring Haiku, $(TEC_UNAME)), )
+    LUA_INC ?= $(shell pkg-config --cflags-only-I lua | cut -b 3-)
+  else
+    LUA_INC ?= $(LUA)/include
+  endif
+
   INCLUDES += $(LUA_INC)
 
   LUA_BIN ?= $(LUA)/bin/$(TEC_UNAME)
-- 
2.19.1

