2024-03-29 12:38:14 -05:00
|
|
|
MAKEFLAGS = --jobs=8
|
2022-02-03 09:16:22 -06:00
|
|
|
UNAME != uname
|
2023-09-19 12:35:12 -05:00
|
|
|
MAKEDIR != pwd
|
2022-12-12 01:35:42 -06:00
|
|
|
# Options
|
2024-03-19 14:39:19 -05:00
|
|
|
# NDEBUG --- build with debugging symbols and logging
|
2023-09-03 12:50:02 -05:00
|
|
|
|
2024-04-17 06:32:25 -05:00
|
|
|
ifeq ($(ARCH),)
|
2024-05-16 14:50:18 -05:00
|
|
|
ARCH != uname -m
|
2024-04-17 06:32:25 -05:00
|
|
|
endif
|
|
|
|
|
2023-11-20 15:57:23 -06:00
|
|
|
CXX:=$(CC)
|
|
|
|
|
2023-09-04 09:48:44 -05:00
|
|
|
OPT ?= 0
|
2023-09-04 21:35:05 -05:00
|
|
|
LD = $(CC)
|
2023-09-03 12:50:02 -05:00
|
|
|
|
2024-03-26 18:31:20 -05:00
|
|
|
STEAM = steam/sdk
|
2024-04-15 07:58:23 -05:00
|
|
|
STEAMAPI =
|
2024-03-26 18:31:20 -05:00
|
|
|
|
2024-04-18 17:34:56 -05:00
|
|
|
ifeq ($(CROSS)$(CC), emcc)
|
2024-05-16 14:50:18 -05:00
|
|
|
LDFLAGS += --shell-file shell.html --closure 1
|
|
|
|
CPPFLAGS += -Wbad-function-cast -Wcast-function-type -sSTACK_SIZE=1MB -sALLOW_MEMORY_GROWTH -sINITIAL_MEMORY=128MB
|
|
|
|
NDEBUG = 1
|
|
|
|
ARCH:= wasm
|
|
|
|
OPT=small
|
2024-03-27 15:00:59 -05:00
|
|
|
endif
|
2024-03-26 18:31:20 -05:00
|
|
|
|
2023-09-12 23:32:14 -05:00
|
|
|
ifdef NEDITOR
|
2023-11-21 01:07:50 -06:00
|
|
|
CPPFLAGS += -DNO_EDITOR
|
2023-09-12 23:32:14 -05:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef NFLAC
|
2023-11-21 01:07:50 -06:00
|
|
|
CPPFLAGS += -DNFLAC
|
2023-09-12 23:32:14 -05:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef NMP3
|
2023-11-21 01:07:50 -06:00
|
|
|
CPPFLAGS += -DNMP3
|
2023-09-12 23:32:14 -05:00
|
|
|
endif
|
|
|
|
|
2023-11-20 15:57:23 -06:00
|
|
|
ifdef NSVG
|
2023-11-21 01:07:50 -06:00
|
|
|
CPPFLAGS += -DNSVG
|
2023-11-20 15:57:23 -06:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef NQOA
|
2023-11-21 01:07:50 -06:00
|
|
|
CPPFLAGS += -DNQOA
|
2023-11-20 15:57:23 -06:00
|
|
|
endif
|
|
|
|
|
2024-03-14 16:48:05 -05:00
|
|
|
ifdef NDEBUG
|
2023-11-21 01:07:50 -06:00
|
|
|
CPPFLAGS += -DNDEBUG
|
2024-03-14 16:48:05 -05:00
|
|
|
else
|
2024-03-23 09:56:38 -05:00
|
|
|
CPPFLAGS += -g -DDUMP
|
|
|
|
INFO :=$(INFO)_dbg
|
2022-12-12 01:35:42 -06:00
|
|
|
endif
|
2022-11-24 10:58:36 -06:00
|
|
|
|
2024-03-14 16:48:05 -05:00
|
|
|
ifdef LEAK
|
2024-03-23 09:56:38 -05:00
|
|
|
CPPFLAGS += -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -DLEAK
|
2024-04-16 07:48:34 -05:00
|
|
|
INFO := $(INFO)_leak
|
2024-03-14 16:48:05 -05:00
|
|
|
endif
|
2024-02-23 16:05:30 -06:00
|
|
|
|
2023-09-04 16:27:30 -05:00
|
|
|
ifeq ($(OPT),small)
|
2024-04-18 17:34:56 -05:00
|
|
|
CPPFLAGS += -Os -flto -fno-ident -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections
|
2024-03-23 09:56:38 -05:00
|
|
|
|
2023-09-04 21:35:05 -05:00
|
|
|
LDFLAGS += -flto
|
2023-09-05 09:38:52 -05:00
|
|
|
|
2024-03-23 09:56:38 -05:00
|
|
|
INFO :=$(INFO)_small
|
|
|
|
else ifeq ($(OPT), 1)
|
2024-04-18 17:34:56 -05:00
|
|
|
CPPFLAGS += -O3 -flto
|
2024-03-23 09:56:38 -05:00
|
|
|
INFO :=$(INFO)_opt
|
2023-09-04 09:48:44 -05:00
|
|
|
else
|
2024-04-28 13:33:37 -05:00
|
|
|
CPPFLAGS += -O2
|
2023-09-04 09:48:44 -05:00
|
|
|
endif
|
|
|
|
|
2024-03-23 09:56:38 -05:00
|
|
|
CPPFLAGS += -DHAVE_CEIL -DCP_USE_CGTYPES=0 -DCP_USE_DOUBLES=0 -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF $(includeflag) -MD $(WARNING_FLAGS) -I. -DVER=\"$(SEM)\" -DCOM=\"$(COM)\" -DINFO=\"$(INFO)\" #-DENABLE_SINC_MEDIUM_CONVERTER -DENABLE_SINC_FAST_CONVERTER -DCP_COLLISION_TYPE_TYPE=uintptr_t -DCP_BITMASK_TYPE=uintptr_t
|
|
|
|
CPPFLAGS += -DCONFIG_VERSION=\"2024-02-14\" -DCONFIG_BIGNUM #for quickjs
|
2024-03-09 18:22:06 -06:00
|
|
|
|
2023-11-28 22:48:32 -06:00
|
|
|
# ENABLE_SINC_[BEST|FAST|MEDIUM]_CONVERTER
|
|
|
|
# default, fast and medium available in game at runtime; best available in editor
|
2023-09-02 06:53:52 -05:00
|
|
|
|
2024-03-23 09:56:38 -05:00
|
|
|
PKGCMD = tar --directory --exclude="./*.a" --exclude="./obj" -czf $(DISTDIR)/$(DIST) .
|
2023-09-03 12:50:02 -05:00
|
|
|
ZIP = .tar.gz
|
2023-09-04 01:20:55 -05:00
|
|
|
UNZIP = cp $(DISTDIR)/$(DIST) $(DESTDIR) && tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR) && rm $(DESTDIR)/$(DIST)
|
2023-09-03 12:50:02 -05:00
|
|
|
|
2024-04-17 06:32:25 -05:00
|
|
|
INFO := $(INFO)_$(ARCH)
|
2023-11-21 01:07:50 -06:00
|
|
|
|
2024-03-23 09:56:38 -05:00
|
|
|
ifeq ($(OS), Windows_NT) # then WINDOWS
|
2024-03-26 18:31:20 -05:00
|
|
|
PLATFORM := win64
|
2024-03-24 10:32:51 -05:00
|
|
|
DEPS += resource.o
|
2024-03-26 18:31:20 -05:00
|
|
|
STEAMAPI := steam_api64
|
2023-11-21 01:07:50 -06:00
|
|
|
LDFLAGS += -mwin32 -static
|
|
|
|
CPPFLAGS += -mwin32
|
2024-03-09 18:22:06 -06:00
|
|
|
LDLIBS += mingw32 kernel32 d3d11 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m pthread
|
2024-03-23 09:56:38 -05:00
|
|
|
PKGCMD = zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\*
|
2023-09-03 12:50:02 -05:00
|
|
|
ZIP = .zip
|
2023-09-04 01:20:55 -05:00
|
|
|
UNZIP = unzip -o -q $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
2024-03-23 09:56:38 -05:00
|
|
|
INFO :=$(INFO)_win
|
2024-04-18 17:34:56 -05:00
|
|
|
EXT = .exe
|
2024-03-23 09:56:38 -05:00
|
|
|
else ifeq ($(OS), IOS)
|
|
|
|
CC = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
|
|
|
|
SDK = iphoneos
|
|
|
|
SDK_PATH = /Applications/Xcode.app/Contents/Developer/Platforms/$(SDK).platform/Developer/SDKs/$(SDK).sdk
|
|
|
|
CFLAGS += -isysroot $(SDK_PATH) -miphoneos-version-min=13.0
|
|
|
|
LDFLAGS += -isysroot $(SDK_PATH) -miphoneos-version-min=13.0
|
|
|
|
LDFLAGS += -framework Foundation -framework UIKit -framework AudioToolbox -framework Metal -framework MetalKit -framework AVFoundation
|
|
|
|
CXXFLAGS += -std=c++11
|
2024-05-06 21:59:22 -05:00
|
|
|
CFLAGS += -x objective-c -DIOS
|
2024-03-23 09:56:38 -05:00
|
|
|
INFO :=$(INFO)_ios
|
2024-04-18 17:34:56 -05:00
|
|
|
else ifeq ($(OS), wasm) # Then WEB
|
2023-11-11 09:56:57 -06:00
|
|
|
OS := Web
|
2024-04-16 22:27:29 -05:00
|
|
|
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
|
2024-04-16 07:51:22 -05:00
|
|
|
CPPFLAGS += -DNSTEAM
|
2024-04-15 07:58:23 -05:00
|
|
|
LDLIBS += GL openal c m dl
|
|
|
|
STEAMAPI :=
|
2023-09-03 12:50:02 -05:00
|
|
|
EXT = .html
|
2023-11-20 15:57:23 -06:00
|
|
|
else
|
2023-09-03 12:50:02 -05:00
|
|
|
UNAME != uname -s
|
2024-03-23 09:56:38 -05:00
|
|
|
ifeq ($(UNAME), Linux) # then LINUX
|
2023-11-11 09:56:57 -06:00
|
|
|
OS := Linux
|
2024-05-16 14:50:18 -05:00
|
|
|
PLATFORM := linux64
|
2023-09-04 16:27:30 -05:00
|
|
|
LDFLAGS += -pthread -rdynamic
|
2024-05-16 14:50:18 -05:00
|
|
|
LDLIBS += pthread c m dl X11 Xi Xcursor EGL asound GL
|
|
|
|
INFO :=$(INFO)_linux
|
2023-09-03 12:50:02 -05:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(UNAME), Darwin)
|
2023-11-11 09:56:57 -06:00
|
|
|
OS := macos
|
2024-03-26 14:57:35 -05:00
|
|
|
PLATFORM := osx
|
2023-11-21 01:07:50 -06:00
|
|
|
CPPFLAGS += -arch $(ARCH)
|
2024-01-14 10:24:31 -06:00
|
|
|
CFLAGS += -x objective-c
|
2023-11-21 01:07:50 -06:00
|
|
|
CXXFLAGS += -std=c++11
|
2024-01-14 10:24:31 -06:00
|
|
|
LDFLAGS += -framework Cocoa -framework QuartzCore -framework AudioToolbox -framework Metal -framework MetalKit
|
2024-03-23 09:56:38 -05:00
|
|
|
INFO :=$(INFO)_macos
|
2023-09-03 12:50:02 -05:00
|
|
|
endif
|
2023-08-31 17:23:24 -05:00
|
|
|
endif
|
|
|
|
|
2022-02-03 09:16:22 -06:00
|
|
|
# All other sources
|
2024-03-26 13:05:25 -05:00
|
|
|
OBJS != find source -type f -name '*.c' | grep -vE 'test|tool|example|fuzz|main' | grep -vE 'quickjs'
|
|
|
|
CPPOBJS != find source -type f -name '*.cpp' | grep -vE 'test|tool|example|fuzz|main'
|
2024-03-03 16:58:59 -06:00
|
|
|
OBJS += $(CPPOBJS)
|
2024-03-28 17:40:14 -05:00
|
|
|
OBJS += source/engine/yugine.c
|
2023-11-20 07:49:14 -06:00
|
|
|
OBJS += $(shell find source/engine -type f -name '*.m')
|
2024-03-28 17:40:14 -05:00
|
|
|
QUICKJS := source/engine/thirdparty/quickjs
|
|
|
|
OBJS += $(addprefix $(QUICKJS)/, libregexp.c quickjs.c libunicode.c cutils.c libbf.c)
|
2024-03-23 09:56:38 -05:00
|
|
|
OBJS := $(patsubst %.cpp, %$(INFO).o, $(OBJS))
|
|
|
|
OBJS := $(patsubst %.c, %$(INFO).o,$(OBJS))
|
|
|
|
OBJS := $(patsubst %.m, %$(INFO).o, $(OBJS))
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2023-09-04 16:27:30 -05:00
|
|
|
engineincs != find source/engine -maxdepth 1 -type d
|
2022-12-23 13:48:29 -06:00
|
|
|
includeflag != find source -type d -name include
|
2024-05-08 11:07:19 -05:00
|
|
|
includeflag += $(engineincs) source/engine/thirdparty/sokol source/engine/thirdparty/stb source/engine/thirdparty/cgltf source/engine/thirdparty/TinySoundFont source/engine/thirdparty/dr_libs
|
2024-03-26 14:57:35 -05:00
|
|
|
includeflag += $(STEAM)/public
|
2024-03-26 13:05:25 -05:00
|
|
|
includeflag += source
|
2022-12-23 13:48:29 -06:00
|
|
|
includeflag := $(addprefix -I, $(includeflag))
|
2022-06-23 13:16:39 -05:00
|
|
|
|
2024-03-11 22:23:02 -05:00
|
|
|
WARNING_FLAGS = -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types
|
2022-11-24 01:54:17 -06:00
|
|
|
|
2024-04-17 06:32:25 -05:00
|
|
|
ifeq ($(INFO),_)
|
|
|
|
INFO :=
|
|
|
|
endif
|
2024-03-23 09:56:38 -05:00
|
|
|
APP = prosperon
|
|
|
|
NAME = $(APP)$(INFO)$(EXT)
|
2024-03-18 08:16:25 -05:00
|
|
|
SEM != git describe --tags --abbrev=0
|
|
|
|
COM != git rev-parse --short HEAD
|
2022-11-24 01:54:17 -06:00
|
|
|
|
2024-03-26 18:31:20 -05:00
|
|
|
LDLIBS += $(STEAMAPI)
|
2023-09-04 16:27:30 -05:00
|
|
|
LDLIBS := $(addprefix -l, $(LDLIBS))
|
2024-03-26 14:57:35 -05:00
|
|
|
LDPATHS := $(STEAM)/redistributable_bin/$(PLATFORM)
|
2023-11-20 07:49:14 -06:00
|
|
|
LDPATHS := $(addprefix -L, $(LDPATHS))
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2023-09-04 16:27:30 -05:00
|
|
|
DEPENDS = $(OBJS:.o=.d)
|
2022-02-03 11:29:43 -06:00
|
|
|
-include $(DEPENDS)
|
2022-02-03 09:16:22 -06:00
|
|
|
|
2023-09-03 12:50:02 -05:00
|
|
|
.DEFAULT_GOAL := all
|
2024-03-23 09:56:38 -05:00
|
|
|
all: $(NAME)
|
2024-03-24 10:32:51 -05:00
|
|
|
cp -f $(NAME) $(APP)$(EXT)
|
2023-09-03 12:50:02 -05:00
|
|
|
|
2024-05-08 11:07:19 -05:00
|
|
|
prereqs: source/engine/core.cdb.h
|
2024-03-29 12:38:14 -05:00
|
|
|
|
2024-03-24 10:32:51 -05:00
|
|
|
DESTDIR ?= ~/.bin
|
2024-03-23 09:56:38 -05:00
|
|
|
install: $(NAME)
|
2024-03-24 12:44:35 -05:00
|
|
|
@echo Copying to destination
|
2024-03-23 09:56:38 -05:00
|
|
|
cp -f $(NAME) $(DESTDIR)/$(APP)
|
2022-11-23 22:44:42 -06:00
|
|
|
|
2024-03-28 17:40:14 -05:00
|
|
|
$(NAME): $(OBJS) $(DEPS)
|
2022-12-15 17:30:17 -06:00
|
|
|
@echo Linking $(NAME)
|
2024-04-18 17:34:56 -05:00
|
|
|
$(CROSS)$(LD) $^ $(CPPFLAGS) $(LDFLAGS) -L. $(LDPATHS) $(LDLIBS) -o $@
|
2022-11-23 17:29:50 -06:00
|
|
|
@echo Finished build
|
2022-08-12 14:03:56 -05:00
|
|
|
|
2024-03-29 12:38:14 -05:00
|
|
|
%$(INFO).o: %.c
|
2023-09-04 09:48:44 -05:00
|
|
|
@echo Making C object $@
|
2024-04-18 17:34:56 -05:00
|
|
|
$(CROSS)$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2024-03-23 09:56:38 -05:00
|
|
|
%$(INFO).o: %.cpp
|
2024-03-09 18:22:06 -06:00
|
|
|
@echo Making C++ object $@
|
2024-04-18 17:34:56 -05:00
|
|
|
$(CROSS)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -fpermissive -c $< -o $@
|
2023-11-20 07:49:14 -06:00
|
|
|
|
2024-03-23 09:56:38 -05:00
|
|
|
%$(INFO).o: %.m
|
2023-11-20 07:49:14 -06:00
|
|
|
@echo Making Objective-C object $@
|
2024-04-18 17:34:56 -05:00
|
|
|
$(CROSS)$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
2023-11-20 07:49:14 -06:00
|
|
|
|
2024-03-24 12:44:35 -05:00
|
|
|
SCRIPTS := $(shell ls scripts/*.js*)
|
|
|
|
CORE != (ls icons/* fonts/*)
|
|
|
|
CORE := $(CORE) $(SCRIPTS)
|
|
|
|
|
2024-04-15 07:58:23 -05:00
|
|
|
packer: tools/packer.c source/engine/miniz.c
|
2024-03-23 09:56:38 -05:00
|
|
|
@echo Making packer
|
2024-03-28 17:40:14 -05:00
|
|
|
$(CC) -O2 $^ -Isource/engine -o packer
|
2024-03-23 09:56:38 -05:00
|
|
|
|
2024-04-15 07:58:23 -05:00
|
|
|
core.cdb: packer $(CORE)
|
2024-03-24 12:44:35 -05:00
|
|
|
@echo Packing core.cdb
|
2024-04-15 07:58:23 -05:00
|
|
|
./packer $@ $(CORE)
|
2023-09-18 07:36:07 -05:00
|
|
|
|
|
|
|
source/engine/core.cdb.h: core.cdb
|
2024-03-24 12:44:35 -05:00
|
|
|
@echo Making $@
|
2023-09-18 07:36:07 -05:00
|
|
|
xxd -i $< > $@
|
|
|
|
|
2024-03-24 10:32:51 -05:00
|
|
|
ICNSIZE = 16 32 128 256 512 1024
|
|
|
|
ICNNAME := $(addsuffix .png, $(ICNSIZE))
|
|
|
|
ICON = icons/moon.gif
|
|
|
|
icon.ico: $(ICON)
|
|
|
|
for i in $(ICNSIZE); do convert $^ -thumbnail $${i}x$${i} $${i}.png; done
|
|
|
|
convert $(ICNNAME) icon.ico
|
|
|
|
rm $(ICNNAME)
|
|
|
|
|
|
|
|
resource.o: resource.rc resource.manifest icon.ico
|
2024-04-18 17:34:56 -05:00
|
|
|
$(CROSS)windres -i $< -o $@
|
2024-03-24 10:32:51 -05:00
|
|
|
|
2024-03-23 09:56:38 -05:00
|
|
|
crossios:
|
|
|
|
make OS=IOS ARCH=arm64 DEBUG=$(DEBUG) OPT=$(OPT)
|
|
|
|
|
2024-03-24 10:32:51 -05:00
|
|
|
Prosperon.icns: $(ICON)
|
2024-03-23 09:56:38 -05:00
|
|
|
mkdir -p Prosperon.iconset
|
2024-03-24 10:32:51 -05:00
|
|
|
for i in $(ICNSIZE); do magick $^ -size $${i}x$${i} Prosperon.iconset/icon_$${i}x$${i}.png; done
|
2024-03-23 09:56:38 -05:00
|
|
|
iconutil -c icns Prosperon.iconset
|
|
|
|
|
|
|
|
crossmac: Prosperon.icns
|
|
|
|
make ARCH=arm64 DEBUG=$(DEBUG) OPT=$(OPT)
|
|
|
|
mv $(APP) mac_arm64
|
|
|
|
make ARCH=x86_64 DEBUG=$(DEBUG) OPT=$(OPT)
|
|
|
|
mv $(APP) mac_x86_64
|
|
|
|
lipo mac_arm64 mac_x86_64 -create -output $(APP)_mac
|
|
|
|
rm mac_arm64 mac_x86_64
|
|
|
|
rm -rf Prosperon.app
|
|
|
|
mkdir Prosperon.app
|
|
|
|
mkdir Prosperon.app/Contents
|
|
|
|
mkdir Prosperon.app/Contents/MacOS
|
|
|
|
mkdir Prosperon.app/Contents/Resources
|
|
|
|
mv $(NAME) Prosperon.app/Contents/MacOS/Prosperon
|
|
|
|
cp Info.plist Prosperon.app/Contents
|
|
|
|
cp Prosperon.icns Prosperon.app/Contents/Resources
|
2024-04-18 17:34:56 -05:00
|
|
|
|
|
|
|
crosswin:
|
|
|
|
make CROSS=x86_64-w64-mingw32- OS=Windows_NT CC=gcc
|
2023-11-11 09:56:57 -06:00
|
|
|
|
2024-03-09 18:22:06 -06:00
|
|
|
crossweb:
|
2024-04-18 17:34:56 -05:00
|
|
|
make CROSS=em OS=wasm
|
2024-04-17 06:32:25 -05:00
|
|
|
mv $(APP).html index.html
|
2024-04-18 17:34:56 -05:00
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
clean:
|
|
|
|
@echo Cleaning project
|
2024-05-08 11:07:19 -05:00
|
|
|
rm -f core.cdb jso cdb packer TAGS source/engine/core.cdb.h tools/libcdb.a $(APP)* *.icns *.ico
|
2024-03-26 13:05:25 -05:00
|
|
|
find . -type f -name "*.[oad]" -delete
|
2024-03-23 09:56:38 -05:00
|
|
|
rm -rf Prosperon.app
|
2023-09-15 03:37:07 -05:00
|
|
|
|
2024-02-21 03:45:26 -06:00
|
|
|
docs: doc/prosperon.org
|
|
|
|
make -C doc
|
|
|
|
mv doc/html .
|
2024-02-19 20:31:26 -06:00
|
|
|
|
2023-09-15 03:37:07 -05:00
|
|
|
TAGINC != find . -name "*.[chj]"
|
|
|
|
tags: $(TAGINC)
|
|
|
|
@echo Making tags.
|
|
|
|
@etags $(TAGINC)
|