From b8ac533b9e0161853b90b61e8e2a93a8867e3009 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Fri, 7 Dec 2018 17:01:34 +0100
Subject: [PATCH 1/5] Add Configure cases for Haiku for shared libs

---
 configure.ac | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 34700f0b2..be1cc0943 100644
--- a/configure.ac
+++ b/configure.ac
@@ -374,6 +374,7 @@ in
    elf*     ) LDFLAGS_DYNAMIC="";;
    freebsd* ) LDFLAGS_DYNAMIC="-export-dynamic";;
    gnu*     ) LDFLAGS_DYNAMIC="-export-dynamic";;
+   haiku*   ) LDFLAGS_DYNAMIC="-export-dynamic";;
    hpux*    ) LDFLAGS_DYNAMIC="-E +s";;
    kfreebsd*) LDFLAGS_DYNAMIC="-export-dynamic";;
    linux*   ) LDFLAGS_DYNAMIC="-export-dynamic";;
@@ -441,7 +442,7 @@ AC_SUBST([can_make_BrlAPIref])
 AC_CACHE_CHECK([for shared object creation command], [brltty_cv_prog_make_object_shared], [dnl
    case "${host_os}"
    in
-      linux*|gnu*|openbsd*|freebsd*|kfreebsd*|netbsd*|*qnx*|cygwin*|mingw*|elf*)
+      linux*|gnu*|openbsd*|freebsd*|kfreebsd*|netbsd*|*qnx*|cygwin*|mingw*|elf*|haiku*)
          brltty_mkshr_ld_make="-shared"
          ;;
       solaris*)
@@ -490,7 +491,7 @@ AC_SUBST([MKREL])
 AC_CACHE_CHECK([for dynamic library creation command], [brltty_cv_prog_mklib], [dnl
 case "${host_os}"
 in
-   linux*|gnu*|openbsd*|freebsd*|kfreebsd*|netbsd*|*qnx*|elf*)
+   linux*|gnu*|openbsd*|freebsd*|kfreebsd*|netbsd*|*qnx*|elf*|haiku*)
       brltty_mklib_ld_make="-shared"
       brltty_mklib_ld_options="-soname"
       ;;
-- 
2.19.1


From f6123bd69220bdbf384da42a4f86371cea9ac593 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Fri, 7 Dec 2018 17:02:20 +0100
Subject: [PATCH 2/5] Check for libnetwork for Haiku in configure

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index be1cc0943..a9b305ab9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -583,7 +583,7 @@ in
       BRLTTY_HAVE_WINDOWS_LIBRARY([gdi32])
       ;;
    *)
-      AC_SEARCH_LIBS([socket], [socket])
+      AC_SEARCH_LIBS([socket], [socket network])
       AC_SEARCH_LIBS([inet_ntoa], [nsl])
       ;;
 esac
-- 
2.19.1


From 2c56084954c83e5653ee481d8c2fd34d910e20e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Fri, 7 Dec 2018 17:05:52 +0100
Subject: [PATCH 3/5] Serial: Avoid using CS5 and CS6 if identical to CS7 (as
 on Haiku).

---
 Programs/serial_termios.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Programs/serial_termios.c b/Programs/serial_termios.c
index 577685f9e..d5fe98da5 100644
--- a/Programs/serial_termios.c
+++ b/Programs/serial_termios.c
@@ -194,11 +194,15 @@ serialPutDataBits (SerialAttributes *attributes, unsigned int bits) {
 
   switch (bits) {
 #ifdef CS5
+#if !defined(CS6) || (CS5 != CS6)
     case 5: size = CS5; break;
+#endif
 #endif /* CS5 */
 
 #ifdef CS6
+#if !defined(CS7) || (CS6 != CS7)
     case 6: size = CS6; break;
+#endif
 #endif /* CS6 */
 
 #ifdef CS7
@@ -334,11 +338,15 @@ serialGetDataBits (const SerialAttributes *attributes) {
 
   switch (size) {
 #ifdef CS5
+#if !defined(CS6) || (CS5 != CS6)
     case CS5: return 5;
+#endif
 #endif /* CS5 */
 
 #ifdef CS6
+#if !defined(CS7) || (CS6 != CS7)
     case CS6: return 6;
+#endif
 #endif /* CS6 */
 
 #ifdef CS7
-- 
2.19.1


From e99472d9a0133a7e326a4c162bf698c410fdafc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Fri, 7 Dec 2018 17:07:00 +0100
Subject: [PATCH 4/5] Use proper header to get fd_set (Haiku needs sys/select.h
 as per POSIX).

---
 Drivers/Braille/Virtual/braille.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Drivers/Braille/Virtual/braille.c b/Drivers/Braille/Virtual/braille.c
index 081d011f9..bd9171243 100644
--- a/Drivers/Braille/Virtual/braille.c
+++ b/Drivers/Braille/Virtual/braille.c
@@ -35,6 +35,7 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 #endif /* __MINGW32__ */
+#include "get_select.h"
 
 #if !defined(AF_LOCAL) && defined(AF_UNIX)
 #define AF_LOCAL AF_UNIX
-- 
2.19.1


From a64a7419bdf62bc68758a4860c8f697f453165e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Fri, 7 Dec 2018 17:40:20 +0100
Subject: [PATCH 5/5] Use /dev/ports/pc_serial0 as first port on Haiku

---
 configure.ac | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configure.ac b/configure.ac
index a9b305ab9..f0792b9bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1609,6 +1609,9 @@ in
    solaris*)
       brltty_cv_device_serial_first="ttya"
       ;;
+   haiku*)
+      brltty_cv_device_serial_first="ports/pc_serial0"
+      ;;
    hpux*)
       brltty_cv_device_serial_first="tty0p0"
       ;;
-- 
2.19.1

