From f902e34fd74091fcd8034065583c0c6594f36505 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 24 Jan 2016 14:37:04 +0100
Subject: Haiku fixes

- Search for plib in the right place
- Do not try to use X11

diff --git a/cmake/FindPLIB.cmake b/cmake/FindPLIB.cmake
index 519c3c0..eb167aa 100644
--- a/cmake/FindPLIB.cmake
+++ b/cmake/FindPLIB.cmake
@@ -16,14 +16,14 @@ IF(NOT APPLE)
  FIND_PATH(PLIB_PLIBINCLUDE_DIR plib/ssg.h
   HINTS ENV PLIB_DIR
   PATH_SUFFIXES 
-	Headers include/plib include
+	Headers include/plib include develop/headers develop/headers/plib
   PATHS
 #Additional MacOS Paths
-   	 ~/Library/Frameworks/plib.framework
-  	 /Library/Frameworks/plib.framework
- 	 /System/Library/Frameworks/plib.framework # Tiger
-
+	 ~/Library/Frameworks/plib.framework
+	 /Library/Frameworks/plib.framework
+	 /System/Library/Frameworks/plib.framework # Tiger
 	/usr /usr/local
+	/system
   DOC "Location of plib")
 ENDIF(NOT APPLE)
 
diff --git a/src/libs/tgfclient/CMakeLists.txt b/src/libs/tgfclient/CMakeLists.txt
index 28cbc42..820bab1 100644
--- a/src/libs/tgfclient/CMakeLists.txt
+++ b/src/libs/tgfclient/CMakeLists.txt
@@ -55,12 +55,12 @@ IF(WIN32)
     TARGET_LINK_LIBRARIES(tgfclient winmm)
 ENDIF(WIN32)
 
-IF(UNIX)
+IF(UNIX AND NOT HAIKU)
     ADD_X11_LIBRARY(tgfclient)
     IF(OPTION_XRANDR)
         ADD_XRANDR_LIBRARY(tgfclient)
     ENDIF(OPTION_XRANDR)
-ENDIF(UNIX)
+ENDIF(UNIX AND NOT HAIKU)
 
 IF(UNIX)
     SD_INSTALL_FILES(LIB lib TARGETS tgfclient)
-- 
2.21.0


From d727ec6643748f8c8e741bdebf25cf5bf5c01e59 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 24 Jan 2016 16:09:57 +0100
Subject: Disable code unsupported on Haiku.


diff --git a/src/libs/tgf/linuxspec.cpp b/src/libs/tgf/linuxspec.cpp
index 042eb39..0c3adfb 100644
--- a/src/libs/tgf/linuxspec.cpp
+++ b/src/libs/tgf/linuxspec.cpp
@@ -690,6 +690,7 @@ unsigned linuxGetNumberOfCPUs()
 * Remarks
 *    
 */
+#ifndef __HAIKU__
 std::string cpuSet2String(const cpu_set_t* pCPUSet)
 {
 	std::ostringstream ossCPUSet;
@@ -703,6 +704,7 @@ std::string cpuSet2String(const cpu_set_t* pCPUSet)
 	
 	return ossCPUSet.str();
 }
+#endif
 
 bool
 linuxSetThreadAffinity(int nCPUId)
-- 
2.21.0


From 37544f6d9664b6a9bae832693fcbc94c7ccc004c Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 24 Jan 2016 16:20:36 +0100
Subject: isnan vs std::isnan.


diff --git a/src/drivers/human/human.cpp b/src/drivers/human/human.cpp
index 7011a19..76373e5 100644
--- a/src/drivers/human/human.cpp
+++ b/src/drivers/human/human.cpp
@@ -1094,7 +1094,7 @@ common_drive(const int index, tCarElt* car, tSituation *s)
 			}
 			ax0 = ax0 * cmd[CMD_THROTTLE].pow;
 			car->_accelCmd =  pow(fabs(ax0), 1.0f / cmd[CMD_THROTTLE].sens) / (1.0 + cmd[CMD_THROTTLE].spdSens * car->_speed_x / 1000.0);
