From 8a3bdcae63f930cff0200f033e50eaa2fe8f8cef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Thu, 22 Jul 2010 14:02:34 +0200
Subject: build: Add Haiku as a supported OS

using the BeOS backend which should be compatible.
---
 configure.ac | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index b04eb3f..00a991b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,7 +61,8 @@ case "$host_os" in
 	linux*) OS=linux ;;
 	gnu*)	OS=gnu ;;
 	beos*)	OS=beos ;;
-	*)	AC_MSG_ERROR([Unknown or unsupported OS "$host_os".  Only "linux", "gnu" and "beos" are supported in this version of GNU Parted.]) ;;
+	haiku*)	OS=beos ;;
+	*)	AC_MSG_ERROR([Unknown or unsupported OS "$host_os".  Only "linux", "gnu", "beos" and "haiku" are supported in this version of GNU Parted.]) ;;
 esac
 AC_SUBST([OS])
 
-- 
2.2.2


From 46e8c05bb09e9bcfe690039cd22f6a3988dbcd8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Tue, 22 Dec 2015 00:32:27 +0100
Subject: libparted: fix ZETA check

Haiku doesn't define those.
---
 libparted/arch/beos.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libparted/arch/beos.c b/libparted/arch/beos.c
index 6a8a5ae..168f58b 100644
--- a/libparted/arch/beos.c
+++ b/libparted/arch/beos.c
@@ -33,7 +33,7 @@
 #include <drivers/Drivers.h>
 
 /* ZETA R1+ APIs */
-#if B_ZETA_VERSION >= B_ZETA_VERSION_1_0_0
+#if defined(B_ZETA_VERSION) && B_ZETA_VERSION >= B_ZETA_VERSION_1_0_0
 #  include <device/ata_info.h>
 #endif
 
@@ -102,7 +102,7 @@ _flush_cache(PedDevice* dev)
 	}
 }
 
