forked from fluffyfreak/stuntcarracer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (82 loc) · 3.75 KB
/
Makefile
File metadata and controls
104 lines (82 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Stunt Car Racer — Emscripten Build
#
# Usage:
# make — production build (fullscreen, custom shell, PWA assets)
# make debug — debug build (small canvas, log area)
# make CHEAT=1 — build with cheat keys (W=win, L=lose during races)
# make clean — remove build output
#
# Requires Emscripten 5.0+ (emcc on PATH).
ENGINE = game-engine
WEB = web
SOURCES = \
$(ENGINE)/StuntCarRacer.cpp \
$(ENGINE)/dxstdafx.cpp \
$(ENGINE)/Car\ Behaviour.cpp \
$(ENGINE)/3D\ Engine.cpp \
$(ENGINE)/Opponent\ Behaviour.cpp \
$(ENGINE)/Car.cpp \
$(ENGINE)/Track.cpp \
$(ENGINE)/wavefunctions.cpp \
$(ENGINE)/Backdrop.cpp \
$(wildcard $(ENGINE)/Substitutes/*.cpp)
EMCC_FLAGS = \
-O2 \
-ferror-limit=1000 \
-s LLD_REPORT_UNDEFINED \
-s EXPORTED_FUNCTIONS='["_main","_touchSetDriveInput","_jsSelectTrack","_jsStartPreview","_jsStartGame","_jsGoToMenu","_jsGetTrackID","_jsGetNumTracks","_jsIsRaceFinished","_jsIsRaceWon","_jsIsPlayerWrecked","_jsGetOpponentId","_jsGetBoostReserve","_jsGetBoostMax","_jsGetDamage","_jsGetDamageHolePosition","_jsSetDamageHolePosition","_jsGetLapNumber","_jsGetGameMode","_jsSetGameOver","_jsGetTrackName","_jsGetOpponentName","_jsGetPlayerBestLap","_jsGetOpponentBestLap","_jsIsSoloMode","_jsGetDisplaySpeed","_jsGetCurrentLapTime","_jsGetDistanceToOpponent","_jsSetTwoPlayerMode","_jsSetTwoPlayerSide","_jsGetPlayerRoadSection","_jsGetPlayerDistanceIntoSection","_jsGetPlayerRoadXPosition","_jsGetPlayerZSpeed","_jsGetPlayerDamage","_jsGetPlayerWheelFL","_jsGetPlayerWheelFR","_jsGetPlayerWheelR","_jsSetOpponentState","_jsSetSuperLeague","_jsGetSparkFerocity"]' \
-s EXPORTED_RUNTIME_METHODS='["ccall","cwrap","UTF8ToString"]' \
-lopenal \
--use-preload-plugins \
-s USE_SDL_IMAGE=2 \
-s SDL2_IMAGE_FORMATS='["bmp"]' \
-s MAX_WEBGL_VERSION=2 \
--embed-file $(ENGINE)/Tracks@Tracks \
--embed-file $(ENGINE)/Bitmap@Bitmap \
--embed-file $(ENGINE)/Sounds@Sounds
# Cheat mode: CHEAT=1 adds W/L keys to force win/loss during races
comma := ,
ifdef CHEAT
EMCC_FLAGS += -DCHEAT_MODE
# Append cheat functions to the export list
EMCC_FLAGS := $(subst _jsSetOpponentState"],_jsSetOpponentState"$(comma)"_jsCheatWin"$(comma)"_jsCheatLose"],$(EMCC_FLAGS))
endif
DIST = dist
# Static PWA assets to copy into dist/ for production builds
PWA_ASSETS = manifest.json icon-192.png icon-512.png game.css
# JavaScript sources (copied flat into dist/)
JS_SOURCES = $(WEB)/javascript/sw.js $(WEB)/javascript/multiplayer.js $(WEB)/javascript/game.js
JS_DIST = $(patsubst $(WEB)/javascript/%,$(DIST)/%,$(JS_SOURCES))
# ─── Targets ────────────────────────────────────────────────
.PHONY: all debug clean
# Image assets under web/images/ to copy into dist/images/
IMAGES = $(shell find $(WEB)/images -type f)
IMAGES_DIST = $(patsubst $(WEB)/%,$(DIST)/%,$(IMAGES))
all: $(DIST)/source.html $(addprefix $(DIST)/,$(PWA_ASSETS)) $(JS_DIST) $(IMAGES_DIST)
debug: $(DIST)/source.html
$(DIST)/source.html: $(SOURCES) $(WEB)/custom_shell.html $(WEB)/game.css $(JS_SOURCES) | $(DIST)
@echo "Building…"
@if [ "$(MAKECMDGOALS)" = "debug" ]; then \
echo " (debug build)"; \
emcc $(SOURCES) $(EMCC_FLAGS) -o $(DIST)/source.html; \
else \
echo " (production build — using custom shell)"; \
emcc $(SOURCES) $(EMCC_FLAGS) --shell-file $(WEB)/custom_shell.html -o $(DIST)/source.html; \
fi
$(DIST)/%.json: $(WEB)/%.json | $(DIST)
cp $< $@
$(DIST)/%.js: $(WEB)/javascript/%.js | $(DIST)
cp $< $@
$(DIST)/%.css: $(WEB)/%.css | $(DIST)
cp $< $@
$(DIST)/images/%: $(WEB)/images/% | $(DIST)
mkdir -p $(dir $@)
cp $< $@
$(DIST)/%.png: $(WEB)/%.png | $(DIST)
cp $< $@
$(DIST):
mkdir -p $(DIST)
$(DIST)/images:
mkdir -p $(DIST)/images
clean:
rm -rf $(DIST)