Mirai's Miscellaneous Misadventures
M7 / Makefile
1.PHONY: build clean
2
3engine ?= sdl2
4
5ifeq ($(engine),sdl2)
6libs += -lSDL2
7endif
8
9src = game.c
10src += engines/$(engine).c
11
12exe = mimimi
13
14ifeq ($(engine),wasm)
15build: $(exe).wasm
16else
17build: $(exe)
18endif
19
20clean:
21 $(RM) $(exe) $(exe).wasm *.o *.wasm *.d engines/*.o engines/*.wasm engines/*.d
22
23$(exe): $(src:.c=.o)
24 $(CC) $(LDFLAGS) -o $@ $^ $(libs)
25
26$(exe).wasm: $(src:.c=.wasm)
27 $(CC) $(LDFLAGS) --target=wasm32 -nostdlib -Wl,--no-entry \
28 -Wl,--export=mirai_game_size \
29 -Wl,--export=mirai_width \
30 -Wl,--export=mirai_height \
31 -Wl,--export=mirai_start \
32 -Wl,--export=mirai_step \
33 -Wl,--export=mirai_assets \
34 -Wl,--export=mirai_wasm_stamp \
35 -Wl,--export=__heap_base \
36 -Wl,--allow-undefined \
37 -Wl,--export-table,--growable-table \
38 -o $@ $^ $(libs)
39
40%.wasm: %.c
41 $(CC) $(CFLAGS) $(CPPFLAGS) --target=wasm32 -ffreestanding -c -o $@ $<
42
43%.d: %.c
44 $(CC) -MM -MP -MT '$(@:.d=.o) $@' -MF $@ engines/sdl2.c
45
46include $(src:.c=.d)