From ba88fe1ad26fc936fcfece46929b4b1eebb091c1 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Tue, 28 Jan 2014 20:36:56 +0100
Subject: remove hardcoded -lm and add -lnetwork.


diff --git a/src/Makefile b/src/Makefile
index a67cd14..8493bb9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -53,6 +53,11 @@ EXTRA_LDFLAGS = -lnsl -lsocket -R$(XLIB_PATH)
 PLATFORM = unix
 endif
 
+ifeq ($(PLATFORM),haiku)		# native compiling to Haiku
+EXTRA_LDFLAGS = -lnetwork
+PLATFORM = unix
+endif
+
 ifeq ($(PLATFORM),macosx)		# native compiling to Mac OS X
 EXTRA_LDFLAGS = -lstdc++
 PLATFORM = unix
@@ -163,7 +168,7 @@ OPTIONS = -O3 -Wall
 endif
 
 CFLAGS = $(OPTIONS) $(SYS_CFLAGS)  $(EXTRA_CFLAGS) $(CONFIG)
-LDFLAGS =           $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm
+LDFLAGS =           $(SYS_LDFLAGS) $(EXTRA_LDFLAGS)
 
 
 SRCS =	main.c		\
-- 
1.8.3.4


From 142ac2bc985591b85860f6fea82b5161fc4446e9 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Tue, 28 Jan 2014 21:10:09 +0100
Subject: Store user files at the right place.


diff --git a/src/main.c b/src/main.c
index aaa3a5b..03723fb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,6 +13,9 @@
 
 #include "libgame/libgame.h"
 
+#include <FindDirectory.h>
+#include <sys/stat.h>
+
 #include "main.h"
 #include "init.h"
 #include "game.h"
@@ -5588,11 +5591,27 @@ int main(int argc, char *argv[])
 {
   char * window_title_string = getWindowTitleString();
 
+#ifdef __HAIKU__
+  char datadir[256];
+  find_directory(B_USER_SETTINGS_DIRECTORY, 0, true, datadir, sizeof(datadir));
+  strcat(datadir,"/rocksndiamonds");
+  find_directory(B_USER_DIRECTORY, 0, true, datadir, sizeof(datadir));
+  char* ptr = datadir;
+  while(*ptr != 0) ptr++;
+  ptr++;
+  mkdir(ptr, 0770);
+  InitProgramInfo(argv[0], ptr, ptr,
+		  PROGRAM_TITLE_STRING, window_title_string, ICON_TITLE_STRING,
+		  X11_ICON_FILENAME, X11_ICONMASK_FILENAME, SDL_ICON_FILENAME,
+		  MSDOS_POINTER_FILENAME,
+		  COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
+#else
   InitProgramInfo(argv[0], USERDATA_DIRECTORY, USERDATA_DIRECTORY_UNIX,
 		  PROGRAM_TITLE_STRING, window_title_string, ICON_TITLE_STRING,
 		  X11_ICON_FILENAME, X11_ICONMASK_FILENAME, SDL_ICON_FILENAME,
 		  MSDOS_POINTER_FILENAME,
 		  COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
+#endif
 
   InitExitMessageFunction(DisplayExitMessage);
   InitExitFunction(CloseAllAndExit);
-- 
1.8.3.4

