forked from charlesnicholson/nanocobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (55 loc) · 1.85 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
SRCS := tests/test_cobs_encode_max.cc \
tests/test_cobs_encode.cc \
tests/test_cobs_encode_inc.cc \
tests/test_cobs_encode_inplace.cc \
tests/test_cobs_decode.cc \
tests/test_cobs_decode_inplace.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++17
CPPFLAGS += -MMD -MP -Os -g
ifeq ($(OS),Linux)
ifeq ($(COBS_LINUXARCH),32)
CPPFLAGS += -m32
LDFLAGS += -m32
endif
endif
ifeq ($(COBS_SANITIZE),1)
CPPFLAGS_SAN += -fsanitize=undefined,address
LDFLAGS_SAN += -fsanitize=undefined,address
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
CFLAGS += -Wno-declaration-after-statement
else
CPPFLAGS += -Wconversion
endif
CPPFLAGS += -Wno-c++98-compat -Wno-padded
$(BUILD_DIR)/cobs_unittests: $(OBJS) $(BUILD_DIR)/cobs.c.o Makefile
$(CXX) $(LDFLAGS) $(LDFLAGS_SAN) $(OBJS) $(BUILD_DIR)/cobs.c.o -o $@
$(BUILD_DIR)/cobs.c.o: cobs.c cobs.h Makefile
mkdir -p $(dir $@) && $(CC) $(CPPFLAGS) $(CFLAGS) $(CPPFLAGS_SAN) -c $< -o $@
$(BUILD_DIR)/%.c.o: %.c Makefile
mkdir -p $(dir $@) && $(CC) $(CPPFLAGS) $(CFLAGS) $(CPPFLAGS_SAN) -c $< -o $@
$(BUILD_DIR)/%.cc.o: %.cc Makefile
mkdir -p $(dir $@) && $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CPPFLAGS_SAN) -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)