-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
78 lines (60 loc) · 2.03 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
SRCS := tests/cobs_encode_max_c.c \
tests/test_cobs_encode_max.cc \
tests/test_cobs_encode.cc \
tests/test_cobs_encode_inc.cc \
tests/test_cobs_encode_tinyframe.cc \
tests/test_cobs_decode.cc \
tests/test_cobs_decode_inc.cc \
tests/test_cobs_decode_tinyframe.cc \
tests/test_many_random_payloads.cc \
tests/test_paper_figures.cc \
tests/test_wikipedia.cc \
tests/unittest_main.cc
BUILD_DIR := build
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
OS := $(shell uname)
COMPILER_VERSION := $(shell $(CXX) --version)
CFLAGS = --std=c99
CXXFLAGS = --std=c++20
CPPFLAGS += -MMD -MP -Os -g
ifeq ($(OS),Linux)
ifeq ($(COBS_LINUXARCH),32)
CPPFLAGS += -m32
LDFLAGS += -m32
endif
endif
CPPFLAGS += -Wall -Werror -Wextra
ifneq '' '$(findstring clang,$(COMPILER_VERSION))'
CPPFLAGS += -Weverything \
-Wno-unknown-warning-option \
-Wno-unsafe-buffer-usage \
-Wno-poison-system-directories \
-Wno-format-pedantic \
-Wno-c++98-compat-bind-to-temporary-copy \
-Wno-pre-c++20-compat-pedantic \
-Wno-switch-default
CFLAGS += -Wno-declaration-after-statement
else
CPPFLAGS += -Wconversion
endif
CPPFLAGS += -Wno-c++98-compat -Wno-padded
ifdef COBS_SANITIZER
CPPFLAGS += -fsanitize=$(COBS_SANITIZER) -fsanitize-ignorelist=sanitize-ignorelist.txt
LDFLAGS += -fsanitize=$(COBS_SANITIZER) -fsanitize-ignorelist=sanitize-ignorelist.txt
endif
$(BUILD_DIR)/cobs_unittests: $(OBJS) $(BUILD_DIR)/cobs.c.o Makefile
$(CXX) $(LDFLAGS) $(OBJS) $(BUILD_DIR)/cobs.c.o -o $@
$(BUILD_DIR)/cobs.c.o: cobs.c cobs.h Makefile
mkdir -p $(dir $@) && $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/%.c.o: %.c Makefile
mkdir -p $(dir $@) && $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/%.cc.o: %.cc Makefile
mkdir -p $(dir $@) && $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
$(BUILD_DIR)/cobs_unittests.timestamp: $(BUILD_DIR)/cobs_unittests
$(BUILD_DIR)/cobs_unittests -m && touch $(BUILD_DIR)/cobs_unittests.timestamp
.PHONY: clean
clean:
$(RM) -r $(BUILD_DIR)
.DEFAULT_GOAL := $(BUILD_DIR)/cobs_unittests.timestamp
-include $(DEPS)