From 63c031ffc41a23f39e35a77b1d945b306e9b33d5 Mon Sep 17 00:00:00 2001 From: erysdren Date: Sun, 19 May 2024 11:34:48 -0500 Subject: [PATCH 1/6] Fix makefile for linux->win64_SDL target --- engine/Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/engine/Makefile b/engine/Makefile index 471810c90..f17592717 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -1143,9 +1143,8 @@ ifeq (win_SDL,$(findstring win,$(FTE_TARGET))$(findstring _SDL,$(FTE_TARGET))) EXEPOSTFIX=.exe - CC_MACHINE:=$(shell $(CC) -dumpmachine) - ARCH_PREDEP=$(BASE_DIR)/libs/SDL2-$(SDL2VER)/$(CC_MACHINE)/bin/sdl2-config - SDLCONFIG=$(ARCH_PREDEP) --prefix=$(BASE_DIR)/libs/SDL2-$(SDL2VER)/$(CC_MACHINE) + ARCH_PREDEP=$(BASE_DIR)/libs-$(ARCH)/SDL2-$(SDL2VER)/$(ARCH)/bin/sdl2-config + SDLCONFIG=$(ARCH_PREDEP) --prefix=$(BASE_DIR)/libs-$(ARCH)/SDL2-$(SDL2VER)/$(ARCH) ARCH_CFLAGS=`$(SDLCONFIG) --cflags` #the defaults for sdl come first @@ -2271,11 +2270,11 @@ droid-help: @-echo @-echo "Note that 'make droid-rel' will automatically generate a keystore. If you forget the password, just do a 'make dist-clean'." -$(BASE_DIR)/libs/SDL2-$(SDL2VER)/i686-w64-mingw32/bin/sdl2-config: +$(BASE_DIR)/libs-$(ARCH)/SDL2-$(SDL2VER)/i686-w64-mingw32/bin/sdl2-config: wget http://www.libsdl.org/release/SDL2-devel-$(SDL2VER)-mingw.tar.gz -O $(BASE_DIR)/sdl2.tar.gz - cd $(BASE_DIR)/libs && tar -xvzf $(BASE_DIR)/sdl2.tar.gz + cd $(BASE_DIR)/libs-$(ARCH) && tar -xvzf $(BASE_DIR)/sdl2.tar.gz rm $(BASE_DIR)/sdl2.tar.gz -$(BASE_DIR)/libs/SDL2-$(SDL2VER)/x86_64-w64-mingw32/bin/sdl2-config: $(BASE_DIR)/libs/SDL2-$(SDL2VER)/i686-w64-mingw32/bin/sdl2-config +$(BASE_DIR)/libs-$(ARCH)/SDL2-$(SDL2VER)/x86_64-w64-mingw32/bin/sdl2-config: $(BASE_DIR)/libs-$(ARCH)/SDL2-$(SDL2VER)/i686-w64-mingw32/bin/sdl2-config From 3ae20a264daf72433b51b8a253a4cd580f187604 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Wed, 12 Jun 2024 16:15:50 +0100 Subject: [PATCH 2/6] Build with SDL for Windows There are link errors to SDL's functions. Running make twice works, and the exectuable builds correctly. Don't ask me why it helps, I don't know. --- .github/workflows/build-all-and-release.yml | 6 +++--- tools/build-nzp-win32.sh | 5 ++++- tools/build-nzp-win64.sh | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-all-and-release.yml b/.github/workflows/build-all-and-release.yml index 3a32acb28..7c43ecdcd 100644 --- a/.github/workflows/build-all-and-release.yml +++ b/.github/workflows/build-all-and-release.yml @@ -80,7 +80,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: pc-nzp-win32.zip - path: ./engine/release/nzportable.exe + path: ./engine/release/nzportable-sdl.exe Compile-Windows64: runs-on: ubuntu-latest container: @@ -96,7 +96,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: pc-nzp-win64.zip - path: ./engine/release/nzportable64.exe + path: ./engine/release/nzportable-sdl64.exe Compile-WASM: runs-on: ubuntu-latest container: @@ -231,4 +231,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - id: ${{ steps.create_release.outputs.id }} \ No newline at end of file + id: ${{ steps.create_release.outputs.id }} diff --git a/tools/build-nzp-win32.sh b/tools/build-nzp-win32.sh index 3a74458aa..ef844cea6 100755 --- a/tools/build-nzp-win32.sh +++ b/tools/build-nzp-win32.sh @@ -1,2 +1,5 @@ cd ../engine -make makelibs FTE_TARGET=win32 && make m-rel FTE_TARGET=win32 FTE_CONFIG=nzportable -j32 \ No newline at end of file +make makelibs FTE_TARGET=win32_SDL2 && make m-rel FTE_TARGET=win32_SDL2 FTE_CONFIG=nzportable -j32 +# Running make once is not sufficient... there are link errors (undefined reference to SDL's functions). +# Doing it twice works. I don't know why. +make m-rel FTE_TARGET=win32_SDL2 FTE_CONFIG=nzportable -j32 diff --git a/tools/build-nzp-win64.sh b/tools/build-nzp-win64.sh index 9a4ff2105..d48bf9b2c 100755 --- a/tools/build-nzp-win64.sh +++ b/tools/build-nzp-win64.sh @@ -1,2 +1,5 @@ cd ../engine -make makelibs FTE_TARGET=win64 && make m-rel FTE_TARGET=win64 FTE_CONFIG=nzportable -j32 +make makelibs FTE_TARGET=win64_SDL2 && make m-rel FTE_TARGET=win64_SDL2 FTE_CONFIG=nzportable -j32 +# Running make once is not sufficient... there are link errors (undefined reference to SDL's functions). +# Doing it twice works. I don't know why. +make m-rel FTE_TARGET=win64_SDL2 FTE_CONFIG=nzportable -j32 From de86ecd8e362a43dd403f7bdfa189a254ad71cae Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Wed, 12 Jun 2024 22:55:02 +0100 Subject: [PATCH 3/6] Static link SDL for Windows --- engine/Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/engine/Makefile b/engine/Makefile index f17592717..d39412ff8 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -1151,19 +1151,19 @@ ifeq (win_SDL,$(findstring win,$(FTE_TARGET))$(findstring _SDL,$(FTE_TARGET))) GLCL_OBJS=$(GL_OBJS) $(D3DGL_OBJS) $(GLQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o $(LTO_END) resources.o $(LTO_START) GL_EXE_NAME=../$(EXE_NAME)-sdl-gl$(BITS)$(EXEPOSTFIX) GLCL_EXE_NAME=../$(EXE_NAME)-sdl-glcl$(BITS)$(EXEPOSTFIX) - ifdef windir +# ifdef windir GL_LDFLAGS=$(GLLDFLAGS) -lmingw32 -lws2_32 `$(SDLCONFIG) --static-libs` VK_LDFLAGS=$(GLLDFLAGS) -lmingw32 -lws2_32 `$(SDLCONFIG) --static-libs` M_LDFLAGS=$(MLDFLAGS) -lmingw32 -lws2_32 `$(SDLCONFIG) --static-libs` SV_LDFLAGS=-lm -lmingw32 -lws2_32 -lwinmm `$(SDLCONFIG) --static-libs` QCC_LDFLAGS= - else - GL_LDFLAGS=$(IMAGELDFLAGS) -lws2_32 -lmingw32 $(SDL_LDFLAGS) -mwindows -ldxguid -lwinmm -lole32 $(GLLDFLAGS) `$(SDLCONFIG) --libs` - VK_LDFLAGS=$(IMAGELDFLAGS) -lws2_32 -lmingw32 $(SDL_LDFLAGS) -mwindows -ldxguid -lwinmm -lole32 $(GLLDFLAGS) `$(SDLCONFIG) --libs` - M_LDFLAGS=$(IMAGELDFLAGS) -lws2_32 -lmingw32 $(SDL_LDFLAGS) -mwindows -ldxguid -lwinmm -lole32 $(MLDFLAGS) `$(SDLCONFIG) --libs` - SV_LDFLAGS=-lm -lmingw32 -lws2_32 -lwinmm `$(SDLCONFIG) --libs` - QCC_LDFLAGS= - endif +# else +# GL_LDFLAGS=$(IMAGELDFLAGS) -lws2_32 -lmingw32 $(SDL_LDFLAGS) -mwindows -ldxguid -lwinmm -lole32 $(GLLDFLAGS) `$(SDLCONFIG) --libs` +# VK_LDFLAGS=$(IMAGELDFLAGS) -lws2_32 -lmingw32 $(SDL_LDFLAGS) -mwindows -ldxguid -lwinmm -lole32 $(GLLDFLAGS) `$(SDLCONFIG) --libs` +# M_LDFLAGS=$(IMAGELDFLAGS) -lws2_32 -lmingw32 $(SDL_LDFLAGS) -mwindows -ldxguid -lwinmm -lole32 $(MLDFLAGS) `$(SDLCONFIG) --libs` +# SV_LDFLAGS=-lm -lmingw32 -lws2_32 -lwinmm `$(SDLCONFIG) --libs` +# QCC_LDFLAGS= +# endif GL_CFLAGS=-DFTE_SDL $(GLCFLAGS) $(CLIENTLIBFLAGS) $(DX7SDK) From 91638fdd305e502f4a69fc9199a022403ea68255 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Fri, 14 Jun 2024 03:31:13 +0100 Subject: [PATCH 4/6] Fix manually overriding CC For some reason, the the assignment to CC wasn't using ?= , so manually specifing a desired compiler (e.g. CC=aarch64-linux-gnu-gcc) didn't work correctly, and the system gcc would be invoked instead. --- engine/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/Makefile b/engine/Makefile index d39412ff8..41f579874 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -23,7 +23,7 @@ #note: cross compiling will typically require 'make makelibs FTE_TARGET=mytarget', which avoids installing lots of extra system packages. # -CC=gcc +CC?=gcc WINDRES=windres STRIP?=strip From 867f970259471b2ebb6d80ca59cb4e29f784e47e Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Thu, 13 Jun 2024 17:47:27 +0100 Subject: [PATCH 5/6] Cross-compile for Linux using SDL --- tools/build-nzp-linux32.sh | 4 +++- tools/build-nzp-linux64.sh | 4 +++- tools/build-nzp-linux_arm64.sh | 4 +++- tools/build-nzp-linux_armhf.sh | 4 +++- tools/build-nzp-macosx_x86.sh | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/build-nzp-linux32.sh b/tools/build-nzp-linux32.sh index c68d4a211..ef71bb900 100755 --- a/tools/build-nzp-linux32.sh +++ b/tools/build-nzp-linux32.sh @@ -1,2 +1,4 @@ cd ../engine -make makelibs FTE_TARGET=linux32 && make m-rel FTE_TARGET=linux32 FTE_CONFIG=nzportable -j32 \ No newline at end of file +export CC=i686-linux-gnu-gcc +export STRIP=i686-linux-gnu-strip +make makelibs FTE_TARGET=SDL2 && make m-rel FTE_TARGET=SDL2 FTE_CONFIG=nzportable -j32 diff --git a/tools/build-nzp-linux64.sh b/tools/build-nzp-linux64.sh index 8c959a3c5..c0ac3d205 100755 --- a/tools/build-nzp-linux64.sh +++ b/tools/build-nzp-linux64.sh @@ -1,2 +1,4 @@ cd ../engine -make makelibs FTE_TARGET=linux64 && make m-rel FTE_TARGET=linux64 FTE_CONFIG=nzportable -j32 +export CC=x86_64-linux-gnu-gcc +export STRIP=x86_64-linux-gnu-strip +make makelibs FTE_TARGET=SDL2 && make m-rel FTE_TARGET=SDL2 FTE_CONFIG_=nzportable -j32 diff --git a/tools/build-nzp-linux_arm64.sh b/tools/build-nzp-linux_arm64.sh index f826cb0f4..07af95216 100755 --- a/tools/build-nzp-linux_arm64.sh +++ b/tools/build-nzp-linux_arm64.sh @@ -1,2 +1,4 @@ cd ../engine -make makelibs FTE_TARGET=linux_arm64 && make m-rel FTE_TARGET=linux_arm64 FTE_CONFIG=nzportable -j32 \ No newline at end of file +export CC=aarch64-linux-gnu-gcc +export STRIP=aarch64-linux-gnu-strip +make makelibs FTE_TARGET=SDL2 && make m-rel FTE_TARGET=SDL2 FTE_CONFIG=nzportable -j32 diff --git a/tools/build-nzp-linux_armhf.sh b/tools/build-nzp-linux_armhf.sh index 2a6955a01..5bcecb89c 100755 --- a/tools/build-nzp-linux_armhf.sh +++ b/tools/build-nzp-linux_armhf.sh @@ -1,2 +1,4 @@ cd ../engine -make makelibs FTE_TARGET=linux_armhf && make m-rel FTE_TARGET=linux_armhf FTE_CONFIG=nzportable -j32 \ No newline at end of file +export CC=arm-linux-gnueabihf-gcc +export STRIP=arm-linux-gnueabihf-strip +make makelibs FTE_TARGET=SDL2 && make m-rel FTE_TARGET=SDL2 FTE_CONFIG=nzportable -j32 diff --git a/tools/build-nzp-macosx_x86.sh b/tools/build-nzp-macosx_x86.sh index e8e80ec50..2c8c113b5 100755 --- a/tools/build-nzp-macosx_x86.sh +++ b/tools/build-nzp-macosx_x86.sh @@ -1,4 +1,4 @@ export MACOSX_DEPLOYMENT_TARGET=10.14 osxcross-macports install libsdl2 libsdl cd ../engine -make makelibs FTE_TARGET=macosx_x86 && make m-rel FTE_TARGET=macosx_x86 FTE_CONFIG=nzportable -j8 \ No newline at end of file +make makelibs FTE_TARGET=macosx_x86 && make m-rel FTE_TARGET=macosx_x86 FTE_CONFIG=nzportable -j8 From 15f4495b63a35cb615f36de4efe6d3a3f16be819 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Fri, 14 Jun 2024 03:09:40 +0100 Subject: [PATCH 6/6] Give executables consistent names --- .github/workflows/build-all-and-release.yml | 8 ++++---- tools/build-nzp-linux32.sh | 1 + tools/build-nzp-linux64.sh | 3 ++- tools/build-nzp-linux_arm64.sh | 1 + tools/build-nzp-linux_armhf.sh | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-all-and-release.yml b/.github/workflows/build-all-and-release.yml index 7c43ecdcd..f666552d8 100644 --- a/.github/workflows/build-all-and-release.yml +++ b/.github/workflows/build-all-and-release.yml @@ -16,7 +16,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: pc-nzp-linux32.zip - path: ./engine/release/nzportable32 + path: ./engine/release/nzportable32-sdl Compile-Linux64: runs-on: ubuntu-latest container: @@ -32,7 +32,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: pc-nzp-linux64.zip - path: ./engine/release/nzportable64 + path: ./engine/release/nzportable64-sdl Compile-LinuxArm64: runs-on: ubuntu-latest container: @@ -48,7 +48,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: pc-nzp-linux_arm64.zip - path: ./engine/release/nzportablearm64 + path: ./engine/release/nzportablearm64-sdl Compile-LinuxArmhf: runs-on: ubuntu-latest container: @@ -64,7 +64,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: pc-nzp-linux_armhf.zip - path: ./engine/release/nzportablearmhf + path: ./engine/release/nzportablearmhf-sdl Compile-Windows32: runs-on: ubuntu-latest container: diff --git a/tools/build-nzp-linux32.sh b/tools/build-nzp-linux32.sh index ef71bb900..fe4f0a470 100755 --- a/tools/build-nzp-linux32.sh +++ b/tools/build-nzp-linux32.sh @@ -2,3 +2,4 @@ cd ../engine export CC=i686-linux-gnu-gcc export STRIP=i686-linux-gnu-strip make makelibs FTE_TARGET=SDL2 && make m-rel FTE_TARGET=SDL2 FTE_CONFIG=nzportable -j32 +mv release/nzportable-sdl2 release/nzportable32-sdl diff --git a/tools/build-nzp-linux64.sh b/tools/build-nzp-linux64.sh index c0ac3d205..d7eef7d78 100755 --- a/tools/build-nzp-linux64.sh +++ b/tools/build-nzp-linux64.sh @@ -1,4 +1,5 @@ cd ../engine export CC=x86_64-linux-gnu-gcc export STRIP=x86_64-linux-gnu-strip -make makelibs FTE_TARGET=SDL2 && make m-rel FTE_TARGET=SDL2 FTE_CONFIG_=nzportable -j32 +make makelibs FTE_TARGET=SDL2 && make m-rel FTE_TARGET=SDL2 FTE_CONFIG=nzportable -j32 +mv release/nzportable-sdl2 release/nzportable64-sdl diff --git a/tools/build-nzp-linux_arm64.sh b/tools/build-nzp-linux_arm64.sh index 07af95216..ee73b7641 100755 --- a/tools/build-nzp-linux_arm64.sh +++ b/tools/build-nzp-linux_arm64.sh @@ -2,3 +2,4 @@ cd ../engine export CC=aarch64-linux-gnu-gcc export STRIP=aarch64-linux-gnu-strip make makelibs FTE_TARGET=SDL2 && make m-rel FTE_TARGET=SDL2 FTE_CONFIG=nzportable -j32 +mv release/nzportable-sdl2 release/nzportablearm64-sdl diff --git a/tools/build-nzp-linux_armhf.sh b/tools/build-nzp-linux_armhf.sh index 5bcecb89c..08a0191e1 100755 --- a/tools/build-nzp-linux_armhf.sh +++ b/tools/build-nzp-linux_armhf.sh @@ -2,3 +2,4 @@ cd ../engine export CC=arm-linux-gnueabihf-gcc export STRIP=arm-linux-gnueabihf-strip make makelibs FTE_TARGET=SDL2 && make m-rel FTE_TARGET=SDL2 FTE_CONFIG=nzportable -j32 +mv release/nzportable-sdl2 release/nzportablearmhf-sdl