From b40e0e56e4af4db8caf73b7e2b8d5e9aea119dda Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 18 Apr 2024 00:10:57 -0400 Subject: [PATCH] add Ubuntu 18.04 docker build target --- Makefile | 37 +++++++++++++++++++++++++++++-------- lib/sb | 2 +- src/Ubuntu18.Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 src/Ubuntu18.Dockerfile diff --git a/Makefile b/Makefile index ae6f6a2..29612ae 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,18 @@ -# Cakefoot [https://cakefoot.dank.game] +# /\ +-------------------------------------------------------+ +# ____/ \____ /| Open source game framework licensed to freely use, | +# \ / / | copy, and modify. Created for [dank.game] | +# +--\ ^__^ /--+ | | +# | ~/ \~ | | Download at https://open.shampoo.ooo/shampoo/spacebox | +# | ~~~~~~~~~~~~ | +-------------------------------------------------------+ +# | SPACE ~~~~~ | / +# | ~~~~~~~ BOX |/ +# +--------------+ # -# This Makefile can be used to create a Linux or web build. +# This Makefile is used to create executables for Cakefoot. There are targets for Linux, Windows, and WebGL. # # NOTE: The Android rules are currently outdated. # -# The SPACE🪐BOX game framework source code from is required. +# The SPACE🪐BOX source code is required. ######### # Paths # @@ -57,8 +65,9 @@ WINDOWS_BUILD_DIR := $(BUILD_ROOT)/win32 ARCADE_BUILD_DIR := $(BUILD_ROOT)/win32_arcade DEMO_BUILD_DIR := $(BUILD_ROOT)/win32_demo WIN64_BUILD_DIR := $(BUILD_ROOT)/win64 +UBUNTU18_BUILD_DIR := $(BUILD_ROOT)/ubuntu18 BUILD_DIRS := $(X64_BUILD_DIR) $(X64_DEBUG_BUILD_DIR) $(WASM_BUILD_DIR) $(WASM_DEBUG_BUILD_DIR) $(WASM_COOLMATH_BUILD_DIR) \ - $(WINDOWS_BUILD_DIR) $(ARCADE_BUILD_DIR) $(DEMO_BUILD_DIR) $(WIN64_BUILD_DIR) + $(WINDOWS_BUILD_DIR) $(ARCADE_BUILD_DIR) $(DEMO_BUILD_DIR) $(WIN64_BUILD_DIR) $(UBUNTU_BUILD_DIR) $(BUILD_DIRS): mkdir -p $@ @@ -187,18 +196,19 @@ $(addsuffix /Cakefoot.o, $(BUILD_DIRS)): $(SRC_DIR)/Cakefoot.cpp $(SRC_H_FILES) LINUX_CFLAGS = -c -I$(SB_LIB_DIR) -I$(SB_SRC_DIR) $(SDL_CFLAGS) -DGLEW_STATIC LINUX_CXXFLAGS = $(CFLAGS) --std=c++17 -# LINUX_LFLAGS = $(SDL_LFLAGS) -Wl/,--enable-new-dtags -lpthread -lGL -lGLESv2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lstdc++fs -# LINUX_LFLAGS = $(SDL_LFLAGS) -lpthread -lGL -lGLESv2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lstdc++fs LINUX_LFLAGS = $(SDL_LFLAGS) -lpthread -lGL -lGLESv2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lstdc++fs -static-libstdc++ -static-libgcc LINUX_OBJ = $(addprefix $(X64_BUILD_DIR)/, glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) LINUX_DEBUG_OBJ = $(addprefix $(X64_DEBUG_BUILD_DIR)/, glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) $(SRC_O_FILES)) X64_BUILD_LIB_DIR = lib/ -Cakefoot-linux.x64 : CFLAGS = $(LINUX_CFLAGS) -O3 +# EXTRA_PLATFORM_FLAGS refers to extra preprocessor definitions, for example -D__UBUNTU18__, to trigger code blocks specific to that +# platform or architecture + +Cakefoot-linux.x64 : CFLAGS = $(LINUX_CFLAGS) -O3 $(EXTRA_PLATFORM_FLAGS) Cakefoot-linux.x64 : CXXFLAGS = $(LINUX_CXXFLAGS) Cakefoot-linux.x64 : LFLAGS = $(LINUX_LFLAGS) -Wl,-rpath $(X64_BUILD_LIB_DIR) Cakefoot-linux.x64 : $(LINUX_OBJ) - $(CXX) $^ $(LFLAGS) -D__LINUX__ -o $(X64_BUILD_DIR)/$@ + $(CXX) $^ $(LFLAGS) -o $(X64_BUILD_DIR)/$@ # Build a distributable archive @@ -220,6 +230,17 @@ Cakefoot-linux_debug.x64 : LFLAGS = $(LINUX_LFLAGS) -fsanitize=undefined Cakefoot-linux_debug.x64 : $(LINUX_DEBUG_OBJ) $(CXX) $^ $(LFLAGS) -D__LINUX__ -o $(X64_DEBUG_BUILD_DIR)/$@ +# Launch a docker container to build the game on Ubuntu 18.04 for compatibility with older Linux distributions. This requires +# Docker to be installed on the host system with the image cakefoot-ubuntu18. Use `src/Ubuntu18.Dockerfile` to build the image +# before attempting this build if the image was not built yet. +# +# sudo docker build src/Ubuntu18.Dockerfile + +Ubuntu-18 : + sudo docker run --rm -v "$(shell pwd)/$(UBUNTU18_BUILD_DIR):/cakefoot/$(X64_BUILD_DIR)" cakefoot-ubuntu18 sh -c \ + "cd cakefoot && git submodule foreach --recursive git pull origin main && git pull origin main &&\ + make CC=clang-8 CXX=clang++-8 EXTRA_PLATFORM_FLAGS='-D__UBUNTU18__' -j7 Cakefoot-linux.x64" + ############# # Web build # ############# diff --git a/lib/sb b/lib/sb index 6fdfa67..a1eef80 160000 --- a/lib/sb +++ b/lib/sb @@ -1 +1 @@ -Subproject commit 6fdfa67c4181b023925b6a1e86950b6fb1378959 +Subproject commit a1eef8017eb3c75a30b00863e1d54f906eefc0df diff --git a/src/Ubuntu18.Dockerfile b/src/Ubuntu18.Dockerfile new file mode 100644 index 0000000..69aa586 --- /dev/null +++ b/src/Ubuntu18.Dockerfile @@ -0,0 +1,36 @@ +# /\ +-------------------------------------------------------+ +# ____/ \____ /| Open source game framework licensed to freely use, | +# \ / / | copy, and modify. Created for [dank.game] | +# +--\ ^__^ /--+ | | +# | ~/ \~ | | Download at https://open.shampoo.ooo/shampoo/spacebox | +# | ~~~~~~~~~~~~ | +-------------------------------------------------------+ +# | SPACE ~~~~~ | / +# | ~~~~~~~ BOX |/ +# +--------------+ +# +# Docker instructions for building an Ubuntu 18.04 container with everything necessary for compiling Cakefoot. +# +# Build with the tag "cakefoot-ubuntu18" for compatbility with the Makefile. +# +# sudo docker build -t cakefoot-ubuntu18 src/Ubuntu18.Dockerfile + +FROM ubuntu:18.04 + +RUN sed -i '/deb-src/s/^# //' /etc/apt/sources.list && \ + apt update && \ + apt upgrade -y && \ + apt install -y wget build-essential clang-8 git rsync && \ + apt build-dep -y libsdl2 && \ + apt clean -y && apt autoclean -y && \ + rm -rf /var/lib/apt/lists/* && \ + wget https://github.com/libsdl-org/SDL/releases/download/release-2.24.2/SDL2-2.24.2.tar.gz && \ + wget https://github.com/libsdl-org/SDL_image/releases/download/release-2.6.2/SDL2_image-2.6.2.tar.gz && \ + wget https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.20.1/SDL2_ttf-2.20.1.tar.gz && \ + wget https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.6.2/SDL2_mixer-2.6.2.tar.gz && \ + tar -xf SDL2-2.24.2.tar.gz && cd SDL2-2.24.2/ && ./configure && make && make install && cd .. && \ + tar -xf SDL2_image-2.6.2.tar.gz && cd SDL2_image-2.6.2/ && ./configure && make && make install && cd .. && \ + tar -xf SDL2_ttf-2.20.1.tar.gz && cd SDL2_ttf-2.20.1/ && ./configure && make && make install && cd .. && \ + tar -xf SDL2_mixer-2.6.2.tar.gz && cd SDL2_mixer-2.6.2/ && ./configure && make && make install && cd .. && \ + ldconfig && \ + rm -rf SDL2* && \ + git clone --recursive https://open.shampoo.ooo/shampoo/cakefoot