Cocktail Frank
4818439acb
Remove pre-processor rules for loading WASM, arcade, and demo configs in favor of using the upstream JSON search path functionality. Add rules for preloading build-specific WASM config from src/ into config/ so that the config is loaded automatically when the build launches. Remove separate compilation of arcade and demo builds in favor of rolling them into the regular Windows build since the config override path no longer needs to be compiled in. Remove unused WASM test.
795 lines
36 KiB
Makefile
795 lines
36 KiB
Makefile
# /*@~@~@ C A K E F O O T <presented by> 💫dank.game💫
|
|
# |~)~)~)
|
|
# |\~*~*| Licensed under the zlib and CC-BY licenses. Source is available for modding at
|
|
# |\\~*~|
|
|
# ,~|#\\~*|~, <https://open.shampoo.ooo/shampoo/cakefoot>
|
|
# : \\@\\~| :
|
|
# : \\#\\| : Created with open SPACE🪐BOX engine for cross-platform, PC, web and mobile games
|
|
# : \\@\' :
|
|
# : \\/ : <https://open.shampoo.ooo/shampoo/spacebox>
|
|
# `~ ~ ~`~ ~'
|
|
#
|
|
# This Makefile is used to create executables for Cakefoot. There are targets for Linux, Windows, macOS, and WebGL.
|
|
#
|
|
# NOTE: The Android rules do not work yet - they were copied in from a previous project.
|
|
#
|
|
# The SPACE🪐BOX library <https://open.shampoo.ooo/shampoo/spacebox> is required to be installed at the paths in the
|
|
# Paths section.
|
|
|
|
# Default flags
|
|
CFLAGS += -Wall -Wextra
|
|
CXXFLAGS += $(CFLAGS) --std=c++17
|
|
|
|
# Program name will appear in all final build target names
|
|
NAME = Cakefoot
|
|
|
|
# Print a success message
|
|
define success_message
|
|
@echo "\n✨ $@ succeeded"
|
|
endef
|
|
|
|
#########
|
|
# Paths #
|
|
#########
|
|
|
|
# Location of project specific source files
|
|
SRC_DIR := src
|
|
|
|
# Locations of [SPACEBOX] source and its packaged dependencies
|
|
SB_DIR := lib/sb
|
|
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 project 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
|
|
X64_TEST_BUILD_DIR := $(BUILD_ROOT)/x64_test
|
|
X64_TEST_DEBUG_BUILD_DIR := $(BUILD_ROOT)/x64_test_debug
|
|
WASM_BUILD_DIR := $(BUILD_ROOT)/wasm
|
|
WASM_DEBUG_BUILD_DIR := $(BUILD_ROOT)/wasm_debug
|
|
WASM_COOLMATH_BUILD_DIR := $(BUILD_ROOT)/wasm_coolmath
|
|
WASM_ITCH_BUILD_DIR := $(BUILD_ROOT)/wasm_itch
|
|
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_TEST_BUILD_DIR) $(X64_TEST_DEBUG_BUILD_DIR) $(X64_DEBUG_BUILD_DIR) \
|
|
$(WASM_BUILD_DIR) $(WASM_DEBUG_BUILD_DIR) $(WASM_COOLMATH_BUILD_DIR) $(WIN32_BUILD_DIR) $(WIN64_BUILD_DIR) \
|
|
$(UBUNTU_BUILD_DIR) $(MACOS_BUILD_DIR) $(WASM_ITCH_BUILD_DIR)
|
|
|
|
$(BUILD_DIRS):
|
|
mkdir -p $@
|
|
|
|
###################
|
|
# Auto-versioning #
|
|
###################
|
|
|
|
# Generate a header file which contains the version string as determined by Git. The file should be listed as a
|
|
# pre-requisite for any target which needs to access the version string. If the version string is identical to what is
|
|
# already written in the file, the file will not be overwritten. Therefore, the file modification date will not be
|
|
# updated, and the target will not need to be rebuilt.
|
|
#
|
|
# See https://stackoverflow.com/q/3236145 and https://stackoverflow.com/q/1704907
|
|
|
|
VERSION_CONTENTS = "// This file is auto-generated and will be overwritten when the project is built\n\#include <string>\
|
|
\n\nnamespace $(PROJECT) {\nconst std::string version = \"$(VERSION)\";\n}"
|
|
|
|
.PHONY : force
|
|
$(SRC_DIR)/version.hpp : PROJECT = cakefoot
|
|
$(SRC_DIR)/version.hpp : VERSION = "$(shell git describe --abbrev=4 --dirty --always --tags)"
|
|
$(SRC_DIR)/version.hpp : force
|
|
echo $(VERSION_CONTENTS) | cmp -s - $@ || echo $(VERSION_CONTENTS) > $@
|
|
|
|
$(SB_SRC_DIR)/version.hpp : PROJECT = sb
|
|
$(SB_SRC_DIR)/version.hpp : VERSION = "$(shell git --git-dir=$(SB_DIR)/.git describe --abbrev=4 --dirty --always --tags)"
|
|
$(SB_SRC_DIR)/version.hpp : force
|
|
echo $(VERSION_CONTENTS) | cmp -s - $@ || echo $(VERSION_CONTENTS) > $@
|
|
|
|
##################################################################
|
|
# 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 sb.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 $@
|
|
|
|
## Cakefoot ##
|
|
|
|
$(addsuffix /Curve.o, $(BUILD_DIRS)): $(addprefix $(SRC_DIR)/, Curve.cpp Curve.hpp) \
|
|
$(addprefix $(SB_SRC_DIR)/, Attributes.hpp math.hpp extension.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Character.o, $(BUILD_DIRS)): $(addprefix $(SRC_DIR)/, Character.cpp Character.hpp Curve.hpp) \
|
|
$(addprefix $(SB_SRC_DIR)/, Configuration.hpp Switch.hpp Selection.hpp Segment.hpp Timer.hpp Sprite.hpp) \
|
|
| $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Enemy.o, $(BUILD_DIRS)): $(addprefix $(SRC_DIR)/, Enemy.cpp Enemy.hpp Curve.hpp Character.hpp) \
|
|
$(addprefix $(SB_SRC_DIR)/, Timer.hpp Animation.hpp Box.hpp Sprite.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /Cakefoot.o, $(BUILD_DIRS)): $(SRC_DIR)/Cakefoot.cpp $(SRC_H_FILES) $(SB_H_FILES) $(SRC_DIR)/version.hpp \
|
|
| $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
$(addsuffix /main.o, $(BUILD_DIRS)): $(SRC_DIR)/main.cpp $(addprefix $(SB_SRC_DIR)/, Configuration.hpp sb.hpp) \
|
|
$(addprefix $(SRC_DIR)/, Cakefoot.hpp) | $(BUILD_DIRS)
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
## Cakefoot test suite ##
|
|
|
|
$(addsuffix /test.o, $(BUILD_DIRS)): $(SRC_DIR)/test/test.cpp $(addprefix $(SB_SRC_DIR)/, test/setup.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
|
|
EMSCRIPTEN_LFLAGS = -sMIN_WEBGL_VERSION=2 -sEXPORTED_FUNCTIONS="['_main', '_malloc', '_pause_for_ads', \
|
|
'_unpause_for_ads']" -sLLD_REPORT_UNDEFINED -sNO_DISABLE_EXCEPTION_CATCHING -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 -fexceptions
|
|
|
|
MACOS_CFLAGS = -Wall -Wextra -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 -D__MACOS__ \
|
|
-D__APPLE__ -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
|
|
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
|
|
|
|
# Windows flags are set separately per build in the Windows 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 $(SB_O_FILES) $(SRC_O_FILES)
|
|
LINUX_RESOURCES = resource/ src/shaders/ config/ src/config_steam_demo.json
|
|
X64_BUILD_LIB_DIR = lib/
|
|
|
|
# EXTRA_PLATFORM_FLAGS refers to extra preprocessor definitions, for example -D__UBUNTU18__, to trigger code blocks
|
|
# specific to that platform or architecture. These extra flags can be passed in when building using the Linux target on
|
|
# a specialized platform that needs different behavior in the code (for example, Ubuntu 18, which only supports the
|
|
# experimental C++ STL filesystem library).
|
|
#
|
|
# The Linux build takes an -rpath so that the distributable can be packaged with a "lib/" folder containing necessary
|
|
# libraries for running the project on another system (see Linux Distributable in the SPACE🪐BOX README).
|
|
|
|
$(NAME)-linux.x64 $(NAME)-linux_debug.x64 $(NAME)-linux_test.x64 $(NAME)-linux_test_debug.x64 : \
|
|
CFLAGS += $(LINUX_CFLAGS)
|
|
$(NAME)-linux.x64 $(NAME)-linux_test.x64 : CFLAGS += -O3 $(EXTRA_PLATFORM_FLAGS)
|
|
$(NAME)-linux_debug.x64 $(NAME)-linux_test_debug.x64 : CFLAGS += -g -O0 -D_GLIBCXX_DEBUG
|
|
$(NAME)-linux.x64 $(NAME)-linux_debug.x64 $(NAME)-linux_test.x64 $(NAME)-linux_test_debug.x64 : \
|
|
LFLAGS += $(LINUX_LFLAGS)
|
|
$(NAME)-linux.x64 : LFLAGS += -Wl,-rpath $(X64_BUILD_LIB_DIR)
|
|
|
|
# Distributable 64-bit Linux build
|
|
|
|
$(NAME)-linux.x64 : $(addprefix $(X64_BUILD_DIR)/, $(LINUX_OBJ))
|
|
$(CXX) $^ $(LFLAGS) -o $(X64_BUILD_DIR)/$@
|
|
|
|
# Pack into a ZIP
|
|
|
|
mkdir -p ${basename $@}/$(X64_BUILD_LIB_DIR)
|
|
cp $$(ldd $(X64_BUILD_DIR)/$@ | grep libSDL2-2.0 | cut -d" " -f3) \
|
|
$$(ldd $(X64_BUILD_DIR)/$@ | grep libSDL2_image | cut -d" " -f3) \
|
|
$$(ldd $(X64_BUILD_DIR)/$@ | grep libSDL2_ttf | cut -d" " -f3) \
|
|
$$(ldd $(X64_BUILD_DIR)/$@ | grep libsteam_api | cut -d" " -f3) \
|
|
$$(ldd $(X64_BUILD_DIR)/$@ | grep libSDL2_mixer | cut -d" " -f3) ${basename $@}/$(X64_BUILD_LIB_DIR)
|
|
rsync -arRL $(LINUX_RESOURCES) ${basename $@}
|
|
cp $(X64_BUILD_DIR)/$@ ${basename $@}
|
|
zip -r ${@:x64=zip} ${basename $@}
|
|
mv ${@:x64=zip} $(X64_BUILD_DIR)
|
|
mv ${basename $@} /tmp
|
|
rm -rf /tmp/${basename $@}
|
|
$(success_message)
|
|
|
|
# Linux debug-able build, for use with GDB
|
|
|
|
$(NAME)-linux_debug.x64 : $(addprefix $(X64_DEBUG_BUILD_DIR)/, $(LINUX_OBJ))
|
|
$(CXX) $^ $(LFLAGS) -o $(X64_DEBUG_BUILD_DIR)/$@
|
|
$(success_message)
|
|
|
|
# Linux test suite executable
|
|
|
|
$(NAME)-linux_test.x64 : BUILD_DIR = $(X64_TEST_BUILD_DIR)
|
|
$(NAME)-linux_test_debug.x64 : BUILD_DIR = $(X64_TEST_DEBUG_BUILD_DIR)
|
|
$(NAME)-linux_test.x64 : $(addprefix $(X64_TEST_BUILD_DIR)/, $(filter-out main.o, $(LINUX_OBJ))) \
|
|
$(addprefix $(X64_TEST_BUILD_DIR)/, test.o catch_amalgamated.o)
|
|
$(NAME)-linux_test_debug.x64 : $(addprefix $(X64_TEST_DEBUG_BUILD_DIR)/, $(filter-out main.o, $(LINUX_OBJ))) \
|
|
$(addprefix $(X64_TEST_DEBUG_BUILD_DIR)/, test.o catch_amalgamated.o)
|
|
$(NAME)-linux_test.x64 $(NAME)-linux_test_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. This image can be created using the Dockerfile at `ubuntu18/Dockerfile`.
|
|
#
|
|
# sudo docker build -t [DOCKER_IMAGE_TAG] ubuntu18/
|
|
#
|
|
# This will use the Ubuntu-18 image to create a new container.
|
|
#
|
|
# 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 in 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.
|
|
|
|
DOCKER_REMOTE_DIR=/cakefoot
|
|
DOCKER_IMAGE_TAG=cakefoot-ubuntu18
|
|
DOCKER_BUILD_TARGET=$(NAME)-linux.x64
|
|
DOCKER_NAME=spacebox-cakefoot
|
|
|
|
Ubuntu-18 : EXTRA_PLATFORM_FLAGS += -D__UBUNTU18__
|
|
Ubuntu-18 :
|
|
mkdir -p $(BUILD_ROOT)
|
|
sudo docker run --name $(DOCKER_NAME) --rm \
|
|
-v "$(shell pwd)/$(UBUNTU18_BUILD_DIR):$(DOCKER_REMOTE_DIR)/$(X64_BUILD_DIR)" \
|
|
-v "$(shell pwd)/.git:$(DOCKER_REMOTE_DIR)/.git" \
|
|
-v "$(shell pwd)/config:$(DOCKER_REMOTE_DIR)/config" \
|
|
-v "$(shell pwd)/.gitignore:$(DOCKER_REMOTE_DIR)/.gitignore" \
|
|
-v "$(shell pwd)/index.html:$(DOCKER_REMOTE_DIR)/index.html" \
|
|
-v "$(shell pwd)/LICENSE.txt:$(DOCKER_REMOTE_DIR)/LICENSE.txt" \
|
|
-v "$(shell pwd)/Press_Kit.md:$(DOCKER_REMOTE_DIR)/Press_Kit.md" \
|
|
-v "$(shell pwd)/README.md:$(DOCKER_REMOTE_DIR)/README.md" \
|
|
-v "$(shell pwd)/Makefile:$(DOCKER_REMOTE_DIR)/Makefile" \
|
|
-v "$(shell pwd)/robots.txt:$(DOCKER_REMOTE_DIR)/robots.txt" \
|
|
-v "$(shell pwd)/src:$(DOCKER_REMOTE_DIR)/src" \
|
|
-v "$(shell pwd)/lib:$(DOCKER_REMOTE_DIR)/lib" \
|
|
-v "$(shell pwd)/doc:$(DOCKER_REMOTE_DIR)/doc" \
|
|
-v "$(shell pwd)/www:$(DOCKER_REMOTE_DIR)/www" \
|
|
-v "$(shell pwd)/resource:$(DOCKER_REMOTE_DIR)/resource" $(DOCKER_IMAGE_TAG) sh -c \
|
|
"useradd $(USER) && chgrp $(USER) $(DOCKER_REMOTE_DIR) -R && chown $(USER) $(DOCKER_REMOTE_DIR) -R &&\
|
|
su - $(USER) && cd $(DOCKER_REMOTE_DIR) &&\
|
|
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)"
|
|
|
|
#############
|
|
# Web build #
|
|
#############
|
|
|
|
# Use Emscripten to create a WASM build for web browsers
|
|
EMSCRIPTENHOME = $(HOME)/ext/software/emsdk/upstream/emscripten
|
|
|
|
# Load into the data file for the WASM build
|
|
EMSCRIPTEN_PRELOADS = --preload-file "config/" --preload-file "resource/" --preload-file "src/shaders/" \
|
|
--preload-file "src/config_wasm.json@config/config_wasm.json"
|
|
|
|
# Trigger a rebuild when these files are edited
|
|
EMSCRIPTEN_CONFIG_TO_WATCH = config/config.json src/config_wasm.json resource/levels.json
|
|
|
|
# Emscripten compilers
|
|
$(NAME).js $(NAME)_debug.html $(NAME)_coolmath.js $(NAME)_itch.js : CC = $(EMSCRIPTENHOME)/emcc
|
|
$(NAME).js $(NAME)_debug.html $(NAME)_coolmath.js $(NAME)_itch.js : CXX = $(EMSCRIPTENHOME)/em++
|
|
|
|
# Extra compiler flags per Emscripten build
|
|
$(NAME).js $(NAME)_itch.js : CFLAGS += $(EMSCRIPTEN_CFLAGS)
|
|
$(NAME)_debug.html : CFLAGS += $(EMSCRIPTEN_CFLAGS) -g2
|
|
$(NAME)_coolmath.js : CFLAGS = $(EMSCRIPTEN_CFLAGS) -D__COOLMATH__
|
|
|
|
# All WASM builds take the same linker flags
|
|
$(NAME).js $(NAME)_debug.html $(NAME)_coolmath.js $(NAME)_itch.js : LFLAGS += $(EMSCRIPTEN_LFLAGS)
|
|
|
|
# Leave the pre-js out of the debug build
|
|
$(NAME).js $(NAME)_coolmath.js $(NAME)_itch.js : EMSCRIPTEN_PRELOADS += --pre-js "src/pre_js.js"
|
|
|
|
# Build the main WASM build
|
|
$(NAME).js : $(addprefix $(WASM_BUILD_DIR)/, SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) \
|
|
$(SRC_O_FILES)) $(EMSCRIPTEN_CONFIG_TO_WATCH)
|
|
$(CXX) $(filter-out $(EMSCRIPTEN_CONFIG_TO_WATCH), $^) $(LFLAGS) $(EMSCRIPTEN_PRELOADS) \
|
|
--pre-js "src/pre_js_collect.js" -o $(WASM_BUILD_DIR)/$@
|
|
$(success_message)
|
|
|
|
# Debug build
|
|
$(NAME)_debug.html : $(addprefix $(WASM_DEBUG_BUILD_DIR)/, SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) \
|
|
$(SRC_O_FILES)) $(EMSCRIPTEN_CONFIG_TO_WATCH)
|
|
$(CXX) $(filter-out $(EMSCRIPTEN_CONFIG_TO_WATCH), $^) $(LFLAGS) $(EMSCRIPTEN_PRELOADS) \
|
|
--memoryprofiler --cpuprofiler -o $(WASM_DEBUG_BUILD_DIR)/$@
|
|
$(success_message)
|
|
|
|
# Special builds for embeds at itch.io and Coolmath
|
|
$(NAME)_coolmath.js $(NAME)_itch.js : JS_SITE = $(patsubst $(NAME)_%.js,%,$@)
|
|
$(NAME)_coolmath.js $(NAME)_itch.js : EMSCRIPTEN_CONFIG_TO_WATCH += "src/config_$(JS_SITE).json"
|
|
$(NAME)_coolmath.js : EMSCRIPTEN_PRELOADS += --preload-file "src/config_coolmath.json@config/config_coolmath.json"
|
|
$(NAME)_itch.js : EMSCRIPTEN_PRELOADS += --preload-file "src/config_itch.json@config/config_itch.json"
|
|
$(NAME)_coolmath.js $(NAME)_itch.js : BUILD_DIR = $(BUILD_ROOT)/wasm_$(JS_SITE)
|
|
$(NAME)_coolmath.js : $(addprefix $(WASM_COOLMATH_BUILD_DIR)/, SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) \
|
|
$(SRC_O_FILES)) $(EMSCRIPTEN_CONFIG_TO_WATCH) src/index_coolmath.html src/embed_style.css
|
|
$(NAME)_itch.js : $(addprefix $(WASM_ITCH_BUILD_DIR)/, SDL2_rotozoom.o SDL2_gfxPrimitives.o $(SB_O_FILES) \
|
|
$(SRC_O_FILES)) $(EMSCRIPTEN_CONFIG_TO_WATCH) src/index_itch.html src/embed_style.css
|
|
$(NAME)_coolmath.js $(NAME)_itch.js :
|
|
$(CXX) $(filter-out $(EMSCRIPTEN_CONFIG_TO_WATCH) src/index_$(JS_SITE).html src/embed_style.css, $^) \
|
|
$(LFLAGS) $(EMSCRIPTEN_PRELOADS) -o $(BUILD_DIR)/$@
|
|
cp src/index_$(JS_SITE).html $(BUILD_DIR)/index.html
|
|
cp src/embed_style.css $(BUILD_DIR)
|
|
cd $(BUILD_DIR) && zip -r $(NAME)_$(JS_SITE).zip *.js *.wasm *.data *.html *.css && \
|
|
rm *.js *.wasm *.data *.html *.css && cd -
|
|
$(success_message)
|
|
|
|
###############
|
|
# MacOS build #
|
|
###############
|
|
|
|
# The first target builds a signed MacOS universal (x86_64 and arm64 in one) application bundle (.app) on Linux.
|
|
#
|
|
# The next target notarizes the app and converts the app into a disk image (.dmg). It requires an internet connection.
|
|
#
|
|
# The app is built using the osxcross toolchain (https://github.com/tpoechtrager/osxcross). See instructions at
|
|
# /README.md#MacOS for setting up osxcross.
|
|
#
|
|
# The program rcodesign (https://gregoryszorc.com/docs/apple-codesign/0.27.0/apple_codesign_getting_started.html) is
|
|
# required for signing the application bundle along with a certificate generated through Apple's developer tools portal.
|
|
|
|
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 $(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 = resource/ src/shaders/ config/ src/config_steam_demo.json
|
|
MACOS_APP_CONFIG = src/Info.plist
|
|
MACOS_CERTIFICATE = local/Cakefoot_MacOS_DeveloperID_Application.pem
|
|
MACOS_RCODESIGN = ~/ext/software/apple-codesign-0.27.0/rcodesign
|
|
MACOS_APP_LIBS = $(MACOS_CROSS_FW)/SDL2*.framework
|
|
|
|
# The entitlements file includes a special permission for the Steam API dylib
|
|
ifeq ($(STEAM),yes)
|
|
MACOS_RESOURCES += src/$(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).
|
|
ifeq ($(STEAM),yes)
|
|
rsync -a $(STEAM_LIB)/osx/libsteam_api.dylib $(MACOS_BUNDLE_CONTENTS)/MacOS/
|
|
endif
|
|
|
|
$(MACOS_RCODESIGN) sign --for-notarization --code-signature-flags runtime --pem-file $(MACOS_CERTIFICATE) \
|
|
--entitlements-xml-file $(MACOS_BUNDLE_CONTENTS)/Resources/src/$(NAME).entitlements $(MACOS_BUNDLE)
|
|
|
|
notarize :
|
|
$(MACOS_RCODESIGN) notary-submit --api-key-file local/Cakefoot_App_Store_Connect_API_key.json --staple \
|
|
$(MACOS_BUILD_DIR)/dmg/$(NAME).app
|
|
cd $(MACOS_BUILD_DIR) && genisoimage -V $(NAME) -D -R -apple -no-pad -hide-rr-moved -o $(NAME).dmg dmg && cd -
|
|
|
|
# Use this to transfer the app bundle to the emulator running at port 50922 on the localhost
|
|
#
|
|
# rsync -Wav -e 'ssh -p 50922' --progress build/macos/dmg/[NAME].app [USER]@localhost:/Users/[USER]/
|
|
|
|
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)"
|
|
|
|
#################
|
|
# Android build #
|
|
#################
|
|
|
|
# Detailed info on how this build target was originally created for the fill_screen demo is in README.md at the root of
|
|
# the repository. It requires the Android SDK and the source packages for SDL. The paths below should be edited to match
|
|
# the local system. Icon creation requires Imagemagick's convert tool from <https://imagemagick.org/>.
|
|
|
|
SDL_SRC := $(HOME)/ext/software/SDL2/SDL2-2.26.3
|
|
SDL_IMAGE_SRC := $(HOME)/ext/software/SDL2/SDL2_image-2.6.2-android
|
|
SDL_MIXER_SRC := $(HOME)/ext/software/SDL2/SDL2_mixer-2.6.2-android
|
|
SDL_TTF_SRC := $(HOME)/ext/software/SDL2/SDL2_ttf-2.20.1-android
|
|
SDL_ANDROID_PROJECT := $(SDL_SRC)/android-project
|
|
ANDROID_MK := app/jni/src/Android.mk
|
|
ANDROID_APP_MK := app/jni/Application.mk
|
|
ANDROID_MANIFEST := app/src/main/AndroidManifest.xml
|
|
ANDROID_SDK := $(HOME)/local/Android
|
|
ANDROID_PACKAGE := ooo.shampoo.foam
|
|
ANDROID_BUILD_DIR := build/android/$(ANDROID_PACKAGE)
|
|
ANDROID_CLASS := $(NAME)
|
|
ANDROID_CLASS_DIR := app/src/main/java/$(subst .,/,$(ANDROID_PACKAGE))
|
|
|
|
# The skeleton for the Android build is based on the SDL android-project. The libraries are symlinked in. If the script
|
|
# that rewrites the skeleton has changed, start with a fresh skeleton. Use the SPACEBOX revise skeleton script to edit
|
|
# the SDL android-project parameters.
|
|
$(ANDROID_BUILD_DIR): $(SDL_SRC)/android-project/ $(SB_SRC_DIR)/android/revise_skeleton.sh
|
|
-mkdir -p $(ANDROID_BUILD_DIR)
|
|
rsync -ar $(SDL_SRC)/android-project/ $(ANDROID_BUILD_DIR)
|
|
ln -nsf $(SDL_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL
|
|
ln -nsf $(SDL_IMAGE_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_image
|
|
ln -nsf $(SDL_MIXER_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_mixer
|
|
ln -nsf $(SDL_TTF_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_ttf
|
|
$(SB_SRC_DIR)/android/revise_skeleton.sh $(ANDROID_PACKAGE) $(ANDROID_BUILD_DIR) $(ANDROID_MANIFEST) \
|
|
$(ANDROID_APP_MK) $(ANDROID_MK) $(ANDROID_CLASS) $(ANDROID_APP_NAME) $(ANDROID_MIN_TARGET) $(ANDROID_NDK) \
|
|
"$(NAME)" "21" "24.0.8215888" $(SB_SRC_DIR) $(SB_LIB_DIR) $(SRC_DIR)
|
|
ln -nsf $(OPENCV_ANDROID_SDK)/sdk/native/libs $(ANDROID_BUILD_DIR)/app/jni/src/opencv
|
|
ln -nsf $(CURL_ANDROID)/jni/build/curl $(ANDROID_BUILD_DIR)/app/jni/src/curl
|
|
ln -nsf $(CURL_ANDROID)/jni/build/openssl $(ANDROID_BUILD_DIR)/app/jni/src/openssl
|
|
sed -i "s/^APP_CPPFLAGS.*/& -nostartfiles/" "$(ANDROID_BUILD_DIR)/$(ANDROID_APP_MK)"
|
|
sed -i "s/org.libsdl.app/$(ANDROID_PACKAGE)/" "$(ANDROID_BUILD_DIR)/app/build.gradle" \
|
|
"$(ANDROID_BUILD_DIR)/$(ANDROID_MANIFEST)"
|
|
|
|
# Extend the SDLActivity class
|
|
$(ANDROID_BUILD_DIR)/$(ANDROID_CLASS_DIR)/$(ANDROID_CLASS).java: $(SB_SRC_DIR)/android/main_class.sh
|
|
$(SB_SRC_DIR)/android/main_class.sh $(ANDROID_PACKAGE) $(ANDROID_CLASS) $(ANDROID_BUILD_DIR)/$(ANDROID_CLASS_DIR)
|
|
|
|
# Generate icon
|
|
$(ANDROID_BUILD_DIR)/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: $(SB_SRC_DIR)/android/generate_icon.sh \
|
|
$(SB_DIR)/icon
|
|
$(SB_SRC_DIR)/android/generate_icon.sh $(ANDROID_BUILD_DIR) "$(SB_DIR)/icon/foreground.png" \
|
|
"$(SB_DIR)/icon/background.png"
|
|
|
|
# Custom assets
|
|
$(ANDROID_BUILD_DIR)/app/src/main/assets: config*.json $(shell find resource/) $(shell find src/shaders)
|
|
-mkdir -p $(ANDROID_BUILD_DIR)/app/src/main/assets
|
|
rsync -ar --relative config*.json resource src/shaders $(ANDROID_BUILD_DIR)/app/src/main/assets
|
|
|
|
# Run gradle and generate an APK
|
|
$(ANDROID_BUILD_DIR)/app-debug.apk: $(ANDROID_BUILD_DIR) $(ANDROID_BUILD_DIR)/$(ANDROID_CLASS_DIR)/$(ANDROID_CLASS).java \
|
|
$(ANDROID_BUILD_DIR)/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml $(ANDROID_BUILD_DIR)/app/src/main/assets
|
|
ANDROID_SDK_ROOT=$(ANDROID_SDK) $(ANDROID_BUILD_DIR)/gradlew -p $(ANDROID_BUILD_DIR) build
|
|
ln -nsf app/build/outputs/apk/debug/app-debug.apk $(ANDROID_BUILD_DIR)
|
|
ln -nsf app/build/outputs/apk/debug/app-release-unsigned.apk $(ANDROID_BUILD_DIR)
|
|
|
|
###########
|
|
# 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_CONFIGS = config/ src/config_steam_demo.json
|
|
WIN_OBJ = glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.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. The demo and arcade distributions do not need the Steam API, but they include it
|
|
# anyway to avoid compiling two more executables.
|
|
|
|
ifeq ($(STEAM),yes)
|
|
$(NAME)-win32.exe $(NAME)-win64.exe : WIN_CFLAGS += -D__STEAM__ -I$(STEAM_INC)
|
|
$(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)-win64.exe : WIN_ARCH = x86_64
|
|
$(NAME)-win32.exe : WIN_ARCH = i686
|
|
$(NAME)-win64.exe : CC = $(WIN_ARCH)-w64-mingw32-gcc-posix
|
|
$(NAME)-win64.exe : CXX = $(WIN_ARCH)-w64-mingw32-g++-posix
|
|
$(NAME)-win32.exe : CC = $(WIN_ARCH)-w64-mingw32-gcc-posix
|
|
$(NAME)-win32.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)
|
|
$(NAME)-win64.exe : WIN_BUILD_DIR := $(WIN64_BUILD_DIR)
|
|
$(NAME)-win32.exe : WIN_BUILD_DIR := $(WIN32_BUILD_DIR)
|
|
|
|
# In the following rules, it doesn't seem possible to use WIN_BUILD_DIR in addprefix for all targets, not sure why
|
|
|
|
$(NAME)-win64.exe : $(addprefix $(WIN64_BUILD_DIR)/, $(WIN_OBJ)) $(WIN_CONFIGS)
|
|
$(NAME)-win32.exe : $(addprefix $(WIN32_BUILD_DIR)/, $(WIN_OBJ)) $(WIN_CONFIGS)
|
|
$(NAME)-win64.exe $(NAME)-win32.exe :
|
|
$(CXX) $(filter-out $(WIN_CONFIGS), $^) $(LFLAGS) -o $(WIN_BUILD_DIR)/$@
|
|
mkdir ${basename $@}
|
|
cp $(WIN_DLLS) ${basename $@}
|
|
rsync -arRL resource/ src/shaders/ $(WIN_CONFIGS) ${basename $@}
|
|
|
|
# Create a distributable ZIP
|
|
|
|
cp $(WIN_BUILD_DIR)/$@ ${basename $@}
|
|
zip -r ${@:exe=zip} ${basename $@}
|
|
mv ${@:exe=zip} $(WIN_BUILD_DIR)
|
|
|
|
# Create a distributable ZIP for arcade cabinets, pre-configured to be arcade-only. Remove the Steam demo config because
|
|
# it is not used.
|
|
|
|
cp src/config_arcade.json ${basename $@}/config/
|
|
rm ${basename $@}/src/config_steam_demo.json
|
|
zip -r ${@:.exe=-ARCADE.zip} ${basename $@}
|
|
mv ${@:.exe=-ARCADE.zip} $(WIN_BUILD_DIR)
|
|
rm ${basename $@}/config/config_arcade.json
|
|
|
|
# Create a distributable ZIP for event demos, pre-configured to reset automatically
|
|
|
|
cp src/config_event_demo.json ${basename $@}/config/
|
|
zip -r ${@:.exe=-EVENT_DEMO.zip} ${basename $@}
|
|
mv ${@:.exe=-EVENT_DEMO.zip} $(WIN_BUILD_DIR)
|
|
|
|
# Delete folder used to make ZIP
|
|
|
|
mv ${basename $@} /tmp
|
|
rm -rf /tmp/${basename $@}
|
|
$(success_message)
|
|
|
|
# Transfer the Windows builds to a Windows computer and unzip the builds automatically. This requires OpenSSH to be
|
|
# installed to Windows with a public key for connecting user.
|
|
|
|
WIN_PORT = 2222
|
|
WIN_HOST = localhost
|
|
WIN_USER = ohsqueezy
|
|
WIN_DEST = /Users/$(WIN_USER)/Desktop
|
|
|
|
win-transfer :
|
|
scp -P $(WIN_PORT) $(WIN64_BUILD_DIR)/*win64.zip $(WIN32_BUILD_DIR)/*win32.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"
|
|
|
|
#############
|
|
# Press kit #
|
|
#############
|
|
|
|
# Generate an HTML page from the Press Kit Markdown file. This requires the document conversion tool Pandoc
|
|
# <https://pandoc.org/>.
|
|
|
|
press :
|
|
pandoc -H "src/Press_kit_style.html" --metadata-file="src/Press_kit_metadata.yml" \
|
|
--template "src/Press_kit_template.html" -s -o press.html Press_Kit.md
|
|
|
|
########################
|
|
# Make multiple builds #
|
|
########################
|
|
|
|
# Release builds that can be built just using the local hard drive
|
|
|
|
local : $(NAME)-linux.x64 $(NAME).js $(NAME)_coolmath.js $(NAME)-win32.exe $(NAME)-win64.exe \
|
|
$(NAME)-win32-ARCADE_ONLY.exe $(NAME)-win32-DEMO.exe $(NAME)_itch.js
|
|
|
|
# Release builds that require SDKs on an external hard drive
|
|
|
|
external : $(NAME).app Ubuntu-18
|
|
|
|
# Builds meant for running unit tests
|
|
|
|
local-tests : $(NAME)-linux_test.x64
|
|
|
|
# Debug builds
|
|
|
|
debug : $(NAME)-linux_debug.x64 $(NAME)_debug.html
|
|
|
|
# Balls to the wall
|
|
|
|
all : local external local-tests debug
|
|
|
|
################################
|
|
# Clean up all generated files #
|
|
################################
|
|
|
|
# This removes all object files, executables, generated JavaScript files, copied resources, and anything else that
|
|
# was added to the build folder. To preserve a build, use the release script at `src/release.py` before running
|
|
# clean.
|
|
|
|
clean :
|
|
rm -rf build/
|
|
|
|
#############
|
|
# 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_debug.x64 -k
|