-			if (isnan (car->_accelCmd)) {
+			if (std::isnan (car->_accelCmd)) {
 				car->_accelCmd = 0;
 			}
 			/* printf("  axO:%f  accelCmd:%f\n", ax0, car->_accelCmd); */
diff --git a/src/libs/learning/policy.cpp b/src/libs/learning/policy.cpp
index 665528b..0c9c2bf 100644
--- a/src/libs/learning/policy.cpp
+++ b/src/libs/learning/policy.cpp
@@ -436,7 +436,7 @@ int DiscretePolicy::SelectAction (int s, real r, int forced_a)
 					// if P[][] remains unchanged between updates.
 					// -- removed because it doesn't work! --
 					//P[i][j] += 0.01*delta * e[i][j] * (1.-P[i][j]);
-					if ((fabs (Q[i][j])>1000.0)||(isnan(Q[i][j]))) {
+					if ((fabs (Q[i][j])>1000.0)||(std::isnan(Q[i][j]))) {
 						printf ("u: %d %d %f %f\n", i,j,Q[i][j], ad * e[i][j]);
 					}
 					
@@ -522,7 +522,7 @@ void DiscretePolicy::loadFile (char* f)
 		if( readSize < (int unsigned)n_actions )
 			fprintf(stderr, "Error when reading file");
 		for (j=0; j<n_actions; j++) {
-			if ((fabs (Q[i][j])>100.0)||(isnan(Q[i][j]))) {
+			if ((fabs (Q[i][j])>100.0)||(std::isnan(Q[i][j]))) {
 				printf ("l: %d %d %f\n", i,j,Q[i][j]);
 				Q[i][j] = 0.0;
 			}
@@ -585,7 +585,7 @@ void DiscretePolicy::saveFile (char* f) {
 		if( writeSize < (int unsigned)n_actions)
 			fprintf( stderr, "Failed to write all data to file %s\n", f);
 		for (int j=0; j<n_actions; j++) {
-			if ((fabs (Q[i][j])>100.0)||(isnan(Q[i][j]))) {
+			if ((fabs (Q[i][j])>100.0)||(std::isnan(Q[i][j]))) {
 				printf ("s: %d %d %f\n", i,j,Q[i][j]);
 			}
 		}
diff --git a/src/modules/simu/simuv2.1/simu.cpp b/src/modules/simu/simuv2.1/simu.cpp
index 0c39a83..c12adbf 100644
--- a/src/modules/simu/simuv2.1/simu.cpp
+++ b/src/modules/simu/simuv2.1/simu.cpp
@@ -28,6 +28,7 @@
 
 #include "sim.h"
 
+using namespace std;
 
 tCar *SimCarTable = 0;
 
-- 
2.21.0


From da7263addb7fb0aa0cb91de260315428f1cc022a Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 24 Jan 2016 16:22:54 +0100
Subject: Do not link against dl


diff --git a/src/tools/nfsperf/CMakeLists.txt b/src/tools/nfsperf/CMakeLists.txt
index fbfc0be..bc2fe61 100755
--- a/src/tools/nfsperf/CMakeLists.txt
+++ b/src/tools/nfsperf/CMakeLists.txt
@@ -16,9 +16,9 @@ ADD_EXECUTABLE(${_TARGET_NAME} ${NFSPERF_SOURCES})
 
 ADD_SDLIB_LIBRARY(${_TARGET_NAME} tgf txml)
 
-IF(UNIX)
+IF(UNIX AND NOT HAIKU)
     TARGET_LINK_LIBRARIES(${_TARGET_NAME} dl)
-ENDIF(UNIX)
+ENDIF(UNIX AND NOT HAIKU)
 
 IF(UNIX)
     SD_INSTALL_FILES(MAN man6 PREFIX ${SOURCE_DIR}/doc/man FILES ${_TARGET_NAME}.6)
diff --git a/src/tools/xmlversion/CMakeLists.txt b/src/tools/xmlversion/CMakeLists.txt
index 3518f93..e65a43e 100644
--- a/src/tools/xmlversion/CMakeLists.txt
+++ b/src/tools/xmlversion/CMakeLists.txt
@@ -20,9 +20,9 @@ ELSE(CMAKE_SKIP_RPATH OR CMAKE_SKIP_BUILD_RPATH)
 	ADD_SDLIB_LIBRARY(xmlversion tgf txml)
 ENDIF(CMAKE_SKIP_RPATH OR CMAKE_SKIP_BUILD_RPATH)
 
-IF(UNIX)
+IF(UNIX AND NOT HAIKU)
   TARGET_LINK_LIBRARIES(xmlversion dl)
-ENDIF(UNIX)
+ENDIF(UNIX AND NOT HAIKU)
 
 GET_TARGET_PROPERTY(XMLVERSION_BUILDLOC xmlversion LOCATION)
 FILE(WRITE ${CMAKE_BINARY_DIR}/xmlversion_loc.txt ${XMLVERSION_BUILDLOC})
-- 
2.21.0


From 3d16186e9b8536caa42964a608d4f6a58e9a6332 Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Sat, 25 May 2019 15:38:21 +0200
Subject: Haiku fixes (from next version)


diff --git a/src/libs/tgf/params.cpp b/src/libs/tgf/params.cpp
index 0b7ce17..82c7953 100644
--- a/src/libs/tgf/params.cpp
+++ b/src/libs/tgf/params.cpp
@@ -3355,7 +3355,7 @@ static char const* GfParmMakePathKey( char const* path, va_list arg, char const
     if( lastSlash != NULL && key )
     {
         *key = lastSlash + 1;
-        lastSlash = '\0';
+        lastSlash = (char*)'\0';
     }
     else if( key )
     {
diff --git a/src/libs/tgfclient/guitexture.cpp b/src/libs/tgfclient/guitexture.cpp
index f795275..e9e0b55 100644
--- a/src/libs/tgfclient/guitexture.cpp
+++ b/src/libs/tgfclient/guitexture.cpp
@@ -392,10 +392,10 @@ GfTexReadImageFromJPEG(const char *filename, float screen_gamma, int *pWidth, in
 	// Initialize the JPEG image decompressor for 24 bit RGB output.
 	jpeg_create_decompress(&cinfo);
 	jpeg_stdio_src(&cinfo, infile);
-	(void)jpeg_read_header(&cinfo, TRUE);
+	(void)jpeg_read_header(&cinfo, (boolean)TRUE);
 
 	cinfo.out_color_space = JCS_RGB;
-	cinfo.quantize_colors = FALSE;
+	cinfo.quantize_colors = (boolean)FALSE;
 	jpeg_calc_output_dimensions(&cinfo);
 	
 	// Load and check image dimensions.
-- 
2.21.0

