From f31ae852ea345c15c165eae72fc97e2ab6ec6d5e Mon Sep 17 00:00:00 2001
From: Chris Roberts <cpr420@gmail.com>
Date: Wed, 25 Jun 2014 21:57:57 -0600
Subject: Haiku fixes


diff --git a/configure.ac b/configure.ac
index ce217c2..16e8dd8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,7 +60,7 @@ LTDL_INIT([recursive])
 dnl Checks for libraries.
 
 dnl Checks for header files.
-AC_CHECK_HEADERS(limits.h string.h unistd.h stdarg.h sys/time.h fcntl.h)
+AC_CHECK_HEADERS(limits.h string.h unistd.h stdarg.h stdint.h sys/time.h fcntl.h)
 AC_CHECK_HEADERS(sys/resource.h)
 AC_HEADER_DIRENT
 if test ${ac_header_dirent} = no; then
diff --git a/gtags-cscope/find.c b/gtags-cscope/find.c
index 650bbe1..3b950fb 100644
--- a/gtags-cscope/find.c
+++ b/gtags-cscope/find.c
@@ -540,6 +540,7 @@ findassign(char *pattern)
 	char **argv;
 	FILE *ip, *op;
 	char *opts[] = {"-d", "-rs", NULL};
+	int i;
 	STATIC_STRBUF(sb);
 	strbuf_clear(sb);
 
@@ -554,7 +555,7 @@ findassign(char *pattern)
 	op = fopen(temp1, "w");
 	if (op == NULL)
 		return FAILED;
-	for (int i = 0; opts[i] != NULL; i++) {
+	for (i = 0; opts[i] != NULL; i++) {
 		secure_open_args();
 		common();
 		secure_add_args(opts[i]);
diff --git a/libdb/db.h b/libdb/db.h
index c13b67e..f4a68f4 100644
--- a/libdb/db.h
+++ b/libdb/db.h
@@ -40,6 +40,9 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
 
 #include "compat.h"
 
diff --git a/libutil/conf.h b/libutil/conf.h
index 5ac4afc..93ceb0e 100644
--- a/libutil/conf.h
+++ b/libutil/conf.h
@@ -28,7 +28,11 @@
  */
 #define GTAGSCONF       "/etc/gtags.conf"
 #define DEBIANCONF      "/etc/gtags/gtags.conf"
+#ifdef __HAIKU__
+#define GTAGSRC    "globalrc"
+#else
 #define GTAGSRC 	".globalrc"
+#endif
 #ifdef __DJGPP__
 #define DOS_GTAGSRC	"_globalrc"
 #endif
diff --git a/libutil/env.c b/libutil/env.c
index 13148e2..4a83aa5 100644
--- a/libutil/env.c
+++ b/libutil/env.c
@@ -32,6 +32,11 @@
 #include <home_etc.h>
 #endif
 
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#include <fs_info.h>
+#endif
+
 #include "conf.h"
 #include "die.h"
 #include "env.h"
@@ -74,6 +79,11 @@ get_home_directory(void)
 {
 #ifdef HAVE_HOME_ETC_H
 	return _HEdir;
+#elif defined(__HAIKU__)
+	char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+	if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, buffer, sizeof(buffer)) != B_OK)
+		return NULL;
+	return strdup(buffer);
 #else
 	return getenv("HOME");
 #endif
diff --git a/m4/check_curses.m4 b/m4/check_curses.m4
index 14aaec5..a370ec6 100644
--- a/m4/check_curses.m4
+++ b/m4/check_curses.m4
@@ -240,6 +240,9 @@ AC_DEFUN([AC_SEARCH_NCURSES], [
 
     AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
 
+    AC_NCURSES(/boot/system/develop/headers, ncurses.h, -lncurses, -I/boot/system/develop/headers/, "ncurses in /boot/system")
+    AC_NCURSES(/boot/home/config/develop/headers, ncurses.h, -lncurses, -I/boot/home/config/develop/headers, "ncurses in /boot/home/config")
+
     dnl
     dnl We couldn't find ncurses, try SysV curses
     dnl
-- 
2.27.0

