From fa11c2f2d66ceedbbd2056e29883a1b9a65cf397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Thu, 28 Aug 2014 13:41:12 -0300 Subject: [PATCH 1/3] (Haiku) Fix Build --- Makefile | 7 ++++++- qb/config.libs.sh | 28 +++++++++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index b7f4ca7ad6..fdf3e167ff 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,11 @@ HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h) ifeq ($(findstring Haiku,$(OS)),) LIBS = -lm + DEBUG_FLAG = -g +else + LIBS = -lroot -lnetwork + # stable and nightly haiku builds are stuck on gdb 6.x but we use gcc4 + DEBUG_FLAG = -gdwarf-2 endif DEFINES = -DHAVE_CONFIG_H -DRARCH_INTERNAL -DHAVE_CC_RESAMPLER -DHAVE_OVERLAY @@ -431,7 +436,7 @@ ifeq ($(GL_DEBUG), 1) CXXFLAGS += -DGL_DEBUG endif -CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) -g -I. +CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I. ifeq ($(CXX_BUILD), 1) LINK = $(CXX) CFLAGS += -std=c++0x -xc++ -D__STDC_CONSTANT_MACROS diff --git a/qb/config.libs.sh b/qb/config.libs.sh index bd2773486e..00b4ce6d72 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -10,12 +10,18 @@ add_define_make NOUNUSED_VARIABLE "$HAVE_NOUNUSED_VARIABLE" [ -z "$CROSS_COMPILE" ] && [ -d /opt/local/lib ] && add_library_dirs /opt/local/lib +DYLIB=-ldl; +CLIB=-lc +PTHREADLIB=-lpthread +SOCKETLIB=-lc + if [ "$OS" = 'BSD' ]; then DYLIB=-lc; elif [ "$OS" = 'Haiku' ]; then - DYLIB=""; -else - DYLIB=-ldl; + DYLIB="" + CLIB=-lroot + PTHREADLIB=-lroot + SOCKETLIB=-lnetwork fi add_define_make DYLIB_LIB "$DYLIB" @@ -107,13 +113,13 @@ else add_define_make MAN_DIR "${PREFIX}/share/man/man1" fi -check_lib THREADS -lpthread pthread_create +check_lib THREADS "$PTHREADLIB" pthread_create check_lib DYLIB "$DYLIB" dlopen -check_lib NETPLAY -lc socket +check_lib NETPLAY "$SOCKETLIB" socket if [ "$HAVE_NETPLAY" = 'yes' ]; then HAVE_GETADDRINFO=auto - check_lib GETADDRINFO -lc getaddrinfo + check_lib GETADDRINFO "$SOCKETLIB" getaddrinfo if [ "$HAVE_GETADDRINFO" = 'yes' ]; then HAVE_SOCKET_LEGACY='no' else @@ -124,7 +130,7 @@ else HAVE_NETWORK_CMD='no' fi -check_lib STDIN_CMD -lc fcntl +check_lib STDIN_CMD "$CLIB" fcntl if [ "$HAVE_NETWORK_CMD" = "yes" ] || [ "$HAVE_STDIN_CMD" = "yes" ]; then HAVE_COMMAND='yes' @@ -132,7 +138,7 @@ else HAVE_COMMAND='no' fi -check_lib GETOPT_LONG -lc getopt_long +check_lib GETOPT_LONG "$CLIB" getopt_long if [ "$HAVE_DYLIB" = 'no' ] && [ "$HAVE_DYNAMIC" = 'yes' ]; then echo "Dynamic loading of libretro is enabled, but your platform does not appear to have dlopen(), use --disable-dynamic or --with-libretro=\"-lretro\"". @@ -277,9 +283,9 @@ if [ "$HAVE_UDEV" != "no" ]; then fi fi -check_lib STRL -lc strlcpy -check_lib STRCASESTR -lc strcasestr -check_lib MMAP -lc mmap +check_lib STRL "$CLIB" strlcpy +check_lib STRCASESTR "$CLIB" strcasestr +check_lib MMAP "$CLIB" mmap check_pkgconf PYTHON python3 From ad23b5865486f419f01629f171c19058fe9fba6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Thu, 28 Aug 2014 13:44:22 -0300 Subject: [PATCH 2/3] (Haiku) Fix config paths --- retroarch.c | 11 ++++++++--- settings.c | 12 ++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/retroarch.c b/retroarch.c index 9d012e10a9..d72f330a0f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -830,12 +830,17 @@ static int16_t input_state(unsigned port, unsigned device, return res; } +#if !defined(_WIN32) && !defined(GLOBAL_CONFIG_DIR) +#if defined(__HAIKU__) +#define GLOBAL_CONFIG_DIR "/system/settings" +#else +#define GLOBAL_CONFIG_DIR "/etc" +#endif +#endif + #ifdef _WIN32 #define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tDefaults to retroarch.cfg in same directory as retroarch.exe.\n\t\tIf a default config is not found, RetroArch will attempt to create one." #else -#ifndef GLOBAL_CONFIG_DIR -#define GLOBAL_CONFIG_DIR "/etc" -#endif #define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tBy default looks for config in $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\t$HOME/.config/retroarch/retroarch.cfg,\n\t\tand $HOME/.retroarch.cfg.\n\t\tIf a default config is not found, RetroArch will attempt to create one based on the skeleton config (" GLOBAL_CONFIG_DIR "/retroarch.cfg)." #endif diff --git a/settings.c b/settings.c index e6a4bcb145..96c83b9065 100644 --- a/settings.c +++ b/settings.c @@ -665,7 +665,11 @@ static config_file_t *open_default_config_file(void) if (xdg) fill_pathname_join(conf_path, xdg, "retroarch/retroarch.cfg", sizeof(conf_path)); else if (home) +#ifdef __HAIKU__ + fill_pathname_join(conf_path, home, "config/settings/retroarch/retroarch.cfg", sizeof(conf_path)); +#else fill_pathname_join(conf_path, home, ".config/retroarch/retroarch.cfg", sizeof(conf_path)); +#endif if (xdg || home) { @@ -688,7 +692,11 @@ static config_file_t *open_default_config_file(void) if (xdg) fill_pathname_join(conf_path, xdg, "retroarch/retroarch.cfg", sizeof(conf_path)); else if (home) +#ifdef __HAIKU__ + fill_pathname_join(conf_path, home, "config/settings/retroarch/retroarch.cfg", sizeof(conf_path)); +#else fill_pathname_join(conf_path, home, ".config/retroarch/retroarch.cfg", sizeof(conf_path)); +#endif char basedir[PATH_MAX]; fill_pathname_basedir(basedir, conf_path, sizeof(basedir)); @@ -696,7 +704,11 @@ static config_file_t *open_default_config_file(void) if (path_mkdir(basedir)) { #ifndef GLOBAL_CONFIG_DIR +#if defined(__HAIKU__) +#define GLOBAL_CONFIG_DIR "/system/settings" +#else #define GLOBAL_CONFIG_DIR "/etc" +#endif #endif char skeleton_conf[PATH_MAX]; fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR, "retroarch.cfg", sizeof(skeleton_conf)); From ebeec0d0567dab557a74838ce4afe869dfd5e572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Thu, 28 Aug 2014 13:45:12 -0300 Subject: [PATCH 3/3] (Haiku) Fix fill_pathname_application_path() --- file_path.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/file_path.c b/file_path.c index 2b8746c596..b745847a2c 100644 --- a/file_path.c +++ b/file_path.c @@ -23,6 +23,10 @@ #include "compat/posix_string.h" #include "miscellaneous.h" +#ifdef __HAIKU__ +#include +#endif + #if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) #include //stat() is defined here #endif @@ -874,6 +878,18 @@ void fill_pathname_application_path(char *buf, size_t size) rarch_assert(strlcat(buf, "nobin", size) < size); return; } +#elif defined(__HAIKU__) + image_info info; + int32 cookie = 0; + + while (get_next_image_info(0, &cookie, &info) == B_OK) + { + if (info.type == B_APP_IMAGE) + { + strlcpy(buf, info.name, size); + return; + } + } #else *buf = '\0'; pid_t pid = getpid();