-#if B_ZETA_VERSION >= B_ZETA_VERSION_1_0_0
+#if defined(B_ZETA_VERSION) && B_ZETA_VERSION >= B_ZETA_VERSION_1_0_0
 static int
 _device_init_ata(PedDevice* dev)
 {
@@ -218,7 +218,7 @@ _device_init_blkdev(PedDevice* dev)
 {
 	int type;
 
-#if B_ZETA_VERSION >= B_ZETA_VERSION_1_0_0
+#if defined(B_ZETA_VERSION) && B_ZETA_VERSION >= B_ZETA_VERSION_1_0_0
 	if (!(type=_device_init_ata(dev)))
 #endif
 	type = _device_init_generic_blkdev(dev);
-- 
2.2.2


From 0cfd6f520aa3da1b6da6e45b0509857c6a1ba567 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Tue, 22 Dec 2015 00:35:19 +0100
Subject: xfs: define loff_t for platforms lacking it

It's not a POSIX type.
---
 libparted/fs/xfs/platform_defs.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libparted/fs/xfs/platform_defs.h b/libparted/fs/xfs/platform_defs.h
index 2b55752..b754979 100644
--- a/libparted/fs/xfs/platform_defs.h
+++ b/libparted/fs/xfs/platform_defs.h
@@ -51,6 +51,10 @@
 # define constpp	char * const *
 #endif
 
+#ifdef __HAIKU__
+typedef off_t		loff_t;
+#endif
+
 typedef loff_t		xfs_off_t;
 typedef uint64_t	xfs_ino_t;
 typedef uint32_t	xfs_dev_t;
-- 
2.2.2


From 662700691d3bebc085ca36f0674f6261640c25b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Tue, 22 Dec 2015 01:01:53 +0100
Subject: libparted: fix Haiku build

---
 libparted/arch/beos.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/libparted/arch/beos.c b/libparted/arch/beos.c
index 168f58b..da05f2e 100644
--- a/libparted/arch/beos.c
+++ b/libparted/arch/beos.c
@@ -270,7 +270,6 @@ done:
 static PedDevice*
 beos_new (const char* path)
 {
-	struct stat stat_info;
 	PedDevice* dev;
 
 	PED_ASSERT(path != NULL);
@@ -423,12 +422,17 @@ beos_read (const PedDevice* dev, void* buffer, PedSector start, PedSector count)
 		{
 			case PED_EXCEPTION_IGNORE:
 				return 1;
+
 			case PED_EXCEPTION_RETRY:
 				break /* out of switch */;
+
 			case PED_EXCEPTION_UNHANDLED:
 				ped_exception_catch ();
 			case PED_EXCEPTION_CANCEL:
 				return 0;
+			default:
+				PED_ASSERT (0);
+				break;
 		}
 	}
 
@@ -442,7 +446,7 @@ beos_read (const PedDevice* dev, void* buffer, PedSector start, PedSector count)
 		if (status > 0)
 		{
 			read_length -= status;
-			buffer += status;
+			buffer = (char *) buffer + status;
 			continue;
 		}
 
@@ -457,12 +461,17 @@ beos_read (const PedDevice* dev, void* buffer, PedSector start, PedSector count)
 		{
 			case PED_EXCEPTION_IGNORE:
 				return 1;
+
 			case PED_EXCEPTION_RETRY:
 				break;
+
 			case PED_EXCEPTION_UNHANDLED:
 				ped_exception_catch ();
 			case PED_EXCEPTION_CANCEL:
 				return 0;
+			default:
+				PED_ASSERT (0);
+				break;
 		}
 	}
 
@@ -508,12 +517,17 @@ beos_write (PedDevice* dev, const void* buffer, PedSector start,
 		{
 			case PED_EXCEPTION_IGNORE:
 				return 1;
+
 			case PED_EXCEPTION_RETRY:
 				break;
+
 			case PED_EXCEPTION_UNHANDLED:
 				ped_exception_catch ();
 			case PED_EXCEPTION_CANCEL:
 				return 0;
+			default:
+				PED_ASSERT (0);
+				break;
 		}
 	}
 
@@ -531,7 +545,7 @@ beos_write (PedDevice* dev, const void* buffer, PedSector start,
 		if (status > 0)
 		{
 			write_length -= status;
-			buffer += status;
+			buffer = (char *) buffer + status;
 			continue;
 		}
 
@@ -545,12 +559,17 @@ beos_write (PedDevice* dev, const void* buffer, PedSector start,
 		{
 			case PED_EXCEPTION_IGNORE:
 				return 1;
+
 			case PED_EXCEPTION_RETRY:
 				break;
+
 			case PED_EXCEPTION_UNHANDLED:
 				ped_exception_catch ();
 			case PED_EXCEPTION_CANCEL:
 				return 0;
+			default:
+				PED_ASSERT (0);
+				break;
 		}
 	}
 #endif /* !READ_ONLY */
-- 
2.2.2


From 9c306e4985dfbfb94ec9b207a38749ad7ccbc2cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Tue, 22 Dec 2015 01:02:22 +0100
Subject: build: use -lnetwork on Haiku, not -lsocket

---
 configure.ac | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 00a991b..3d88448 100644
--- a/configure.ac
+++ b/configure.ac
@@ -487,11 +487,18 @@ fi
 
 dnl BeOS/ZETA/Haiku:
 
-if test "$OS" = beos; then
-	dnl Include the socket library, as it is a depedency of libuuid
-	dnl and so also of us (due to socket() call in libuuid)
-	OS_LIBS="$OS_LIBS -lsocket"
-fi
+case "$host_os" in
+	beos*)
+		dnl Include the socket library, as it is a depedency of libuuid
+		dnl and so also of us (due to socket() call in libuuid)
+		OS_LIBS="$OS_LIBS -lsocket"
+		;;
+	haiku*)
+		dnl Include the socket library, as it is a depedency of libuuid
+		dnl and so also of us (due to socket() call in libuuid)
+		OS_LIBS="$OS_LIBS -lnetwork"
+		;;
+esac
 
 AC_SUBST([OS_LIBS])
 
