.DEFAULT_GOAL := engine # Modules listed in dependency order MODULE_NAMES := entity tilemap world input physics renderer assets engine mixer sound animation ai scene-loader OBJECT_FILES := $(patsubst %,bin/%.o,$(MODULE_NAMES)) DEMO_NAMES := platformer shmup topdown audio sandbox 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/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/engine.o: bin/renderer.o bin/world.o bin/input.o bin/assets.o bin/mixer.o: bin/sound.o: bin/mixer.o bin/animation.o: bin/entity.o bin/world.o bin/ai.o: bin/entity.o bin/world.o bin/scene-loader.o: bin/world.o bin/tilemap.o bin/assets.o bin/engine.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 clean: rm -rf bin rm -f *.import.scm rm -f *.log test: @echo "Running unit tests..." @csi -s tests/entity-test.scm @csi -s tests/world-test.scm @csi -s tests/tilemap-test.scm @csi -s tests/physics-test.scm @csi -s tests/input-test.scm @csi -s tests/renderer-test.scm @csi -s tests/assets-test.scm @csi -s tests/engine-test.scm @csi -s tests/animation-test.scm @csi -s tests/ai-test.scm @csi -s tests/scene-loader-test.scm 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