From c1e8a1e692a531f3ef992435a0cc28e98c8e114e Mon Sep 17 00:00:00 2001 From: Jaycie Ewald Date: Tue, 23 May 2023 00:52:43 -0500 Subject: [PATCH] add Haiku OS cross-compile support x86 and x86_64 both tested and working. --- Quake/Makefile | 11 ++++++++++- Quake/arch_def.h | 8 ++++++++ Quake/build_cross_haiku32-sdl2.sh | 17 +++++++++++++++++ Quake/build_cross_haiku64-sdl2.sh | 16 ++++++++++++++++ Quake/net_sys.h | 5 +++-- 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100755 Quake/build_cross_haiku32-sdl2.sh create mode 100755 Quake/build_cross_haiku64-sdl2.sh diff --git a/Quake/Makefile b/Quake/Makefile index 404b6157..beea5e15 100644 --- a/Quake/Makefile +++ b/Quake/Makefile @@ -10,6 +10,9 @@ DO_USERDIRS=0 ### Enable/Disable SDL2 USE_SDL2=0 +### Do we need to link the math library? +LINK_M=1 + ### Enable/Disable codecs for streaming music support USE_CODEC_WAVE=1 USE_CODEC_FLAC=0 @@ -109,6 +112,8 @@ SDL_LIBS := $(shell $(SDL_CONFIG) --libs) ifeq ($(HOST_OS),sunos) NET_LIBS :=-lsocket -lnsl -lresolv +else ifdef HAIKU_OS +NET_LIBS :=-lnetwork else NET_LIBS := endif @@ -180,7 +185,11 @@ ifeq ($(USE_CODEC_UMX),1) CFLAGS+= -DUSE_CODEC_UMX endif -COMMON_LIBS:= -lm -lGL +COMMON_LIBS:= -lGL + +ifeq ($(LINK_M),1) +COMMON_LIBS += -lm +endif LIBS := $(COMMON_LIBS) $(NET_LIBS) $(CODECLIBS) diff --git a/Quake/arch_def.h b/Quake/arch_def.h index 4a27d9ad..8dd5b86d 100644 --- a/Quake/arch_def.h +++ b/Quake/arch_def.h @@ -72,6 +72,12 @@ # define PLATFORM_RISCOS 1 # endif +#elif defined(__HAIKU__) + +# if !defined(PLATFORM_HAIKU) +# define PLATFORM_HAIKU 1 +# endif + #else /* here goes the unix platforms */ #if defined(__unix) || defined(__unix__) || defined(unix) || \ @@ -159,6 +165,8 @@ # define PLATFORM_STRING "RiscOS" #elif defined(__GNU__) # define PLATFORM_STRING "GNU/Hurd" +#elif defined(PLATFORM_HAIKU) +# define PLATFORM_STRING "Haiku" #elif defined(PLATFORM_UNIX) # define PLATFORM_STRING "Unix" #else diff --git a/Quake/build_cross_haiku32-sdl2.sh b/Quake/build_cross_haiku32-sdl2.sh new file mode 100755 index 00000000..b180335d --- /dev/null +++ b/Quake/build_cross_haiku32-sdl2.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Change this script to meet your needs and/or environment. + +TARGET=i586-pc-haiku + +MAKE_CMD=make + +CC="$TARGET-gcc" +AS="$TARGET-as" +RANLIB="$TARGET-ranlib" +AR="$TARGET-ar" +STRIP="$TARGET-strip" +LDFLAGS=-L/usr/lib32 # hack +export CC AS AR RANLIB STRIP LDFLAGS + +exec $MAKE_CMD HAIKU_OS=1 LINK_M=0 USE_SDL2=1 LDFLAGS=$LDFLAGS CC=$CC AS=$AS RANLIB=$RANLIB AR=$AR STRIP=$STRIP -f Makefile $* diff --git a/Quake/build_cross_haiku64-sdl2.sh b/Quake/build_cross_haiku64-sdl2.sh new file mode 100755 index 00000000..0b43404c --- /dev/null +++ b/Quake/build_cross_haiku64-sdl2.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Change this script to meet your needs and/or environment. + +TARGET=x86_64-unknown-haiku + +MAKE_CMD=make + +CC="$TARGET-gcc" +AS="$TARGET-as" +RANLIB="$TARGET-ranlib" +AR="$TARGET-ar" +STRIP="$TARGET-strip" +export CC AS AR RANLIB STRIP + +exec $MAKE_CMD HAIKU_OS=1 LINK_M=0 USE_SDL2=1 CC=$CC AS=$AS RANLIB=$RANLIB AR=$AR STRIP=$STRIP -f Makefile $* diff --git a/Quake/net_sys.h b/Quake/net_sys.h index 77727e3b..bc334dc1 100644 --- a/Quake/net_sys.h +++ b/Quake/net_sys.h @@ -31,7 +31,8 @@ #if defined(PLATFORM_BSD) || defined(PLATFORM_OSX) || \ defined(PLATFORM_AMIGA) /* bsdsocket.library */ || \ - defined(__GNU__) /* GNU/Hurd */ || defined(__riscos__) + defined(__GNU__) /* GNU/Hurd */ || defined(__riscos__) || \ + defined(PLATFORM_HAIKU) /* Haiku OS */ /* struct sockaddr has unsigned char sa_len as the first member in BSD * variants and the family member is also an unsigned char instead of an * unsigned short. This should matter only when PLATFORM_UNIX is defined, @@ -47,7 +48,7 @@ #endif /* BSD, sockaddr */ /* unix includes and compatibility macros */ -#if defined(PLATFORM_UNIX) || defined(PLATFORM_RISCOS) +#if defined(PLATFORM_UNIX) || defined(PLATFORM_RISCOS) || defined(PLATFORM_HAIKU) #include #include