-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (38 loc) · 1.27 KB
/
Copy pathMakefile
File metadata and controls
53 lines (38 loc) · 1.27 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
53
CC ?= cc
# Stronger warnings for code quality
CFLAGS ?= -O2 -Iinclude -Wall -Wextra -Wpedantic -Wconversion -Wshadow \
-Wcast-align -Wcast-qual -Wpointer-arith -Wformat=2 \
-Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wundef \
-std=c99
AR ?= ar
PREFIX ?= /usr/local
LIBNAME = libspacepacket.a
BUILD_DIR = build
LIB_PATH = $(BUILD_DIR)/$(LIBNAME)
OBJ_PATH = $(BUILD_DIR)/src/space_packet.o
EXAMPLE_PATH = $(BUILD_DIR)/examples/spacepacket_example
CTEST_PATH = $(BUILD_DIR)/tests/ctest
COVERAGE_MIN ?= 95
all: lib example test
lib: $(LIB_PATH)
$(OBJ_PATH): src/space_packet.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c src/space_packet.c -o $(OBJ_PATH)
$(LIB_PATH): $(OBJ_PATH)
mkdir -p $(dir $@)
$(AR) rcs $(LIB_PATH) $(OBJ_PATH)
example: $(EXAMPLE_PATH)
$(EXAMPLE_PATH): lib examples/main.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -Iinclude examples/main.c $(LIB_PATH) -o $(EXAMPLE_PATH)
ctest: $(CTEST_PATH)
$(CTEST_PATH): lib tests/unit_tests.c tests/test_space_packet.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -Iinclude tests/unit_tests.c tests/test_space_packet.c $(LIB_PATH) -o $(CTEST_PATH)
test: ctest
./$(CTEST_PATH)
coverage-html:
bash tools/coverage_html.sh
clean:
rm -rf $(BUILD_DIR)
.PHONY: all lib example test ctest coverage-html ci clean install