Add a space between --preload-file and the file path in the WASM build instructions. Increase the running time for the suppress input test to work with Emscripten and asyncify.
536 lines
22 KiB
Makefile
536 lines
22 KiB
Makefile
# /\ +=======================================================+
|
|
# ____/ \____ /: 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 :/
|
|
# +==============+
|
|
#
|
|
# These targets are for building the SPACE🪐BOX test program on each platform.
|
|
#
|
|
# The resulting program should be run from the current directory.
|
|
#
|
|
# $ build/x64/SPACEBOX_test-linux.x64
|
|
# <Catch2 output...>
|
|
|
|
# Default flags
|
|
CFLAGS += -Wall -Wextra
|
|
CXXFLAGS += $(CFLAGS) --std=c++17
|
|
|
|
# Program name will appear in all final build target names
|
|
NAME = SPACEBOX_test
|
|
|
|
# Print a success message
|
|
define success_message
|
|
@echo "\n✨ $@ succeeded"
|
|
endef
|
|
|
|
#########
|
|
# Paths #
|
|
#########
|
|
|
|
# Location of testing-specific source files
|
|
SRC_DIR := .
|
|
|
|
# Locations of [SPACEBOX] source and its packaged dependencies
|
|
SB_DIR := ../..
|
|
SB_SRC_DIR := $(SB_DIR)/src
|
|
SB_LIB_DIR := $(SB_DIR)/lib
|
|
SDLGFX2_DIR := $(SB_LIB_DIR)/sdl2-gfx
|
|
GLEW_DIR := $(SB_LIB_DIR)/glew
|
|
CATCH2_DIR := $(SB_LIB_DIR)/catch2
|
|
|
|
# C and C++ compiler commands
|
|
CC = clang
|
|
CXX = clang++
|
|
|
|
# Location of SDL config program. See README.md for how to compile the SDL library and this utility. Define SDL_BIN_DIR
|
|
# when invoking make to use an alternate SDL installation location.
|
|
SDLCONFIG := $(SDL_BIN_DIR)sdl2-config
|
|
|
|
# Override these to use Steamworks SDK from a custom location
|
|
STEAM_INC := "lib/steam/include/"
|
|
STEAM_LIB := "lib/steam/lib/"
|
|
|
|
#############################
|
|
# Based on above parameters #
|
|
#############################
|
|
|
|
# Use SDL's utility program to get compilation and linker flags
|
|
SDL_CFLAGS := $(shell $(SDLCONFIG) --cflags)
|
|
SDL_LFLAGS := $(shell $(SDLCONFIG) --libs)
|
|
|
|
# Get all SPACEBOX header files, and get a list of object targets by replacing the .cpp suffix with .o
|
|
SB_H_FILES := $(wildcard $(addprefix $(SB_SRC_DIR)/,*.hpp))
|
|
SB_O_FILES := $(notdir $(patsubst %.cpp, %.o, $(wildcard $(addprefix $(SB_SRC_DIR)/,*.cpp))))
|
|
|
|
# Get all testing-specific header and object files
|
|
SRC_H_FILES := $(wildcard $(addprefix $(SRC_DIR)/,*.hpp))
|
|
SRC_O_FILES := $(notdir $(patsubst %.cpp, %.o, $(wildcard $(addprefix $(SRC_DIR)/,*.cpp))))
|
|
|
|
##########################################################
|
|
# Build directories where object targets will be written #
|
|
##########################################################
|
|
|
|
BUILD_ROOT := build
|
|
X64_BUILD_DIR := $(BUILD_ROOT)/x64
|
|
X64_DEBUG_BUILD_DIR := $(BUILD_ROOT)/x64_debug
|
|
WASM_BUILD_DIR := $(BUILD_ROOT)/wasm
|
|
WIN32_BUILD_DIR := $(BUILD_ROOT)/win32
|
|
WIN64_BUILD_DIR := $(BUILD_ROOT)/win64
|
|
UBUNTU18_BUILD_DIR := $(BUILD_ROOT)/ubuntu18
|
|
MACOS_BUILD_DIR := $(BUILD_ROOT)/macos
|
|
BUILD_DIRS := $(X64_BUILD_DIR) $(X64_DEBUG_BUILD_DIR) $(WASM_BUILD_DIR) $(WIN32_BUILD_DIR) $(WIN64_BUILD_DIR) \
|
|
$(UBUNTU_BUILD_DIR) $(MACOS_BUILD_DIR)
|
|
|
|
$(BUILD_DIRS):
|
|
mkdir -p $@
|
|
|
|
##################################################################
|
|
# Object files for [SPACEBOX], its dependencies, and the project #
|
|
##################################################################
|
|
|
|
## SDL2-gfx ##
|
|
|
|
$(addsuffix /SDL2_framerate.o, $(BUILD_DIRS)): $(SDLGFX2_DIR)/SDL2_framerate.c $(wildcard $(SDLGFX2_DIR)/*.h) \
|
|
| $(BUILD_DIRS)
|
|
$(CC) $< $(CFLAGS) -c -o $@
|
|
|
|
$(addsuffix /SDL2_gfxPrimitives.o, $(BUILD_DIRS)): $(SDLGFX2_DIR)/SDL2_gfxPrimitives.c $(wildcard $(SDLGFX2_DIR)/*.h) \
|
|
| $(BUILD_DIRS)
|
|
$(CC) $< $(CFLAGS) -c -o $@
|
|
|
|
$(addsuffix /SDL2_imageFilter.o, $(BUILD_DIRS)): $(SDLGFX2_DIR)/SDL2_imageFilter.c $(wildcard $(SDLGFX2_DIR)/*.h) \
|
|
| $(BUILD_DIRS)
|
|
$(CC) $< $(CFLAGS) -c -o $@
|
|
|
|
$(addsuffix /SDL2_rotozoom.o, $(BUILD_DIRS)): $(SDLGFX2_DIR)/SDL2_rotozoom.c $(wildcard $(SDLGFX2_DIR)/*.h) \
|
|
| $(BUILD_DIRS)
|
|
$(CC) $< $(CFLAGS) -c -o $@
|
|
|
|
## GLEW ##
|
|
|
|
$(addsuffix /glew.o, $(BUILD_DIRS)): $(GLEW_DIR)/glew.c $(wildcard $(GLEW_DIR)/*.h) | $(BUILD_DIRS)
|
|
$(CC) $< $(CFLAGS) -c -o $@
|
|
|
|
## Catch2 ##
|
|
|
|
$(addsuffix /catch_amalgamated.o, $(BUILD_DIRS)): \
|
|
$(addprefix $(CATCH2_DIR)/, catch_amalgamated.cpp catch_amalgamated.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $< $(CXXFLAGS) -c -o $@
|
|
|
|
## SPACE🪐BOX ##
|
|
|
|
$(addsuffix /extension.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, extension.cpp extension.hpp Box.hpp Segment.hpp \
|
|
Color.hpp filesystem.hpp Pixels.hpp Log.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Node.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Node.cpp Node.hpp Game.hpp Configuration.hpp \
|
|
Delegate.hpp Display.hpp Input.hpp Box.hpp Audio.hpp Log.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Game.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Game.cpp Game.hpp extension.hpp Node.hpp Recorder.hpp \
|
|
Input.hpp Configuration.hpp Delegate.hpp Audio.hpp Log.hpp version.hpp progress.hpp) \
|
|
| $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Animation.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Animation.cpp Animation.hpp Node.hpp Timer.hpp) \
|
|
| $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Recorder.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Recorder.cpp Recorder.hpp Node.hpp Game.hpp \
|
|
Configuration.hpp Delegate.hpp Animation.hpp extension.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Input.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Input.cpp Input.hpp Node.hpp Animation.hpp \
|
|
Configuration.hpp Delegate.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Configuration.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Configuration.cpp Configuration.hpp \
|
|
Animation.hpp Log.hpp extension.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Delegate.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Delegate.cpp Delegate.hpp Node.hpp Game.hpp \
|
|
Input.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Display.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Display.cpp Display.hpp Node.hpp Game.hpp Box.hpp \
|
|
Configuration.hpp Delegate.hpp Log.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Box.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Box.cpp Box.hpp extension.hpp Segment.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Segment.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Segment.cpp Segment.hpp extension.hpp Box.hpp) \
|
|
| $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Pixels.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Pixels.cpp Pixels.hpp Box.hpp extension.hpp Log.hpp \
|
|
math.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Audio.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Audio.cpp Audio.hpp Node.hpp filesystem.hpp) \
|
|
| $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /GLObject.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, GLObject.cpp GLObject.hpp Log.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Texture.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Texture.cpp Texture.hpp GLObject.hpp filesystem.hpp \
|
|
Log.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /VBO.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, VBO.cpp VBO.hpp Log.hpp GLObject.hpp Attributes.hpp \
|
|
extension.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Attributes.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Attributes.cpp Attributes.hpp Log.hpp \
|
|
extension.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Model.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Model.cpp Model.hpp extension.hpp Attributes.hpp \
|
|
Texture.hpp Carousel.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Text.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Text.cpp Text.hpp Model.hpp Color.hpp Log.hpp \
|
|
Texture.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Color.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Color.cpp Color.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Log.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Log.cpp Log.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /math.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, math.cpp math.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Timer.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, Timer.cpp Timer.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /cloud.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, cloud.cpp cloud.hpp Log.hpp Configuration.hpp \
|
|
Animation.hpp Delegate.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /progress.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, progress.cpp progress.hpp sb.hpp filesystem.hpp \
|
|
Sprite.hpp Configuration.hpp extension.hpp cloud.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /sb.o, $(BUILD_DIRS)): $(addprefix $(SB_SRC_DIR)/, sb.cpp sb.hpp filesystem.hpp extension.hpp) \
|
|
| $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
## Test suite ##
|
|
|
|
$(addsuffix /test.o, $(BUILD_DIRS)): $(addprefix $(SRC_DIR)/, test.cpp setup.hpp) $(addprefix $(SB_SRC_DIR)/, sb.hpp \
|
|
Game.hpp Log.hpp progress.hpp extension.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $< $(CXXFLAGS) -c -o $@
|
|
|
|
#############################
|
|
# Compiler and linker flags #
|
|
#############################
|
|
|
|
LINUX_CFLAGS = -c -I$(SB_LIB_DIR) -I$(SB_SRC_DIR) $(SDL_CFLAGS) -DGLEW_STATIC -DGLEW_NO_GLU \
|
|
-DCATCH_AMALGAMATED_CUSTOM_MAIN
|
|
LINUX_LFLAGS = $(SDL_LFLAGS) -lpthread -lGL -lGLESv2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lstdc++fs -static-libstdc++ \
|
|
-static-libgcc
|
|
|
|
EMSCRIPTEN_CFLAGS = -Oz -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS="['png', 'jpg']" -sUSE_SDL_TTF=2 \
|
|
-sUSE_SDL_MIXER=2 -I $(SB_LIB_DIR) -I $(SB_SRC_DIR) -fexceptions -DCATCH_AMALGAMATED_CUSTOM_MAIN \
|
|
-D__ASYNCIFY__
|
|
EMSCRIPTEN_LFLAGS = -sMIN_WEBGL_VERSION=2 -sEXPORTED_FUNCTIONS="['_main']" -sLLD_REPORT_UNDEFINED \
|
|
-fexceptions -sFULL_ES3=1 -lidbfs.js -sALLOW_MEMORY_GROWTH=1 -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 \
|
|
-sSDL2_IMAGE_FORMATS="['png', 'jpg']" -sUSE_SDL_TTF=2 -sUSE_SDL_MIXER=2 --pre-js "pre_js.js" \
|
|
-sASYNCIFY -sASYNCIFY_STACK_SIZE=65536
|
|
|
|
MACOS_CFLAGS = -O3 -c -I$(SB_LIB_DIR) -I$(SB_SRC_DIR) -DGLEW_STATIC -DGLEW_NO_GLU -F$(MACOS_CROSS_FW) \
|
|
-I$(MACOS_CROSS_FW)/SDL2.framework/Headers -I$(MACOS_CROSS_FW)/SDL2_image.framework/Headers \
|
|
-I$(MACOS_CROSS_FW)/SDL2_ttf.framework/Headers -I$(MACOS_CROSS_FW)/SDL2_mixer.framework/Headers \
|
|
-DCATCH_AMALGAMATED_CUSTOM_MAIN
|
|
MACOS_LFLAGS = -Wl,-rpath,@executable_path/../Frameworks -pthread -F$(MACOS_CROSS_FW) -framework SDL2 \
|
|
-framework SDL2_image -framework SDL2_ttf -framework SDL2_mixer -framework OpenGL
|
|
|
|
WIN_CFLAGS = -O3 -c -I$(SB_LIB_DIR) -I$(SB_SRC_DIR) -DGLEW_STATIC -DGLEW_NO_GLU \
|
|
-I$(SDL_MINGW)/include/SDL2 -I$(SDL_IMG_MINGW)/include/SDL2 -I$(SDL_TTF_MINGW)/include/SDL2 \
|
|
-I$(SDL_MIXER_MINGW)/include/SDL2 -DCATCH_AMALGAMATED_CUSTOM_MAIN -DSDL_MAIN_HANDLED
|
|
WIN_LFLAGS = -lpthread -lstdc++fs -L$(SDL_MINGW)/lib -L$(SDL_IMG_MINGW)/lib -L$(SDL_TTF_MINGW)/lib \
|
|
-L$(SDL_MIXER_MINGW)/lib -lmingw32 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lSDL2main -lSDL2 -lopengl32 \
|
|
-static-libstdc++ -static-libgcc -mwindows
|
|
|
|
#######################
|
|
# Steam API Extension #
|
|
#######################
|
|
|
|
# Include Steamworks macro and headers if Steam is enabled. There are additional clauses defined per build target in
|
|
# later sections, such as extra files to include in the distributable.
|
|
|
|
ifeq ($(STEAM),yes)
|
|
LINUX_CFLAGS += -D__STEAM__ -I$(STEAM_INC)
|
|
LINUX_LFLAGS += -L$(STEAM_LIB)/linux64/ -Wl,-rpath,$(STEAM_LIB)/linux64/ -lsteam_api
|
|
|
|
WIN_CFLAGS += -D__STEAM__ -I$(STEAM_INC)
|
|
# WIN_LFLAGS are set separately for 32-bit and 64-bit in the Windows build section below
|
|
|
|
MACOS_CFLAGS += -D__STEAM__ -I$(STEAM_INC)
|
|
MACOS_LFLAGS += -L$(STEAM_LIB)/osx/ -lsteam_api
|
|
|
|
# For Ubuntu-18 build
|
|
DOCKER_STEAM = STEAM=yes
|
|
else
|
|
DOCKER_STEAM = STEAM=no
|
|
endif
|
|
|
|
###############
|
|
# Linux build #
|
|
###############
|
|
|
|
LINUX_OBJ = glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o catch_amalgamated.o $(SB_O_FILES) $(SRC_O_FILES)
|
|
|
|
$(NAME)-linux.x64 : CFLAGS += $(LINUX_CFLAGS) -O3 $(EXTRA_PLATFORM_FLAGS)
|
|
$(NAME)-linux_debug.x64 : CFLAGS += $(LINUX_CFLAGS) -g -O0
|
|
$(NAME)-linux.x64 : BUILD_DIR = $(X64_BUILD_DIR)
|
|
$(NAME)-linux_debug.x64 : BUILD_DIR = $(X64_DEBUG_BUILD_DIR)
|
|
$(NAME)-linux.x64 $(NAME)-linux_debug.x64 : LFLAGS += $(LINUX_LFLAGS)
|
|
$(NAME)-linux.x64 : $(addprefix $(X64_BUILD_DIR)/, $(LINUX_OBJ))
|
|
$(NAME)-linux_debug.x64 : $(addprefix $(X64_DEBUG_BUILD_DIR)/, $(LINUX_OBJ))
|
|
$(NAME)-linux.x64 $(NAME)-linux_debug.x64 :
|
|
$(CXX) $^ $(LFLAGS) -o $(BUILD_DIR)/$@
|
|
$(success_message)
|
|
|
|
# Launch a Docker container and build on Ubuntu 18.04.
|
|
#
|
|
# This Linux build target requires Docker to be installed locally, along with an Ubuntu-18 image with the SPACE🪐BOX
|
|
# prerequisites installed. It also requires that the user has `sudo` access to run docker. The image can be created
|
|
# using the Dockerfile at `ubuntu18/Dockerfile`.
|
|
#
|
|
# sudo docker build -t [DOCKER_IMAGE_TAG] ubuntu18/
|
|
#
|
|
# The project files are mapped onto the container to include all necessary files for the build. The local Ubuntu-18 build
|
|
# directory is mapped to sync automatically with the Linux/X64 build directory on the container.
|
|
#
|
|
# On the container, build the Linux/X64 version using clang-8. Set permissions so that the local user owns the output
|
|
# build files.
|
|
#
|
|
# Git files are necessary for building the version string.
|
|
#
|
|
# To just build the executable and sync it to the host machine, use the "Ubuntu-18" target. To also run the executable
|
|
# at the end of the build on the container and get standard output on the host, run the "Ubuntu-18-launch" target.
|
|
|
|
DOCKER_REMOTE_DIR=/spacebox-test
|
|
DOCKER_IMAGE_TAG=spacebox-ubuntu18
|
|
DOCKER_BUILD_TARGET=$(NAME)-linux.x64
|
|
DOCKER_NAME=spacebox-test
|
|
GIT_DIR=../../.git
|
|
|
|
Ubuntu-18 : DOCKER_RUN_TEST = no
|
|
Ubuntu-18-launch : DOCKER_RUN_TEST = yes
|
|
Ubuntu-18 Ubuntu-18-launch : EXTRA_PLATFORM_FLAGS += -D__UBUNTU18__
|
|
Ubuntu-18 Ubuntu-18-launch :
|
|
mkdir -p $(BUILD_ROOT)
|
|
sudo docker run --name $(DOCKER_NAME) --rm \
|
|
-v "$(shell pwd)/$(GIT_DIR):$(DOCKER_REMOTE_DIR)/.git" \
|
|
-v "$(shell pwd)/../../.gitignore:$(DOCKER_REMOTE_DIR)/.gitignore" \
|
|
-v "$(shell pwd)/../../lib:$(DOCKER_REMOTE_DIR)/lib" \
|
|
-v "$(shell pwd)/../../src:$(DOCKER_REMOTE_DIR)/src" \
|
|
-v "$(shell pwd)/../../config:$(DOCKER_REMOTE_DIR)/config" \
|
|
-v "$(shell pwd)/../../BPmono.ttf:$(DOCKER_REMOTE_DIR)/BPmono.ttf" \
|
|
-v "$(shell pwd)/$(UBUNTU18_BUILD_DIR):$(DOCKER_REMOTE_DIR)/src/test/$(X64_BUILD_DIR)" \
|
|
$(DOCKER_IMAGE_TAG) bash -c \
|
|
"useradd $(USER) && chgrp $(USER) $(DOCKER_REMOTE_DIR) -R && chown $(USER) $(DOCKER_REMOTE_DIR) -R &&\
|
|
su - $(USER) && cd $(DOCKER_REMOTE_DIR)/src/test/ &&\
|
|
git config --global --add safe.directory $(DOCKER_REMOTE_DIR) &&\
|
|
make CC=clang-8 CXX=clang++-8 $(DOCKER_STEAM) EXTRA_PLATFORM_FLAGS='$(EXTRA_PLATFORM_FLAGS)' -j7\
|
|
$(DOCKER_BUILD_TARGET) &&\
|
|
if [ '$(DOCKER_RUN_TEST)' == 'yes' ]; \
|
|
then 'build/x64/$(DOCKER_BUILD_TARGET)' '~Steam*' -s --no-default-reporters; fi;"
|
|
|
|
#############
|
|
# Web build #
|
|
#############
|
|
|
|
# Use Emscripten to output JavaScript.
|
|
#
|
|
# In the resources list, the '@' operator is used with BPmono.ttf because Emscripten reads BPmono.ttf as being in another
|
|
# directory because it is a symbolic link and tries to put it in another directory. The '@' operator instructs Emscripten
|
|
# to put BPmono.ttf in the root of the project.
|
|
|
|
EMSCRIPTENHOME = $(HOME)/ext/software/emsdk/upstream/emscripten
|
|
EMSCRIPTEN_OBJ = SDL2_rotozoom.o SDL2_gfxPrimitives.o catch_amalgamated.o $(SB_O_FILES) $(SRC_O_FILES)
|
|
EMSCRIPTEN_RESOURCES = malformed.json Simulacra_and_Simulation.json config.json config/ BPmono.ttf@BPmono.ttf
|
|
EMSCRIPTEN_DEPENDENCIES = $(filter-out BPmono.ttf@BPmono.ttf, $(EMSCRIPTEN_RESOURCES)) pre_js.js
|
|
EMSCRIPTEN_PRELOADS = $(addprefix --preload-file , $(EMSCRIPTEN_RESOURCES))
|
|
|
|
$(NAME).html : CC = $(EMSCRIPTENHOME)/emcc
|
|
$(NAME).html : CXX = $(EMSCRIPTENHOME)/em++
|
|
$(NAME).html : CFLAGS += $(EMSCRIPTEN_CFLAGS)
|
|
$(NAME).html : $(addprefix $(WASM_BUILD_DIR)/, $(EMSCRIPTEN_OBJ)) $(EMSCRIPTEN_DEPENDENCIES)
|
|
$(CXX) $(filter-out $(EMSCRIPTEN_DEPENDENCIES), $^) $(EMSCRIPTEN_LFLAGS) $(EMSCRIPTEN_PRELOADS) \
|
|
-o $(WASM_BUILD_DIR)/$@
|
|
$(success_message)
|
|
|
|
###############
|
|
# MacOS build #
|
|
###############
|
|
|
|
# This target builds a signed MacOS universal (x86_64 and arm64 in one) application bundle (.app).
|
|
#
|
|
# It uses the osxcross toolchain (https://github.com/tpoechtrager/osxcross). See instructions at /README.md#MacOS for
|
|
# setting up osxcross.
|
|
|
|
MACOS_CROSS_ROOT = /media/unionsine/osxcross
|
|
MACOS_CROSS_FW = $(MACOS_CROSS_ROOT)/local/Frameworks
|
|
MACOS_OBJ = $(addprefix $(MACOS_BUILD_DIR)/, glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o catch_amalgamated.o \
|
|
$(SB_O_FILES) $(SRC_O_FILES))
|
|
MACOS_BUNDLE = $(MACOS_BUILD_DIR)/dmg/$@
|
|
MACOS_BUNDLE_CONTENTS = $(MACOS_BUILD_DIR)/dmg/$@/Contents
|
|
MACOS_CROSS_BIN = $(MACOS_CROSS_ROOT)/target/bin
|
|
MACOS_RESOURCES = Simulacra_and_Simulation.json malformed.json icon.png config.json config/ BPmono.ttf
|
|
MACOS_APP_CONFIG = Info.plist
|
|
MACOS_APP_LIBS = $(MACOS_CROSS_FW)/SDL2*.framework
|
|
|
|
# The entitlements file includes a special permission for the Steam API dylib
|
|
ifeq ($(STEAM),yes)
|
|
MACOS_APP_CONFIG += $(NAME).entitlements
|
|
endif
|
|
|
|
$(NAME).app : CC = MACOSX_DEPLOYMENT_TARGET=11.3 PATH=$(PATH):$(MACOS_CROSS_BIN) o64-clang -arch arm64 -arch x86_64
|
|
$(NAME).app : CXX = MACOSX_DEPLOYMENT_TARGET=11.3 PATH=$(PATH):$(MACOS_CROSS_BIN) o64-clang++ -arch arm64 -arch x86_64
|
|
$(NAME).app : CFLAGS += $(MACOS_CFLAGS)
|
|
$(NAME).app : LFLAGS += $(MACOS_LFLAGS)
|
|
$(NAME).app : $(MACOS_OBJ)
|
|
mkdir -p $(MACOS_BUNDLE_CONTENTS)/MacOS $(MACOS_BUNDLE_CONTENTS)/Frameworks $(MACOS_BUNDLE_CONTENTS)/Resources
|
|
cp $(MACOS_APP_CONFIG) $(MACOS_BUNDLE_CONTENTS)
|
|
cp -r $(MACOS_APP_LIBS) $(MACOS_BUNDLE_CONTENTS)/Frameworks
|
|
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(MACOS_CROSS_ROOT)/target/lib $(CXX) -v $^ $(LFLAGS) \
|
|
-o $(MACOS_BUNDLE_CONTENTS)/MacOS/$(basename $@)
|
|
rsync -arRL $(MACOS_RESOURCES) $(MACOS_BUNDLE_CONTENTS)/Resources
|
|
$(success_message)
|
|
|
|
# The Steam API requires the dylib file to be in the MacOS directory (the same directory as the executable). The Steam
|
|
# app ID file is also included in the app bundle because this app is only used for testing.
|
|
ifeq ($(STEAM),yes)
|
|
rsync -a $(STEAM_LIB)/osx/libsteam_api.dylib $(MACOS_BUNDLE_CONTENTS)/MacOS/
|
|
-cp steam_appid.txt $(MACOS_BUNDLE_CONTENTS)/Resources/
|
|
endif
|
|
|
|
MACOS_EMU_PORT = 50922
|
|
MACOS_EMU_HOST = localhost
|
|
MACOS_EMU_USER = frank
|
|
|
|
macos-transfer :
|
|
rsync -Wav -e "ssh -p $(MACOS_EMU_PORT)" --progress $(MACOS_BUILD_DIR)/dmg/*.app \
|
|
"$(MACOS_EMU_USER)@$(MACOS_EMU_HOST):/Users/$(MACOS_EMU_USER)"
|
|
|
|
###########
|
|
# Windows #
|
|
###########
|
|
|
|
# Set the paths to the directories for the SDL MinGW libraries
|
|
|
|
SDL_MINGW_ROOT := $(HOME)/ext/software/SDL2/SDL2-mingw
|
|
SDL_MINGW = $(SDL_MINGW_ROOT)/SDL2-2.24.2/$(WIN_ARCH)-w64-mingw32
|
|
SDL_IMG_MINGW = $(SDL_MINGW_ROOT)/SDL2_image-2.5.2/$(WIN_ARCH)-w64-mingw32
|
|
SDL_TTF_MINGW = $(SDL_MINGW_ROOT)/SDL2_ttf-2.20.2/$(WIN_ARCH)-w64-mingw32
|
|
SDL_MIXER_MINGW = $(SDL_MINGW_ROOT)/SDL2_mixer-2.5.2/$(WIN_ARCH)-w64-mingw32
|
|
WIN_RESOURCES = malformed.json Simulacra_and_Simulation.json config.json config/ BPmono.ttf
|
|
WIN_OBJ = glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o catch_amalgamated.o $(SB_O_FILES) $(SRC_O_FILES)
|
|
WIN_DLLS = $(SDL_MINGW)/bin/*.dll $(SDL_IMG_MINGW)/bin/*.dll $(SDL_TTF_MINGW)/bin/*.dll $(SDL_MIXER_MINGW)/bin/*.dll \
|
|
/usr/$(WIN_ARCH)-w64-mingw32/lib/libwinpthread-1.dll
|
|
|
|
# If the Steam API is enabled, link to the Steam API library and include the DLL in the distributable, using separate
|
|
# files for 32-bit and 64-bit builds
|
|
|
|
ifeq ($(STEAM),yes)
|
|
$(NAME)-win32.exe : LFLAGS += -L$(STEAM_LIB)/ -lsteam_api
|
|
$(NAME)-win64.exe : LFLAGS += -L$(STEAM_LIB)/win64/ -lsteam_api64
|
|
$(NAME)-win32.exe : WIN_DLLS += $(STEAM_LIB)/steam_api.dll
|
|
$(NAME)-win64.exe : WIN_DLLS += $(STEAM_LIB)/win64/steam_api64.dll
|
|
endif
|
|
|
|
# Set the compiler to the MinGW compilers
|
|
|
|
$(NAME)-win32.exe: WIN_ARCH = i686
|
|
$(NAME)-win64.exe: WIN_ARCH = x86_64
|
|
$(NAME)-win32.exe: WIN_BUILD_DIR := $(WIN32_BUILD_DIR)
|
|
$(NAME)-win64.exe: WIN_BUILD_DIR := $(WIN64_BUILD_DIR)
|
|
$(NAME)-win32.exe $(NAME)-win64.exe: CC = $(WIN_ARCH)-w64-mingw32-gcc-posix
|
|
$(NAME)-win32.exe $(NAME)-win64.exe: CXX = $(WIN_ARCH)-w64-mingw32-g++-posix
|
|
$(NAME)-win32.exe $(NAME)-win64.exe: CFLAGS += $(WIN_CFLAGS)
|
|
$(NAME)-win32.exe $(NAME)-win64.exe: LFLAGS += $(WIN_LFLAGS)
|
|
|
|
# In the following rules, it doesn't seem possible to use WIN_BUILD_DIR for both, not sure why
|
|
|
|
$(NAME)-win32.exe: $(addprefix $(WIN32_BUILD_DIR)/, $(WIN_OBJ)) $(WIN_RESOURCES)
|
|
$(NAME)-win64.exe: $(addprefix $(WIN64_BUILD_DIR)/, $(WIN_OBJ)) $(WIN_RESOURCES)
|
|
$(NAME)-win32.exe $(NAME)-win64.exe:
|
|
$(CXX) $(filter-out $(WIN_RESOURCES), $^) $(LFLAGS) -o $(WIN_BUILD_DIR)/$@
|
|
mkdir ${basename $@}
|
|
cp $(WIN_DLLS) ${basename $@}
|
|
-cp steam_appid.txt ${basename $@}
|
|
rsync -arRL $(WIN_RESOURCES) ${basename $@}
|
|
cp $(WIN_BUILD_DIR)/$@ ${basename $@}
|
|
zip -r ${@:exe=zip} ${basename $@}
|
|
mv ${basename $@} /tmp
|
|
rm -rf /tmp/${basename $@}
|
|
mv ${@:exe=zip} $(WIN_BUILD_DIR)
|
|
$(success_message)
|
|
|
|
# Transfer Windows builds to a Windows PC and unzip them. The Windows PC must have OpenSSH server installed and running.
|
|
# This is intended for transferring the test program for automated testing. After this is run, the test could be
|
|
# triggered remotely.
|
|
|
|
WIN_PORT = 2222
|
|
WIN_HOST = localhost
|
|
WIN_USER = ohsqueezy
|
|
WIN_DEST = /Users/$(WIN_USER)/Desktop
|
|
|
|
win-transfer :
|
|
scp -P $(WIN_PORT) $(WIN64_BUILD_DIR)/*.zip $(WIN32_BUILD_DIR)/*.zip "$(WIN_USER)@$(WIN_HOST):$(WIN_DEST)"
|
|
ssh -p $(WIN_PORT) $(WIN_USER)@$(WIN_HOST) -x \
|
|
"cd $(WIN_DEST) && (for %I in (*.zip) do tar.exe -xf %I) && del *.zip"
|
|
|
|
########################
|
|
# Make multiple builds #
|
|
########################
|
|
|
|
# Builds that can be built just using the local hard drive
|
|
|
|
local : $(NAME)-linux.x64 $(NAME).html $(NAME)-win32.exe $(NAME)-win64.exe
|
|
|
|
# Builds that require SDKs on an external hard drive
|
|
|
|
external : $(NAME).app Ubuntu-18
|
|
|
|
# Debug builds
|
|
|
|
debug : $(NAME)-linux_debug.x64
|
|
|
|
# Balls to the wall
|
|
|
|
all : local debug external
|
|
|
|
################################
|
|
# Clean up all generated files #
|
|
################################
|
|
|
|
clean :
|
|
-rm -rf build/
|
|
-rm -f Test_Result*
|
|
-rm -f space_box*_log.txt
|
|
|
|
#############
|
|
# compiledb #
|
|
#############
|
|
|
|
# Generate a clang JSON compilation database file. This can be useful for example for code completion. It requires a
|
|
# compiledb binary (https://pypi.org/project/compiledb/). It should be generated manually every time a file is added,
|
|
# renamed, or the compilation flags change. The generated database is based on the Linux build.
|
|
|
|
PATH_TO_COMPILEDB = $(HOME)/ext/software/compiledb/bin/compiledb
|
|
compiledb: CC = clang-16
|
|
compiledb: CXX = clang++-16
|
|
compiledb :
|
|
-$(PATH_TO_COMPILEDB) -n make $(NAME)-linux.x64 -k
|