-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (43 loc) · 1002 Bytes
/
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
# Copyright 2022 Mitchell Kember. Subject to the MIT License.
define usage
Targets:
all Build eva
help Show this help message
check Run before committing
test Run tests
clean Remove build output
Variables:
DEBUG If nonempty, build in debug mode
endef
.PHONY: all help check test clean
CFLAGS := $(shell cat compile_flags.txt) $(if $(DEBUG),-O0 -g,-O3 -DNDEBUG)
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
LDFLAGS := $(if $(DEBUG),,-O3)
LDLIBS := -lreadline
src_existing := $(wildcard src/*.c)
src_gen := src/prelude.c
src := $(src_existing) $(src_gen)
obj := $(src:src/%.c=obj/%.o)
dep := $(obj:.o=.d)
bin := bin/eva
.SUFFIXES:
all: $(bin)
help:
$(info $(usage))
@:
check: all test
test: $(bin)
./test.sh
clean:
rm -f $(src_gen)
rm -rf obj bin
./test.sh clean
src/prelude.c: gen-prelude.sh src/prelude.scm
./$^ $@
obj bin:
mkdir $@
obj/%.o: src/%.c | obj
$(CC) $(CFLAGS) $(DEPFLAGS) -c -o $@ $<
$(bin): $(obj) | bin
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
-include $(dep)