-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
63 lines (47 loc) · 1.45 KB
/
Makefile
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
CC := clang
CFLAGS := -std=c17 -Wall -Wextra -pedantic $(ADD_CFLAGS)
LDFLAGS := $(ADD_LDFLAGS)
LDLIBS := -lm -lpthread -lncursesw $(ADD_LDLIBS)
LIB_SRCS := ccodoc.c renderer.c canvas.c time.c memory.c string.c math.c platform.c
SRCS := main.c mode.c $(LIB_SRCS)
OBJS := $(patsubst %.c, %.o, $(SRCS))
TEST_SRCS := test.c $(LIB_SRCS) ccodoc_test.c renderer_test.c string_test.c time_test.c platform_test.c
TEST_OBJS := $(patsubst %.c, %.o, $(TEST_SRCS))
override TARGET := $(shell ./tool/build/detect_platform.sh $(TARGET))
ifeq ($(TARGET),)
$(error failed to detect target platform)
endif
ifeq ($(TARGET), linux)
CFLAGS += -include env_linux.h
COMPILE_FLAGS := compile_flags_linux.txt
endif
ifeq ($(TARGET), macos)
CFLAGS += -include env_macos.h
VSCODE_SETTINGS := .vscode/settings_macos.json
COMPILE_FLAGS := compile_flags_macos.txt
endif
ccodoc: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
test.exe: $(TEST_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
assets/sounds/sounds.h: tool/build/embed_sounds.exe assets/sounds/*.mp3
./$<
mode.o: mode.h mode.c assets/sounds/sounds.h
%.o: %.h %.c
%.exe: %.c
$(CC) $(CFLAGS) -o $@ $*.c
.PHONY: run
run: ccodoc
./ccodoc $(ARGS)
.PHONY: test
test: test.exe
./$< $(ARGS)
.PHONY: clean
clean:
$(RM) ccodoc
find . -name '*.o' -or -name '*.exe' | while read -r file; do $(RM) "$${file}"; done
# dev
.vscode/settings.json: $(VSCODE_SETTINGS)
cat $^ > $@
compile_flags.txt: $(COMPILE_FLAGS)
cat compile_flags_vanilla.txt $^ > $@