-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (43 loc) · 1.46 KB
/
Makefile
File metadata and controls
59 lines (43 loc) · 1.46 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
54
55
56
57
58
59
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=c11
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 ctest
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
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -Iinclude tests/unit_tests.c $(LIB_PATH) -o $(CTEST_PATH)
coverage-html:
bash scripts/coverage_html.sh
ci:
bash scripts/coverage_html.sh
gcovr -r "$$PWD" --filter "$$PWD/src" --txt-summary --fail-under-line $(COVERAGE_MIN)
clean:
rm -rf $(BUILD_DIR)
install: lib
mkdir -p $(PREFIX)/lib $(PREFIX)/include
cp $(LIB_PATH) $(PREFIX)/lib/$(LIBNAME)
cp include/space_packet.h $(PREFIX)/include/
.PHONY: all lib example test ctest coverage-html ci clean install