Files
catch-phase/Makefile
2026-11-08 20:20:10 +03:00

97 lines
2.4 KiB
Makefile

# raylib is built as a static library. After changing its build flags, run
# `make clean` so its objects are rebuilt with the new flags.
SEXC ?= sexc
CC ?= cc
RAYLIB_LIB := build/libraylib.a
RAYLIB_PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_BUILD_MODE ?= RELEASE
CFLAGS ?= -g
RAYLIB_SRC := third-party/raylib/src
RAYGUI_SRC := third-party/raygui/src
RAYTMX_SRC := third-party/raytmx
INCLUDES := -I$(RAYLIB_SRC) -I$(RAYGUI_SRC) -I$(RAYTMX_SRC) -I$(RAYTMX_SRC)/external
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
RAYLIB_LIBS := -framework OpenGL -framework Cocoa -framework IOKit \
-framework CoreAudio -framework CoreVideo -framework QuartzCore
else
RAYLIB_LIBS := -lGL -lm -lpthread -ldl -lrt -lX11
endif
OBJECTS := main.o menu.o game.o tmx.o audio.o
all: catch-phase
catch-phase: $(OBJECTS) $(RAYLIB_LIB)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(RAYLIB_LIB) $(RAYLIB_LIBS)
%.o: %.sex
$(SEXC) $< -c -o $@ -- $(CFLAGS) $(INCLUDES)
# raylib ------------------------------------------------------------
$(RAYLIB_LIB):
mkdir -p build
$(MAKE) -C $(RAYLIB_SRC) clean
$(MAKE) -C $(RAYLIB_SRC) \
PLATFORM=$(RAYLIB_PLATFORM) \
RAYLIB_LIBTYPE=STATIC \
RAYLIB_BUILD_MODE=$(RAYLIB_BUILD_MODE) \
RAYLIB_RELEASE_PATH=$(abspath ./build)
# web build ---------------------------------------------------------
EMCC ?= emcc
EMAR ?= emar
WEB_SEXC := $(SEXC) --c-compiler=$(EMCC) --no-platform-features --features=emscripten
EMFLAGS := -O2 -DPLATFORM_WEB \
-sUSE_GLFW=3 \
-sTOTAL_MEMORY=134217728 \
-sFORCE_FILESYSTEM=1 \
--shell-file shell.html \
--preload-file ./res@res
WEB_OBJECTS := web/menu.o web/game.o web/tmx.o web/audio.o
web/%.o: %.sex
mkdir -p web
$(WEB_SEXC) $< -c -o $@ -- \
$(CFLAGS) $(INCLUDES)
web/libraylib.web.a:
mkdir -p web
$(MAKE) -C $(RAYLIB_SRC) clean
$(MAKE) -C $(RAYLIB_SRC) \
PLATFORM=PLATFORM_WEB \
RAYLIB_LIBTYPE=STATIC \
RAYLIB_BUILD_MODE=RELEASE \
GRAPHICS=GRAPHICS_API_OPENGL_ES2 \
RAYLIB_RELEASE_PATH=$(abspath ./web)
web/index.html: $(WEB_OBJECTS) main.sex shell.html web/libraylib.web.a
$(WEB_SEXC) main.sex -o $@ -- \
-I$(RAYLIB_SRC) \
$(WEB_OBJECTS) \
./web/libraylib.web.a \
$(EMFLAGS)
web: web/index.html
serve: web
python3 -m http.server -d web 8000
# ------------------------------------------------------------
clean:
$(MAKE) -C $(RAYLIB_SRC) clean
rm -rf ./build ./web
rm -f $(OBJECTS) catch-phase
.PHONY: all clean