From d1451ae108bc3bef182ca16e5b1a625483346cfe Mon Sep 17 00:00:00 2001
From: Jonathan Schleifer <js@webkeks.org>
Date: Wed, 26 Mar 2014 02:26:37 +0100
Subject: [PATCH 1/5] Add Haiku to config.bfd

Merged the config.bfd from gdb-7.7 with the config.bfd from our
buildtools.
---
 bfd/config.bfd | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/bfd/config.bfd b/bfd/config.bfd
index 4edcc6a..91a72db 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -334,7 +334,7 @@ case "${targ}" in
     ;;
   arm-*-elf | arm-*-freebsd* | arm*-*-linux-* | arm*-*-conix* | \
   arm*-*-uclinux* | arm-*-kfreebsd*-gnu | \
-  arm*-*-eabi* )
+  arm*-*-eabi* | arm*-*-haiku*)
     targ_defvec=bfd_elf32_littlearm_vec
     targ_selvecs=bfd_elf32_bigarm_vec
     ;;
@@ -668,6 +668,11 @@ case "${targ}" in
     targ_selvecs="bfd_elf32_i386_vec bfd_elf32_x86_64_vec i386linux_vec i386pei_vec x86_64pei_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec"
     want64=true
     ;;
+  x86_64-*-haiku*)
+    targ_defvec=bfd_elf64_x86_64_vec
+    targ_selvecs="bfd_elf32_i386_vec"
+    want64=true
+    ;;
   x86_64-*-nacl*)
     targ_defvec=bfd_elf32_x86_64_nacl_vec
     targ_selvecs="bfd_elf32_i386_nacl_vec bfd_elf64_x86_64_nacl_vec bfd_elf32_bigarm_nacl_vec bfd_elf32_littlearm_nacl_vec"
@@ -716,6 +721,9 @@ case "${targ}" in
     targ_defvec=bfd_elf32_i386_vec
     targ_selvecs="i386pe_vec i386pei_vec"
     ;;
+  i[3-7]86-*-haiku*)
+    targ_defvec=bfd_elf32_i386_vec
+    ;;
   i[3-7]86-*-interix*)
     targ_defvec=i386pei_vec
     targ_selvecs="i386pe_vec"
@@ -907,7 +915,10 @@ case "${targ}" in
     targ_selvecs=ieee_vec
     targ_underscore=yes
     ;;
-
+  m68*-*-haiku*)
+    targ_defvec=bfd_elf32_m68k_vec
+    targ_selvecs="m68kcoff_vec ieee_vec"
+    ;;
   m88*-harris-cxux* | m88*-*-dgux* | m88*-*-sysv4*)
     targ_defvec=bfd_elf32_m88k_vec
     targ_selvecs=m88kbcs_vec
@@ -963,6 +974,10 @@ case "${targ}" in
     targ_defvec=bfd_elf32_tradlittlemips_vec
     targ_selvecs="bfd_elf32_tradbigmips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec ecoff_little_vec ecoff_big_vec"
     ;;
+  mips*el-*-haiku*)
+    targ_defvec=bfd_elf32_littlemips_vec
+    targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_little_vec ecoff_big_vec"
+    ;;
   mips*-*-netbsd*)
     targ_defvec=bfd_elf32_tradbigmips_vec
     targ_selvecs="bfd_elf32_tradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec ecoff_big_vec ecoff_little_vec"
@@ -1276,6 +1291,11 @@ case "${targ}" in
     targ_selvecs="mach_o_be_vec mach_o_le_vec mach_o_fat_vec pef_vec pef_xlib_vec sym_vec"
     targ_archs="$targ_archs bfd_i386_arch"
     ;;
+  powerpc-*-haiku*)
+    targ_defvec=bfd_elf32_powerpc_vec
+    targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec pef_vec pef_xlib_vec pmac_xcoff_vec ppcboot_vec"
+    targ_cflags=-D__HAIKU_TARGET__
+    ;;
   powerpc-*-macos*)
     targ_defvec=pmac_xcoff_vec
     ;;
-- 
Jonathan


From 95c56e69655292af02df81204a6957af8589f91e Mon Sep 17 00:00:00 2001
From: Jonathan Schleifer <js@webkeks.org>
Date: Wed, 26 Mar 2014 02:36:02 +0100
Subject: [PATCH 2/5] Add Haiku to gdb/configure.tgt

---
 gdb/configure.tgt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 47e98d9..e7843f6 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -687,6 +687,10 @@ x86_64-*-openbsd*)
 			i387-tdep.o i386bsd-tdep.o i386obsd-tdep.o \
 			bsd-uthread.o solib-svr4.o"
 	;;
