-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (32 loc) · 880 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
CC ?= clang
BUILD_CONFIG ?= debug
BUILD_ASAN ?= true
BUILD_PATH = build
CFLAGS += -std=c99 -Wall -Wextra -Wconversion -Wno-sign-conversion -Wno-unused-function -Wpedantic \
-Iinclude
LFLAGS +=
ifeq ($(BUILD_CONFIG), debug)
CFLAGS += -gdwarf-5
ifeq ($(BUILD_ASAN), true)
CFLAGS += -fsanitize=address,undefined -fno-omit-frame-pointer
LFLAGS += -fsanitize=address,undefined
endif
CFLAGS += -O0 -g3 -DTEST_DEBUG
else
CFLAGS += -Os
LFLAGS +=
endif
TEST_SRC = test/main.c test/test_assert.c
TEST_OBJ := $(patsubst %.c,$(BUILD_PATH)/%.o,$(TEST_SRC))
test: $(TEST_OBJ) ./include/test/test.h
$(CC) $(LFLAGS) $(TEST_OBJ) -o build/main
dev: clean
@mkdir -p $(BUILD_PATH)
bear --output $(BUILD_PATH)/compile_commands.json -- $(MAKE)
clean:
rm -rf build
.PHONY: clean test dev
.SUFFIXES:
$(TEST_OBJ): $(BUILD_PATH)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) -c $(CFLAGS) $< -o $@