From f4a3757145a508fa9338562b6524f488b0a0c492 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 16:16:44 -0300 Subject: [PATCH 1/7] Further fixes to MXE compilation Adds on the work of PR #130. --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 91049539..a0dd34c5 100644 --- a/Makefile +++ b/Makefile @@ -423,7 +423,13 @@ else endif ifeq ($(WINDOWS_BUILD),1) - LD := $(CXX) + ifeq ($(CROSS),i686-w64-mingw32.static-) # fixes compilation in MXE on Linux and WSL + LD := $(CC) + else ifeq ($(CROSS),x86_64-w64-mingw32.static-) + LD := $(CC) + else + LD := $(CXX) + endif else LD := $(CC) endif From 3d7bdc300cd5c818ee7c677d4ef9718ddfe0402d Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 17:12:56 -0300 Subject: [PATCH 2/7] Add NO_BZERO for MXE --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index a0dd34c5..ece07b95 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,8 @@ TARGET_N64 = 0 # Build and optimize for Raspberry Pi(s) TARGET_RPI ?= 0 +# No BZERO (for building under MXE) +NO_BZERO ?= 0 # Compiler to use (ido or gcc) COMPILER ?= ido @@ -461,6 +463,12 @@ endif # Check for enhancement options +# Check for no bzero option +ifeq ($(NO_BZERO),1) +CC_CHECK += -DNO_BZERO +CFLAGS += -DNO_BZERO +endif + # Check for Puppycam option ifeq ($(BETTERCAMERA),1) CC_CHECK += -DBETTERCAMERA From e42e1587b24c7042de03cf00a715f6fcbd4a8fb4 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 17:14:10 -0300 Subject: [PATCH 3/7] MXE fix for os_libc.h --- include/PR/os_libc.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 94111c0b..13ec2124 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -4,7 +4,13 @@ #include "ultratypes.h" // Old deprecated functions from strings.h, replaced by memcpy/memset. +#ifdef NO_BZERO +#include +#define bzero(buf, size) memset(buf, 0, size) +#define bcopy(src, dst, size) memcpy(dst, src, size) +#else extern void bcopy(const void *, void *, size_t); extern void bzero(void *, size_t); +#endif #endif /* !_OS_LIBC_H_ */ From 8736776545859a9dd6bb33fd4022d1bc598c8dbb Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 17:20:33 -0300 Subject: [PATCH 4/7] Another fix to MXE --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index ece07b95..5903e52f 100644 --- a/Makefile +++ b/Makefile @@ -450,6 +450,12 @@ SDLCONFIG := $(CROSS)sdl2-config ifeq ($(WINDOWS_BUILD),1) CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(SDLCONFIG) --cflags` + ifeq ($(CROSS),i686-w64-mingw32.static-) + ifeq ($(CROSS),x86_64-w64-mingw32.static-) + CC_CHECK += D_NOBZERO + CFLAGS += D_NOBZERO + endif + endif else ifeq ($(TARGET_WEB),1) CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2 From 385e396feb6d6afd4d71d096ddb9378425206402 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 17:21:59 -0300 Subject: [PATCH 5/7] fix the MXE fix for os_libc.h --- include/PR/os_libc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 13ec2124..4c2fc3e1 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -6,8 +6,8 @@ // Old deprecated functions from strings.h, replaced by memcpy/memset. #ifdef NO_BZERO #include -#define bzero(buf, size) memset(buf, 0, size) -#define bcopy(src, dst, size) memcpy(dst, src, size) +#define bzero(buf, size) memset((buf), 0, (size)) +#define bcopy(src, dst, size) memcpy((dst), (src), (size)) #else extern void bcopy(const void *, void *, size_t); extern void bzero(void *, size_t); From 0402ad463b84fe5049bd491c9a8ff951342755c7 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 19:18:50 -0300 Subject: [PATCH 6/7] fixed MXE once and for all thanks to @fgsfdsfgs, this is the final thing needed for MXE support --- include/PR/os_libc.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 4c2fc3e1..e7567516 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -3,14 +3,28 @@ #include "ultratypes.h" -// Old deprecated functions from strings.h, replaced by memcpy/memset. -#ifdef NO_BZERO +// old bstring functions that aren't present on some platforms + +#if defined(__APPLE__) + +// macOS libc has them +#include + +#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) + +// there's no way that shit's defined, use memcpy/memset #include -#define bzero(buf, size) memset((buf), 0, (size)) -#define bcopy(src, dst, size) memcpy((dst), (src), (size)) +#undef bzero +#undef bcopy +#define bzero(buf, len) memset((buf), 0, (len)) +#define bcopy(src, dst, len) memcpy((dst), (src), (len)) + #else + +// hope for the best extern void bcopy(const void *, void *, size_t); extern void bzero(void *, size_t); + #endif #endif /* !_OS_LIBC_H_ */ From 5c9e3c60a7b14ccc387ea1e7bcdb98585ba8446e Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 19:20:45 -0300 Subject: [PATCH 7/7] strip out now-needless NOBZERO flag --- Makefile | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Makefile b/Makefile index 5903e52f..a0dd34c5 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,6 @@ TARGET_N64 = 0 # Build and optimize for Raspberry Pi(s) TARGET_RPI ?= 0 -# No BZERO (for building under MXE) -NO_BZERO ?= 0 # Compiler to use (ido or gcc) COMPILER ?= ido @@ -450,12 +448,6 @@ SDLCONFIG := $(CROSS)sdl2-config ifeq ($(WINDOWS_BUILD),1) CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(SDLCONFIG) --cflags` - ifeq ($(CROSS),i686-w64-mingw32.static-) - ifeq ($(CROSS),x86_64-w64-mingw32.static-) - CC_CHECK += D_NOBZERO - CFLAGS += D_NOBZERO - endif - endif else ifeq ($(TARGET_WEB),1) CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2 @@ -469,12 +461,6 @@ endif # Check for enhancement options -# Check for no bzero option -ifeq ($(NO_BZERO),1) -CC_CHECK += -DNO_BZERO -CFLAGS += -DNO_BZERO -endif - # Check for Puppycam option ifeq ($(BETTERCAMERA),1) CC_CHECK += -DBETTERCAMERA