Allow Haiku build of libretro target

This commit is contained in:
Benjamin FRANCOIS 2021-09-20 19:03:47 -07:00 committed by Tim Allen
parent 74f6ffe89b
commit 6fc6bf14a3
4 changed files with 27 additions and 1 deletions

View File

@ -19,6 +19,8 @@ obj/libretro.o: target-libretro/libretro.cpp
all: $(objects)
ifeq ($(platform),linux)
$(strip $(compiler) -o out/$(name).so -shared $(objects) -Wl,--no-undefined -Wl,--version-script=target-libretro/link.T -lgomp -Wl,-Bdynamic $(options))
else ifeq ($(platform),haiku)
$(strip $(compiler) -o out/$(name).so -shared $(objects) -Wl,--no-undefined -Wl,--version-script=target-libretro/link.T -lgomp -Wl,-Bdynamic $(options))
else ifeq ($(platform),windows)
$(strip $(compiler) -o out/$(name).dll -shared $(objects) -Wl,--no-undefined -Wl,--version-script=target-libretro/link.T -lgomp -Wl,-Bdynamic $(options))
else ifeq ($(platform),macos)

View File

@ -32,6 +32,8 @@ ifeq ($(platform),)
platform := linux
else ifneq ($(findstring BSD,$(uname)),)
platform := bsd
else ifneq ($(findstring Haiku,$(uname)),)
platform := haiku
else
$(error unknown platform, please specify manually.)
endif
@ -139,6 +141,11 @@ ifeq ($(platform),bsd)
options += -lstdc++ -lm
endif
# haiku settings
ifeq ($(platform),haiku)
options += -lroot
endif
# threading support
ifeq ($(threaded),true)
ifneq ($(filter $(platform),linux bsd),)

View File

@ -267,6 +267,7 @@ inline auto directory::copy(const string& source, const string& target) -> bool
}
#else
inline auto directoryIsFolder(DIR* dp, struct dirent* ep) -> bool {
#if defined(PLATFORM_MACOS) || defined(PLATFORM_LINUX) || defined(PLATFORM_BSD)
if(ep->d_type == DT_DIR) return true;
if(ep->d_type == DT_LNK || ep->d_type == DT_UNKNOWN) {
//symbolic links must be resolved to determine type
@ -274,6 +275,15 @@ inline auto directory::copy(const string& source, const string& target) -> bool
fstatat(dirfd(dp), ep->d_name, &sp, 0);
return S_ISDIR(sp.st_mode);
}
#else // strictly POSIX systems
struct stat sp = {0};
stat(ep->d_name, &sp);
if S_ISDIR(sp.st_mode) return true;
if (S_ISLNK(sp.st_mode) || not S_ISREG(sp.st_mode)) {
fstatat(dirfd(dp), ep->d_name, &sp, 0);
return S_ISDIR(sp.st_mode);
}
#endif
return false;
}

View File

@ -4,7 +4,7 @@ namespace nall {
using uint = unsigned;
enum class Compiler : uint { Clang, GCC, Microsoft, Unknown };
enum class Platform : uint { Windows, MacOS, Linux, BSD, Android, Unknown };
enum class Platform : uint { Windows, MacOS, Linux, BSD, Haiku, Android, Unknown };
enum class API : uint { Windows, Posix, Unknown };
enum class DisplayServer : uint { Windows, Quartz, Xorg, Unknown };
enum class Architecture : uint { x86, amd64, ARM32, ARM64, PPC32, PPC64, Unknown };
@ -105,6 +105,13 @@ namespace nall {
constexpr auto platform() -> Platform { return Platform::BSD; }
constexpr auto api() -> API { return API::Posix; }
constexpr auto display() -> DisplayServer { return DisplayServer::Xorg; }
#elif defined(__HAIKU__)
#define PLATFORM_HAIKU
#define API_POSIX
#define DISPLAY_UNKNOWN
constexpr auto platform() -> Platform { return Platform::Haiku; }
constexpr auto api() -> API { return API::Posix; }
constexpr auto display() -> DisplayServer { return DisplayServer::Unknown; }
#else
#warning "unable to detect platform"
#define PLATFORM_UNKNOWN