-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (29 loc) · 937 Bytes
/
Copy pathMakefile
File metadata and controls
40 lines (29 loc) · 937 Bytes
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
CC ?= cc
CFLAGS ?= -O2 -std=c11 \
-Iinclude -Itests \
-Wall -Wextra -Wpedantic -Wconversion -Wshadow \
-Wcast-align -Wcast-qual -Wpointer-arith -Wformat=2 \
-Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wundef
BUILD_DIR = build
CTEST_PATH = $(BUILD_DIR)/tests/ctest
SRC_FILES = $(wildcard src/*.c)
TEST_FILES = $(wildcard tests/*.c)
SRC_OBJS = $(patsubst src/%.c, $(BUILD_DIR)/src/%.o, $(SRC_FILES))
TEST_OBJS = $(patsubst tests/%.c, $(BUILD_DIR)/tests/%.o, $(TEST_FILES))
.PHONY: all ctest clean
all: ctest
ctest: $(CTEST_PATH)
$(CTEST_PATH)
$(CTEST_PATH): $(SRC_OBJS) $(TEST_OBJS)
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -o $@ $^
$(BUILD_DIR)/src/%.o: src/%.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD_DIR)/tests/%.o: tests/%.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -rf $(BUILD_DIR)
coverage-html:
bash tools/coverage_html.sh