+x86_64-*-haiku*)
+	# Target: Haiku/x86_64
+	gdb_target_obs="amd64-tdep.o i386-tdep.o i387-tdep.o solib-svr4.o"
+	;;
 xtensa*-*-linux*)	gdb_target=linux
 	# Target: GNU/Linux Xtensa
 	gdb_target_obs="xtensa-tdep.o xtensa-config.o xtensa-linux-tdep.o \
-- 
Jonathan


From 809b3250039450b348f16aee7430d4c98b8ca2ec Mon Sep 17 00:00:00 2001
From: Jonathan Schleifer <js@webkeks.org>
Date: Wed, 26 Mar 2014 02:54:53 +0100
Subject: [PATCH 3/5] Add gdb/config/i386/haiku64.mh

---
 gdb/config/i386/haiku64.mh | 2 ++
 gdb/configure.host         | 1 +
 2 files changed, 3 insertions(+)
 create mode 100644 gdb/config/i386/haiku64.mh

diff --git a/gdb/config/i386/haiku64.mh b/gdb/config/i386/haiku64.mh
new file mode 100644
index 0000000..aa99883
--- /dev/null
+++ b/gdb/config/i386/haiku64.mh
@@ -0,0 +1,2 @@
+# Host: Haiku/x86_64
+NATDEPFILES= fork-child.o amd64-nat.o
diff --git a/gdb/configure.host b/gdb/configure.host
index 634213f..e91e8bd 100644
--- a/gdb/configure.host
+++ b/gdb/configure.host
@@ -183,6 +183,7 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
 x86_64-*-netbsd* | x86_64-*-knetbsd*-gnu)
 			gdb_host=nbsd64 ;;
 x86_64-*-openbsd*)	gdb_host=obsd64 ;;
+x86_64-*-haiku*)	gdb_host=haiku64 ;;
 x86_64-*-mingw*)        gdb_host=mingw64
 			gdb_host_obs=mingw-hdep.o
 			;;
-- 
Jonathan


From 4ed8b2a84a58416de1baf6d2222b377e1462a3d5 Mon Sep 17 00:00:00 2001
From: Jonathan Schleifer <js@webkeks.org>
Date: Wed, 26 Mar 2014 03:11:41 +0100
Subject: [PATCH 4/5] Look for socketpair and gethostbyname in -lnetwork

---
 gdb/configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/configure.ac b/gdb/configure.ac
index 55f37d2..6fd12a7 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -510,10 +510,10 @@ AC_CHECK_FUNC(wctype, [],
   [AC_CHECK_LIB(w, wctype)])
 
 # Some systems (e.g. Solaris) have `gethostbyname' in libnsl.
-AC_SEARCH_LIBS(gethostbyname, nsl)
+AC_SEARCH_LIBS(gethostbyname, [nsl network])
 
 # Some systems (e.g. Solaris) have `socketpair' in libsocket.
-AC_SEARCH_LIBS(socketpair, socket)
+AC_SEARCH_LIBS(socketpair, [socket network])
 
 # Link in zlib if we can.  This allows us to read compressed debug sections.
 AM_ZLIB
-- 
Jonathan


From ede4bf96bdfa2e6f4f36d7e0056adc5cdec70058 Mon Sep 17 00:00:00 2001
From: Jonathan Schleifer <js@webkeks.org>
Date: Wed, 26 Mar 2014 03:17:18 +0100
Subject: [PATCH 5/5] Remove autoconf version check

---
 config/override.m4 | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/config/override.m4 b/config/override.m4
index 52bd1c3..3af7e21 100644
--- a/config/override.m4
+++ b/config/override.m4
@@ -27,27 +27,6 @@ AC_DEFUN([AC_PREREQ], [frob])
 m4_copy_force([_AC_PREREQ], [AC_PREREQ])
 
 
-dnl Ensure exactly this Autoconf version is used
-m4_ifndef([_GCC_AUTOCONF_VERSION],
-  [m4_define([_GCC_AUTOCONF_VERSION], [2.64])])
-
-dnl Test for the exact version when AC_INIT is expanded.
-dnl This allows to update the tree in steps (for testing)
-dnl by putting
-dnl   m4_define([_GCC_AUTOCONF_VERSION], [X.Y])
-dnl in configure.ac before AC_INIT,
-dnl without rewriting this file.
-dnl Or for updating the whole tree at once with the definition above.
-AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
-[m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
-  m4_defn([m4_PACKAGE_VERSION]), [],
-  [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
-])
-m4_define([AC_INIT], m4_defn([AC_INIT])[
-_GCC_AUTOCONF_VERSION_CHECK
-])
-
-
 dnl Ensure we do not use a buggy M4.
 m4_if(m4_index([..wi.d.], [.d.]), [-1],
   [m4_fatal(m4_do([m4 with buggy strstr detected.  Please install
-- 
Jonathan

