Mirai's Miscellaneous Misadventures
M18 / makefile
1# copyright 2022 zamfofex
2# license: AGPLv3 or later
3
4.PHONY: build clean
5
6engine = mfb
7
8libs =
9
10ifeq ($(engine),sdl2)
11libs += -lSDL2
12endif
13
14ifeq ($(engine),mfb)
15libs += -lminifb -lX11 -lGL
16CFLAGS += -Wno-discarded-qualifiers
17endif
18
19src = \
20 core/behaviors.c \
21 core/sprites.c \
22 core/controls.c \
23 core/cameras.c \
24 core/appearances.c \
25 core/displays.c \
26 core/fonts.c core/font.c \
27 core/text.c \
28 models/all.c \
29 test/chapter.c \
30 engines/$(engine).c
31
32exe = mimimi
33
34ifneq ($(engine),wasm)
35
36src += core/malloc.c
37
38$(exe): $(src:.c=.o) main/$(engine).o
39 @echo $(CC) -o $@
40 @$(CC) $(LDFLAGS) -o $@ $^ $(libs)
41
42%.o: %.c
43 @echo $(CC) -c $<
44 @$(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MP -Iinclude -c -o $@ $<
45
46else
47
48$(exe).wasm: $(src:.c=.wasm)
49 @echo $(CC) -o $@
50 @$(CC) $(LDFLAGS) --target=wasm32 -nostdlib -Wl,--no-entry \
51 -Wl,--export=mimimi_wasm_stamp \
52 -Wl,--export=mimimi_wasm_allocator \
53 -Wl,--export=mimimi_wasm_allocate \
54 -Wl,--export=mimimi_test \
55 -Wl,--allow-undefined \
56 -Wl,--export-table,--growable-table \
57 -o $@ $^ $(libs)
58
59%.wasm: %.c
60 @echo $(CC) -c $<
61 @$(CC) $(CFLAGS) $(CPPFLAGS) --target=wasm32 -ffreestanding -MMD -MP -Iinclude -c -o $@ $<
62
63endif
64
65clean:
66 $(RM) $(exe) $(exe).wasm */*.o */*.wasm */*.d
67
68-include $(src:.c=.d)