From 2f56001ed94a90648d69945216bfcfde6c653d43 Mon Sep 17 00:00:00 2001
From: TURX <turx2003@gmail.com>
Date: Thu, 23 Jan 2020 11:24:33 +0800
Subject: [PATCH 1/2] add includedir support for cmake

---
 src/libcec/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libcec/CMakeLists.txt b/src/libcec/CMakeLists.txt
index 6baee69..2b1cf34 100644
--- a/src/libcec/CMakeLists.txt
+++ b/src/libcec/CMakeLists.txt
@@ -163,7 +163,7 @@ else()
                         ${CMAKE_CURRENT_SOURCE_DIR}/libcec.pc
                         ${CMAKE_INSTALL_PREFIX}
                         ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
-                        ${CMAKE_INSTALL_PREFIX}/include)
+                        ${CMAKE_INSTALL_INCLUDEDIR})
 
   install(FILES         ${CMAKE_CURRENT_SOURCE_DIR}/libcec.pc
           DESTINATION   ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
@@ -176,7 +176,7 @@ install(FILES ${PROJECT_SOURCE_DIR}/../../include/cec.h
               ${PROJECT_SOURCE_DIR}/../../include/ceccloader.h
               ${PROJECT_SOURCE_DIR}/../../include/cectypes.h
               ${PROJECT_SOURCE_DIR}/../../include/version.h
-        DESTINATION include/libcec)
+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libcec)
 
 # libCEC target
 add_library(cec SHARED ${CEC_SOURCES})
-- 
2.20.1


From ec6c5c9cb2a56e93ffcf1df4e465ad526d82c473 Mon Sep 17 00:00:00 2001
From: TURX <turx2003@gmail.com>
Date: Thu, 23 Jan 2020 17:23:19 +0800
Subject: [PATCH] fix Haiku support

---
 src/cec-client/CMakeLists.txt            | 12 ++++++++++--
 src/libcec/cmake/SetBuildInfo.cmake      |  4 ++++
 src/libcec/platform/drm/drm-edid.cpp     |  4 +++-
 src/libcec/platform/posix/serialport.cpp |  4 ++++
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/cec-client/CMakeLists.txt b/src/cec-client/CMakeLists.txt
index 8002d49..30fa489 100644
--- a/src/cec-client/CMakeLists.txt
+++ b/src/cec-client/CMakeLists.txt
@@ -24,7 +24,11 @@ find_package(Threads REQUIRED)
 set(cecclient_SOURCES cec-client.cpp)
 
 # curses
-check_library_exists(curses initscr "" HAVE_CURSES_API)
+if (HAIKU)
+  check_library_exists(ncurses initscr "" HAVE_CURSES_API)
+else()
+  check_library_exists(curses initscr "" HAVE_CURSES_API)
+endif()
 if (HAVE_CURSES_API)
   list(APPEND cecclient_SOURCES curses/CursesControl.cpp)
 
@@ -47,7 +51,11 @@ if (NOT WIN32)
 
   # curses
   if (HAVE_CURSES_API)
-    target_link_libraries(cec-client curses)
+    if (HAIKU)
+      target_link_libraries(cec-client ncurses)
+    else()
+      target_link_libraries(cec-client curses)
+    endif()
     if (HAVE_CURSES_TINFO)
       target_link_libraries(cec-client tinfo)
     endif()
diff --git a/src/libcec/cmake/SetBuildInfo.cmake b/src/libcec/cmake/SetBuildInfo.cmake
index 39bf4be..f0859cd 100644
--- a/src/libcec/cmake/SetBuildInfo.cmake
+++ b/src/libcec/cmake/SetBuildInfo.cmake
@@ -45,7 +45,11 @@ else()
   # add host on which this was built to compile info
   find_program(HAVE_HOSTNAME_BIN hostname /bin /usr/bin /usr/local/bin)
   if(HAVE_HOSTNAME_BIN)
+    if(HAIKU)
+    exec_program(hostname OUTPUT_VARIABLE BUILD_HOST)
+    else()
     exec_program(hostname ARGS -f OUTPUT_VARIABLE BUILD_HOST)
+    endif()
     set(LIB_INFO "${LIB_INFO}@${BUILD_HOST}")
   endif()
 
diff --git a/src/libcec/platform/drm/drm-edid.cpp b/src/libcec/platform/drm/drm-edid.cpp
index a3b1596..20b1bba 100644
--- a/src/libcec/platform/drm/drm-edid.cpp
+++ b/src/libcec/platform/drm/drm-edid.cpp
@@ -62,7 +62,9 @@ uint16_t CDRMEdidParser::GetPhysicalAddress(void)
   while (entry != NULL && enablededid.empty())
   {
     // We look if the element is a symlinl
-    if (entry->d_type == DT_LNK)
+    #ifndef __HAIKU__
+        if (entry->d_type == DT_LNK)
+    #endif // HAIKU
     {
       // We look for the file enable to find the active video card
       std::string path, enabledPath, edidPath;
diff --git a/src/libcec/platform/posix/serialport.cpp b/src/libcec/platform/posix/serialport.cpp
index c97bd69..eaff978 100644
--- a/src/libcec/platform/posix/serialport.cpp
+++ b/src/libcec/platform/posix/serialport.cpp
@@ -186,7 +186,11 @@ bool CSerialSocket::Open(uint64_t iTimeoutMs /* = 0 */)
   else
     m_options.c_iflag |= INPCK | ISTRIP;
 
+#ifdef IMAXBEL
   m_options.c_iflag &= ~(IXON | IXOFF | IXANY | BRKINT | INLCR | IGNCR | ICRNL | IUCLC | IMAXBEL);
+#else
+  m_options.c_iflag &= ~(IXON | IXOFF | IXANY | BRKINT | INLCR | IGNCR | ICRNL | IUCLC);
+#endif
   m_options.c_oflag &= ~(OPOST | ONLCR | OCRNL);
 
   if (tcsetattr(m_socket, TCSANOW, &m_options) != 0)
-- 
2.20.1

