From f8374cc154fccc51dbdd90c13de9d158185a8487 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Fri, 25 Feb 2022 11:43:14 +0100
Subject: Haiku: requires libnetwork


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0b6228a..f0d0a4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -183,6 +183,10 @@ if(NOT HAVE_STDINT_H)
   message(FATAL_ERROR "Could NOT find required header stdint.h")
 endif()
 
+if(HAIKU)
+	set(CMAKE_REQUIRED_LIBRARIES network)
+endif(HAIKU)
+
 check_function_exists(gettimeofday    LIBVNCSERVER_HAVE_GETTIMEOFDAY)
 check_function_exists(vfork           LIBVNCSERVER_HAVE_VFORK)
 check_function_exists(vprintf         LIBVNCSERVER_HAVE_VPRINTF)
@@ -569,6 +573,10 @@ if(ANDROID)
   )
 endif(ANDROID)
 
+if(HAIKU)
+  find_library(NETWORK_LIBRARY network)
+endif(HAIKU)
+
 set(LIBVNCCLIENT_EXAMPLES
     backchannel
     ppmtest
@@ -603,14 +611,14 @@ foreach(e ${LIBVNCSERVER_EXAMPLES})
   add_executable(examples_${e} ${LIBVNCSRVEXAMPLE_DIR}/${e}.c)
   set_target_properties(examples_${e} PROPERTIES OUTPUT_NAME ${e})
   set_target_properties(examples_${e} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/examples)
-  target_link_libraries(examples_${e} vncserver ${CMAKE_THREAD_LIBS_INIT} ${CARBON_LIBRARY} ${IOKIT_LIBRARY} ${IOSURFACE_LIBRARY})
+  target_link_libraries(examples_${e} vncserver ${CMAKE_THREAD_LIBS_INIT} ${CARBON_LIBRARY} ${IOKIT_LIBRARY} ${IOSURFACE_LIBRARY} ${NETWORK_LIBRARY})
 endforeach(e ${LIBVNCSERVER_EXAMPLES})
 
 foreach(e ${LIBVNCCLIENT_EXAMPLES})
   add_executable(client_examples_${e} ${LIBVNCCLIEXAMPLE_DIR}/${e}.c ${LIBVNCCLIEXAMPLE_DIR}/${${e}_EXTRA_SOURCES} )
   set_target_properties(client_examples_${e} PROPERTIES OUTPUT_NAME ${e})
   set_target_properties(client_examples_${e} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/client_examples)
-  target_link_libraries(client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES})
+  target_link_libraries(client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES} ${NETWORK_LIBRARY})
 endforeach(e ${LIBVNCCLIENT_EXAMPLES})
 
 
-- 
2.30.2


From 644d0240c8551537f2ba2fa29e7687e99df97af4 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Fri, 25 Feb 2022 12:08:32 +0100
Subject: undef min on Haiku


diff --git a/libvncserver/websockets.c b/libvncserver/websockets.c
index 9fd96a6..d33b7e5 100644
--- a/libvncserver/websockets.c
+++ b/libvncserver/websockets.c
@@ -98,6 +98,9 @@ static int webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char
 
 static int ws_read(void *cl, char *buf, size_t len);
 
+#ifdef __HAIKU__
+#undef min
+#endif
 
 static int
 min (int a, int b) {
-- 
2.30.2

