From a39422852662c415ca51bf41fb5809e24bae900b Mon Sep 17 00:00:00 2001 From: Hanicef Date: Tue, 24 Sep 2024 21:24:33 +0000 Subject: [PATCH 1/4] Revive Haiku build --- src/Makefile.d/detect.mk | 4 ++- src/Makefile.d/haiku.mk | 71 ++++++++++++++++++++++++++++++++++++++ src/Makefile.d/platform.mk | 4 +++ src/Makefile.d/sdl.mk | 12 ++++--- 4 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 src/Makefile.d/haiku.mk diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk index 9e2736946..853ad3d6d 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -4,7 +4,6 @@ # Previously featured:\ PANDORA\ - HAIKU\ DUMMY\ DJGPPDOS\ SOLARIS\ @@ -17,6 +16,7 @@ all_systems:=\ UNIX\ LINUX\ FREEBSD\ + HAIKU\ # check for user specified system ifeq (,$(filter $(all_systems),$(.VARIABLES))) @@ -35,6 +35,8 @@ system:=$(shell uname -s) ifeq ($(system),Linux) new_system:=LINUX +else ifeq ($(system),Haiku) +new_system:=HAIKU else $(error \ diff --git a/src/Makefile.d/haiku.mk b/src/Makefile.d/haiku.mk new file mode 100644 index 000000000..6742ec75b --- /dev/null +++ b/src/Makefile.d/haiku.mk @@ -0,0 +1,71 @@ +# +# Makefile options for Haiku +# + +opts+=-DUNIXCOMMON -DLUA_USE_POSIX + +ifndef DEDICATED +ifndef DUMMY +SDL?=1 +DEDICATED?=0 +endif +endif + +NOEXECINFO=1 + +ifeq (${SDL},1) +EXENAME?=srb2haiku +else ifeq (${DEDICATED},1) +EXENAME?=srb2haikud +endif + +ifndef NONET +libs+=-lnetwork +endif + +define _set = +$(1)_CFLAGS?=$($(1)_opts) +$(1)_LDFLAGS?=$($(1)_libs) +endef + +lib:=../libs/gme +LIBGME_opts:=-I$(lib)/include +LIBGME_libs:=-l:libgme.so.0 +$(eval $(call _set,LIBGME)) + +lib:=../libs/libopenmpt +LIBOPENMPT_opts:=-I$(lib)/inc +LIBOPENMPT_libs:=-l:libopenmpt.so.0 +$(eval $(call _set,LIBOPENMPT)) + +ifdef SDL +lib:=../libs/SDL2_mixer +mixer_opts:=-I$(lib)/include +mixer_libs:=-l:libSDL2_mixer-2.0.so.0 + +lib:=../libs/SDL2 +SDL_opts:=-I$(lib)/include $(mixer_opts) +SDL_libs:=$(mixer_libs) -l:libSDL2-2.0.so.0 +$(eval $(call _set,SDL)) +endif + +lib:=../libs/zlib +ZLIB_opts:=-I$(lib) +ZLIB_libs:=-l:libz.so.1 +$(eval $(call _set,ZLIB)) + +ifndef PNG_CONFIG +PNG_opts:= +PNG_libs:=-l:libpng16.so.16 +$(eval $(call _set,PNG)) +endif + +lib:=../libs/curl +CURL_opts:=-I$(lib)/include +CURL_libs:=-l:libcurl.so.4 +$(eval $(call _set,CURL)) + +lib:=../libs/miniupnpc +MINIUPNPC_opts:=-I$(lib)/include +MINIUPNPC_libs:=-l:libminiupnpc.so.17 +$(eval $(call _set,MINIUPNPC)) diff --git a/src/Makefile.d/platform.mk b/src/Makefile.d/platform.mk index d9a2954f6..d5423a397 100644 --- a/src/Makefile.d/platform.mk +++ b/src/Makefile.d/platform.mk @@ -35,6 +35,10 @@ endif else ifdef FREEBSD UNIX=1 platform=freebsd +else ifdef HAIKU +# Give Haiku its own configuration, since it +# isn't actually UNIX. +include Makefile.d/haiku.mk else ifdef SOLARIS # FIXME: UNTESTED UNIX=1 platform=solaris diff --git a/src/Makefile.d/sdl.mk b/src/Makefile.d/sdl.mk index a1bfa3303..d5e83989c 100644 --- a/src/Makefile.d/sdl.mk +++ b/src/Makefile.d/sdl.mk @@ -33,11 +33,13 @@ else opts+=-DHAVE_MIXER sources+=sdl/mixer_sound.c - ifdef HAVE_MIXERX - opts+=-DHAVE_MIXERX - libs+=-lSDL2_mixer_ext - else - libs+=-lSDL2_mixer + ifndef HAIKU # Haiku has a special import path + ifdef HAVE_MIXERX + opts+=-DHAVE_MIXERX + libs+=-lSDL2_mixer_ext + else + libs+=-lSDL2_mixer + endif endif endif From 79dd5de63b05a7264d2c3cd39a98cb55d20be76b Mon Sep 17 00:00:00 2001 From: Hanicef Date: Thu, 7 Nov 2024 18:59:13 +0000 Subject: [PATCH 2/4] Include Haiku for nanosleep sleeping --- src/sdl/i_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 9fe50a6a2..07088b957 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2307,7 +2307,7 @@ void I_Sleep(UINT32 ms) void I_SleepDuration(precise_t duration) { -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) UINT64 precision = I_GetPrecisePrecision(); struct timespec ts = { .tv_sec = duration / precision, From 3cf48e31d6efb04dc5f9cd6c0128e3a715530df7 Mon Sep 17 00:00:00 2001 From: Hanicef Date: Thu, 7 Nov 2024 19:23:34 +0000 Subject: [PATCH 3/4] Fix netcode on Haiku --- src/netcode/i_tcp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/netcode/i_tcp.c b/src/netcode/i_tcp.c index ed1f5b4e7..442ed9817 100644 --- a/src/netcode/i_tcp.c +++ b/src/netcode/i_tcp.c @@ -1211,11 +1211,16 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port) // test ip address of server for (i = 0; i < mysocketses; ++i) { +#ifdef __HAIKU__ + // Haiku doesn't appreciate empty packets, so just hope for the best. + if (runp->ai_addr->sa_family == myfamily[i]) +#else /* sendto tests that there is a network to this address */ if (runp->ai_addr->sa_family == myfamily[i] && sendto(mysockets[i], NULL, 0, 0, runp->ai_addr, runp->ai_addrlen) == 0) +#endif { memcpy(&clientaddress[newnode], runp->ai_addr, runp->ai_addrlen); break; From 4a9f10c076169bbf77e495186dedf665534f0d6d Mon Sep 17 00:00:00 2001 From: Hanicef Date: Sat, 14 Dec 2024 15:09:56 +0100 Subject: [PATCH 4/4] Adjust CMakeLists.txt for Haiku --- src/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 20caecf7b..fbd29cddd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -172,6 +172,11 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") endif() endif() +if("${CMAKE_SYSTEM_NAME}" MATCHES "Haiku") + target_compile_definitions(SRB2SDL2 PRIVATE -DNOEXECINFO) + target_link_libraries(SRB2SDL2 PRIVATE network) +endif() + if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") target_compile_definitions(SRB2SDL2 PRIVATE -DMACOSX) endif()