.DEFAULT_GOAL := engine CSI ?= csi CSI_FLAGS := -I $(CURDIR) -I $(CURDIR)/bin # Canonical release string for the tree — keep in sync with downstroke.egg and # README v… markers (see bump-version). VERSION := 1.0.0 # Modules listed in dependency order MODULE_NAMES := entity tween tilemap world input physics renderer assets animation engine mixer sound prefabs scene-loader OBJECT_FILES := $(patsubst %,bin/%.o,$(MODULE_NAMES)) DEMO_NAMES := getting-started platformer shmup topdown audio sandbox spritefont menu tweens scaling animation DEMO_BINS := $(patsubst %,bin/demo-%,$(DEMO_NAMES)) UNIT_NAMES := $(patsubst %,downstroke.%,$(MODULE_NAMES)) USES_FLAGS := $(patsubst %,-uses %,$(UNIT_NAMES)) # Build all engine modules engine: $(OBJECT_FILES) bin: @mkdir -p $@ # Explicit inter-module dependencies bin/entity.o: bin/tween.o: bin/entity.o bin/tilemap.o: bin/world.o: bin/entity.o bin/tilemap.o bin/input.o: bin/entity.o bin/physics.o: bin/entity.o bin/world.o bin/tilemap.o bin/renderer.o: bin/entity.o bin/tilemap.o bin/world.o bin/assets.o: bin/animation.o: bin/entity.o bin/world.o bin/engine.o: bin/renderer.o bin/world.o bin/input.o bin/assets.o bin/physics.o bin/tween.o bin/animation.o bin/mixer.o: bin/sound.o: bin/mixer.o bin/prefabs.o: bin/entity.o bin/scene-loader.o: bin/world.o bin/tilemap.o bin/assets.o bin/engine.o bin/prefabs.o # Pattern rule: compile each module as a library unit bin/%.o: %.scm | bin csc -c -J -unit downstroke.$* $*.scm -o bin/$*.o -I bin @if [ -f downstroke.$*.import.scm ]; then mv downstroke.$*.import.scm bin/; fi .PHONY: clean test engine demos filter format bump-version # Reformat every tracked .scm file with Emacs `indent-region` under the user's # real init (so geiser-chicken / scheme-mode rules apply consistently). # Override EMACS_INIT_DIR / EMACS_SUBSTRATE_DIR if your config lives elsewhere. EMACS_INIT_DIR ?= $(HOME)/.emacs-perso EMACS_SUBSTRATE_DIR ?= $(EMACS_INIT_DIR)/emacs-substrate format: @emacs --batch \ --init-directory=$(EMACS_INIT_DIR) \ --eval "(add-to-list 'load-path \"$(EMACS_SUBSTRATE_DIR)/\")" \ -l $(EMACS_INIT_DIR)/init.el \ -l format.el \ --eval "(downstroke-format-tracked-scm-files)" clean: rm -rf bin downstroke/ rm -f *.import.scm *.import.so *.so *.o *.link rm -f *.log test: @echo "Running unit tests..." @$(CSI) $(CSI_FLAGS) -s tests/entity-test.scm @$(CSI) $(CSI_FLAGS) -s tests/world-test.scm @$(CSI) $(CSI_FLAGS) -s tests/tilemap-test.scm @$(CSI) $(CSI_FLAGS) -s tests/physics-test.scm @$(CSI) $(CSI_FLAGS) -s tests/input-test.scm @$(CSI) $(CSI_FLAGS) -s tests/renderer-test.scm @$(CSI) $(CSI_FLAGS) -s tests/assets-test.scm @$(CSI) $(CSI_FLAGS) -s tests/engine-test.scm @$(CSI) $(CSI_FLAGS) -s tests/animation-test.scm @$(CSI) $(CSI_FLAGS) -s tests/prefabs-test.scm @$(CSI) $(CSI_FLAGS) -s tests/scene-loader-test.scm @$(CSI) $(CSI_FLAGS) -s tests/tween-test.scm # Run a single test file with optional name/group filtering (pytest -k style). # make filter FILE=tests/physics-test.scm # whole file # make filter FILE=tests/physics-test.scm K=gravity # tests matching regex # make filter FILE=tests/physics-test.scm G=apply # groups matching regex # Note: combining K/G with TEST_QUIET=1 hits a known bug in the `test` egg # (modulo error in summary timing), so this target intentionally doesn't # expose Q. Use `TEST_QUIET=1 $(CSI) $(CSI_FLAGS) -s ` when you want quiet. filter: @if [ -z "$(FILE)" ]; then echo "usage: make filter FILE= [K=name-regex] [G=group-regex]"; exit 2; fi @$(if $(K),TEST_FILTER='$(K)') $(if $(G),TEST_GROUP_FILTER='$(G)') $(CSI) $(CSI_FLAGS) -s $(FILE) demos: engine $(DEMO_BINS) bin/demo-%: demo/%.scm $(OBJECT_FILES) | bin csc demo/$*.scm $(OBJECT_FILES) -o bin/demo-$* -I bin $(USES_FLAGS) -L -lSDL2_mixer # Bump VERSION, downstroke.egg, and README v… strings (POSIX sed: write temp, mv). # NEW must not contain &, backslash, or # (sed replacement / delimiter limits). bump-version: ifndef NEW $(error usage: make bump-version NEW=1.2.3) endif @set -e; \ test "$(VERSION)" != "$(NEW)" || { echo "bump-version: already at $(VERSION)"; exit 0; }; \ old='$(VERSION)'; new='$(NEW)'; \ oesc=$$(printf '%s' "$$old" | sed 's/\./\\./g'); \ t=$$$$.bump; \ sed "s#^VERSION := $$oesc#VERSION := $$new#" Makefile > "Makefile.$$t" && mv "Makefile.$$t" Makefile; \ sed "s#((version \"$$oesc\")#((version \"$$new\")#" downstroke.egg > "downstroke.egg.$$t" && mv "downstroke.egg.$$t" downstroke.egg; \ echo "bump-version: $$old -> $$new (Makefile, downstroke.egg)"