From 07aa2cd2341c487547a48aaf20f955e93e0378a8 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 12:21:16 -0300 Subject: [PATCH 1/9] Fix compilation for MXE on Linux and WSL Even though this isn't usually an option on the wiki, this will allow for cross-compilation of sm64pc through MXE on both Linux and WSL, making Wine testing much easier. --- Makefile | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 89452c95..71379025 100644 --- a/Makefile +++ b/Makefile @@ -428,9 +428,17 @@ else LD := $(CC) endif -CPP := $(CROSS)cpp -P +ifeq ($(WINDOWS_BUILD),1) # fixes compilation in MXE on Linux and WSL + CPP := cpp -P +else + CPP := $(CROSS)cpp -P +endif OBJDUMP := $(CROSS)objdump -OBJCOPY := $(CROSS)objcopy +ifeq ($(WINDOWS_BUILD),1) # fixes compilation in MXE on Linux and WSL + OBJCOPY := $(CROSS)objcopy +else + OBJCOPY := $(CROSS)objcopy +endif PYTHON := python3 SDLCONFIG := $(CROSS)sdl2-config @@ -473,9 +481,22 @@ LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base ht else ifeq ($(WINDOWS_BUILD),1) -LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static -ifeq ($(WINDOWS_CONSOLE),1) -LDFLAGS += -mconsole + ifeq ($(CROSS),i686-w64-mingw32.static-) + LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static + ifeq ($(WINDOWS_CONSOLE),1) + LDFLAGS += -mconsole + endif + else ifeq ($(CROSS),x86_64-w64-mingw32.static-) + LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static + ifeq ($(WINDOWS_CONSOLE),1) + LDFLAGS += -mconsole + endif + else + LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static + ifeq ($(WINDOWS_CONSOLE),1) + LDFLAGS += -mconsole + endif + endif endif else From 0f688c80d00492f31ee4e3dac7c9927cd1d54c34 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 12:26:06 -0300 Subject: [PATCH 2/9] removing a pesky endif --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 71379025..11aa77ca 100644 --- a/Makefile +++ b/Makefile @@ -495,7 +495,6 @@ ifeq ($(WINDOWS_BUILD),1) LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static ifeq ($(WINDOWS_CONSOLE),1) LDFLAGS += -mconsole - endif endif endif else From b4cb8a7f65f5fb7f6be5006000e6d7d94ae73439 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 12:30:25 -0300 Subject: [PATCH 3/9] remove needless ifeq --- Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 11aa77ca..4eae2ca8 100644 --- a/Makefile +++ b/Makefile @@ -434,11 +434,7 @@ else CPP := $(CROSS)cpp -P endif OBJDUMP := $(CROSS)objdump -ifeq ($(WINDOWS_BUILD),1) # fixes compilation in MXE on Linux and WSL - OBJCOPY := $(CROSS)objcopy -else - OBJCOPY := $(CROSS)objcopy -endif +OBJCOPY := $(CROSS)objcopy PYTHON := python3 SDLCONFIG := $(CROSS)sdl2-config From 17695a7b4f8bf6633e065f4a85e01c52deb0e235 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 12:56:58 -0300 Subject: [PATCH 4/9] fix objcopy on MXE builds --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4eae2ca8..41617d6c 100644 --- a/Makefile +++ b/Makefile @@ -434,7 +434,11 @@ else CPP := $(CROSS)cpp -P endif OBJDUMP := $(CROSS)objdump -OBJCOPY := $(CROSS)objcopy +ifeq ($(WINDOWS_BUILD),1) # fixes compilation in MXE on Linux and WSL + OBJCOPY := objcopy +else + OBJCOPY := $(CROSS)objcopy +endif PYTHON := python3 SDLCONFIG := $(CROSS)sdl2-config From 74058cf32f97abeead9f9cdfe62eb3e0c0d16e67 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 13:01:23 -0300 Subject: [PATCH 5/9] Simplify MXE fixes --- Makefile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 41617d6c..fe45680c 100644 --- a/Makefile +++ b/Makefile @@ -430,15 +430,12 @@ endif ifeq ($(WINDOWS_BUILD),1) # fixes compilation in MXE on Linux and WSL CPP := cpp -P -else - CPP := $(CROSS)cpp -P -endif -OBJDUMP := $(CROSS)objdump -ifeq ($(WINDOWS_BUILD),1) # fixes compilation in MXE on Linux and WSL OBJCOPY := objcopy else + CPP := $(CROSS)cpp -P OBJCOPY := $(CROSS)objcopy endif +OBJDUMP := $(CROSS)objdump PYTHON := python3 SDLCONFIG := $(CROSS)sdl2-config From 31c91c6968c900667335854aa3b01214a5f585c5 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 13:46:18 -0300 Subject: [PATCH 6/9] Nah dude, that's possible under WINDOWS_BUILD=1 --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index fe45680c..63fb19d5 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,6 @@ else endif # Automatic settings for PC port(s) -# WINDOWS_BUILD IS NOT FOR COMPILING A WINDOWS EXECUTABLE UNDER LINUX OR WSL! -# USE THE WIKI GUIDE WITH MSYS2 FOR COMPILING A WINDOWS EXECUTABLE! NON_MATCHING := 1 GRUCODE := f3dex2e From 0a6ea9e9d42bdcf5f25619984b385a3ef11b4a81 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 14:35:56 -0300 Subject: [PATCH 7/9] Clean up the makefile fixes a bit --- Makefile | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 63fb19d5..7ef38cdd 100644 --- a/Makefile +++ b/Makefile @@ -477,18 +477,13 @@ else ifeq ($(WINDOWS_BUILD),1) ifeq ($(CROSS),i686-w64-mingw32.static-) - LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static - ifeq ($(WINDOWS_CONSOLE),1) - LDFLAGS += -mconsole - endif + LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static else ifeq ($(CROSS),x86_64-w64-mingw32.static-) - LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static - ifeq ($(WINDOWS_CONSOLE),1) - LDFLAGS += -mconsole - endif + LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static else - LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static - ifeq ($(WINDOWS_CONSOLE),1) + LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static + endif + ifeq ($(WINDOWS_CONSOLE),1) LDFLAGS += -mconsole endif endif From 50af1393c3b0af1d00fe7a8c1d4098b2f202ea22 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 14:38:47 -0300 Subject: [PATCH 8/9] Further clean up the makefile fixes --- Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7ef38cdd..4cc4db1e 100644 --- a/Makefile +++ b/Makefile @@ -476,12 +476,11 @@ LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base ht else ifeq ($(WINDOWS_BUILD),1) - ifeq ($(CROSS),i686-w64-mingw32.static-) - LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static - else ifeq ($(CROSS),x86_64-w64-mingw32.static-) - LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static - else - LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static + LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static + ifneq ($(CROSS),i686-w64-mingw32.static-) + ifneq ($(CROSS),x86_64-w64-mingw32.static-) + LDFLAGS += -no-pie + endif endif ifeq ($(WINDOWS_CONSOLE),1) LDFLAGS += -mconsole From 3c6bf53dea58c9e38fe285291b3e5d07ce82951c Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 16 May 2020 14:59:27 -0300 Subject: [PATCH 9/9] even further cleanup of the makefile --- Makefile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 4cc4db1e..b285ddba 100644 --- a/Makefile +++ b/Makefile @@ -473,9 +473,7 @@ ASFLAGS := -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) ifeq ($(TARGET_WEB),1) LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base http://localhost:8080/ -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']" -else - -ifeq ($(WINDOWS_BUILD),1) +else ifeq ($(WINDOWS_BUILD),1) LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static ifneq ($(CROSS),i686-w64-mingw32.static-) ifneq ($(CROSS),x86_64-w64-mingw32.static-) @@ -485,17 +483,12 @@ ifeq ($(WINDOWS_BUILD),1) ifeq ($(WINDOWS_CONSOLE),1) LDFLAGS += -mconsole endif -endif -else - +else ifeq ($(TARGET_RPI),1) # Linux / Other builds below -ifeq ($(TARGET_RPI),1) LDFLAGS := $(OPT_FLAGS) -lm -lGLESv2 `$(SDLCONFIG) --libs` -no-pie else LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -lm -lGL `$(SDLCONFIG) --libs` -no-pie -lpthread endif -endif -endif #Added for Pi ifeq # Prevent a crash with -sopt