-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (41 loc) · 1.3 KB
/
Makefile
File metadata and controls
52 lines (41 loc) · 1.3 KB
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
WARNINGS=-Wnull-dereference -Wall -Winline -Wextra -Wno-unused-parameter
CFLAGS+=-g -std=gnu11 $(WARNINGS) -I$(CURDIR) -I$(CURDIR)/vendor
LDLIBS+=-lm -lreadline vendor/utf8proc/libutf8proc.a
SANITIZERS+=address,undefined
ifeq ($(TARGET),release)
CFLAGS+=-DNDEBUG -O3 -flto
else ifeq ($(TARGET),profile)
CFLAGS+=-DPROFILE -pg -O3 -flto --coverage
endif
ifneq ($(TARGET),release)
ifneq ($(TARGET),profile)
CFLAGS+=-fsanitize=$(SANITIZERS)
endif
CFLAGS+=-fno-omit-frame-pointer
endif
ifeq ($(TARGET),debug)
CFLAGS+=-DCB_DEBUG_VM
endif
SRC = $(wildcard *.c modules/*.c)
OBJ := $(patsubst %.c,%.o,$(SRC))
DEP := $(patsubst %.o,%.d,$(OBJ))
cbcvm: $(OBJ) vendor/utf8proc/libutf8proc.a
$(CC) $(CFLAGS) -o $@ $(OBJ) $(LDFLAGS) $(LDLIBS)
-include $(DEP)
%.o: %.c
$(CC) $(CFLAGS) -MMD -o $@ -c $<
vendor/utf8proc/libutf8proc.a:
$(MAKE) -C vendor/utf8proc
# Generate a release binary using profile-guided optimization
profile-opt:
CFLAGS='-fprofile-generate' $(MAKE) clean cbcvm TARGET=release
./cbcvm bf.cb bench.b
$(MAKE) clean
CFLAGS='-fprofile-use -fprofile-correction' $(MAKE) TARGET=release
find . -name '*.gcda' -delete
clean:
[ -f cbcvm ] && rm cbcvm || true
-rm $(OBJ) $(DEP)
find . \( -name '*.gcda' -o -name '*.gcno' -o -name 'gmon.out' \) -delete
$(MAKE) -C vendor/utf8proc clean
.PHONY: clean profile-opt