-- 
2.2.2


From a3cb2ab877064c01f8e6c67e59a44ab8455576a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Tue, 22 Dec 2015 02:02:37 +0100
Subject: libparted: Haiku doesn't define __BEOS__ anymore

---
 libparted/architecture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libparted/architecture.c b/libparted/architecture.c
index b339dc4..901399e 100644
--- a/libparted/architecture.c
+++ b/libparted/architecture.c
@@ -31,7 +31,7 @@ ped_set_architecture ()
 #ifdef linux
 	extern PedArchitecture ped_linux_arch;
 	const PedArchitecture* arch = &ped_linux_arch;
-#elif defined(__BEOS__)
+#elif defined(__BEOS__) || defined(__HAIKU__)
 	extern PedArchitecture ped_beos_arch;
 	const PedArchitecture* arch = &ped_beos_arch;
 #else
-- 
2.2.2


From 12e0852afd98e23bdd8eab0b8e12bb2c92a05868 Mon Sep 17 00:00:00 2001
From: fbrosson <fbrosson@localhost>
Date: Wed, 16 Mar 2016 21:48:17 +0000
Subject: Add "AC_CONFIG_MACRO_DIR([m4])" to configure.ac


diff --git a/configure.ac b/configure.ac
index 9b9d13a..16856eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,7 @@ dnl This file may be modified and/or distributed without restriction.
 AC_PREREQ([2.63])
 AC_INIT([GNU parted], m4_esyscmd([build-aux/git-version-gen .version]),
         [bug-parted@gnu.org])
-
+AC_CONFIG_MACRO_DIR([m4])
 # When the most recent signed tag is v1.8.8.1,
 # the above might set e.g., PACKAGE_VERSION='1.8.8.1.1-0bfc'
 
-- 
2.2.2


From 48186e284a4f74c93a5961cd3ab50c2e44a98de5 Mon Sep 17 00:00:00 2001
From: fbrosson <fbrosson@localhost>
Date: Wed, 16 Mar 2016 21:48:17 +0000
Subject: build: use -lroot on Haiku, not -ldl


diff --git a/configure.ac b/configure.ac
index 16856eb..f49c291 100644
--- a/configure.ac
+++ b/configure.ac
@@ -307,13 +307,13 @@ DL_LIBS=""
 AC_SUBST([DYNAMIC_LOADING])
 DYNAMIC_LOADING=no
 if test "$enable_dynamic_loading" = yes; then
-	AC_CHECK_LIB([dl], [dlopen],
-		DL_LIBS="-ldl"
-		PARTED_LIBS="$PARTED_LIBS -ldl"
+	AC_CHECK_LIB([root], [dlopen],
+		DL_LIBS="-lroot"
+		PARTED_LIBS="$PARTED_LIBS -lroot"
 		DYNAMIC_LOADING=yes
 		AC_DEFINE([DYNAMIC_LOADING], [1], [Lazy linking to fs libs]),
 		AC_MSG_ERROR(
-			[-ldl not found!  Try using --disable-dynamic-loading]
+			[-lroot not found!  Try using --disable-dynamic-loading]
 		)
 	)
 fi
-- 
2.2.2


From 8d65604e26ab20d2bf2a0cbd95821e95cd9c9384 Mon Sep 17 00:00:00 2001
From: fbrosson <fbrosson@localhost>
Date: Wed, 16 Mar 2016 21:48:17 +0000
Subject: Do not install lib/charset.alias.


diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index bbc592a..9084514 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -573,7 +573,7 @@ install-exec-localcharset: all-local
 	  case '$(host_os)' in \
 	    darwin[56]*) \
 	      need_charset_alias=true ;; \
-	    darwin* | cygwin* | mingw* | pw32* | cegcc*) \
+	    darwin* | cygwin* | mingw* | pw32* | cegcc* | haiku*) \
 	      need_charset_alias=false ;; \
 	    *) \
 	      need_charset_alias=true ;; \
-- 
2.2.2
