-
Notifications
You must be signed in to change notification settings - Fork 0
/
bak.Makefile
120 lines (98 loc) · 3.87 KB
/
bak.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# These will be set from the outside
TARGET?=zero
SOURCES?=$(shell find src -type f -name '*.cpp' -o -name '*.c')
TOOLCHAIN_NAME?=gcc-11
TOOLCHAIN_CONFIG?=release
STATIC_LIBCPP?=0
VERBOSE?=0
LTO?=0
UNITY_BUILD?=0
BUILD_TESTS?=0
BUILD_EXAMPLES?=0
BENCHMARK?=0
CXXSTD?=-std=c++2b
# -------------------------------------------------------------------------- Configure build options
ifneq ("$(BUILD_TESTS)", "0")
SOURCES+= $(shell find testcases -type f -name '*.cpp' -o -name '*.c')
CPPFLAGS+= -DCATCH_BUILD -DCATCH_CONFIG_PREFIX_ALL -DCATCH_CONFIG_COLOUR_ANSI -isystemtestcases
endif
ifneq ("$(BUILD_EXAMPLES)", "0")
SOURCES+= $(shell find examples -type f -name '*.cpp' -o -name '*.c')
CPPFLAGS+= -DBUILD_EXAMPLES -Wno-unused-function
endif
ifneq ("$(BENCHMARK)", "0")
SOURCES+= $(shell find benchmark -type f -name '*.cpp' -o -name '*.c')
CPPFLAGS+= -DBENCHMARK_BUILD
LDFLAGS+= -L/usr/local/lib -lbenchmark
endif
BOOST_DEFINES:=-DBOOST_NO_TYPEID -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_ASIO_SEPARATE_COMPILATION -DBOOST_ASIO_NO_DEPRECATED -DBOOST_ASIO_DISABLE_VISIBILITY
DEFINES:=$(BOOST_DEFINES) -DUSE_ASIO
WARNINGS:=-Wno-variadic-macros
# Configure includes
INCDIRS:=-Isrc -isystemcontrib/include -isystem/usr/local/include
LDFLAGS+=-lunifex -lpthread -lssl -lcrypto
CFLAGS+= $(INCDIRS) $(DEFINES)
CXXFLAGS+= -DFMT_HEADER_ONLY $(INCDIRS) $(DEFINES) $(WARNINGS)
# -------------------------------------------------------- Check that we're in the correct directory
# Every shell command is executed in the same invocation
MKFILE_PATH:=$(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR:=$(patsubst %/,%,$(dir $(MKFILE_PATH)))
ifneq ("$(MKFILE_DIR)", "$(CURDIR)")
$(error Should run from $(MKFILE_DIR) not $(CURDIR))
endif
# -------------------------------------------------- Include makefile environment and standard rules
include project-config/env.inc.makefile
-include $(DEP_FILES)
# -------------------------------------------------------------------------------------------- Rules
# Standard Rules
.PHONY: clean info test deps test-scan module-deps coverage
all: $(TARGETDIR)/$(TARGET)
test: | all
$(TARGETDIR)/$(TARGET) src/main.cpp
$(TARGETDIR)/$(TARGET): $(OBJECTS)
@echo "$(BANNER)link $(TARGET)$(BANEND)"
mkdir -p $(dir $@)
$(CC) -o $@ $^ $(LDFLAGS_F)
@$(RECIPETAIL)
clean:
@echo rm -rf $(BUILDDIR) $(TARGETDIR)
@rm -rf $(BUILDDIR) $(TARGETDIR)
coverage: $(TARGETDIR)/$(TARGET)
@echo "running target"
$(TARGETDIR)/$(TARGET)
@echo "generating coverage"
gcovr --gcov-executable $(GCOV) --root . --object-directory $(BUILDDIR) --exclude contrib --exclude testcases
coverage_html: $(TARGETDIR)/$(TARGET)
@echo "running target"
$(TARGETDIR)/$(TARGET)
@echo "running lcov to generate coverage"
lcov --gcov-tool $(GCOV) -c --directory $(BUILDDIR) --output-file $(TARGETDIR)/app_info.info
genhtml $(TARGETDIR)/app_info.info --output-directory doc/html/coverage
llvm_coverage_html: $(TARGETDIR)/$(TARGET)
@echo "running target"
$(TARGETDIR)/$(TARGET)
@echo "generating coverage..."
$(LLVM_PROFDATA) merge -o default.prof default.profraw
$(LLVM_COV) export -format lcov -instr-profile default.prof $(TARGETDIR)/$(TARGET) > $(TARGETDIR)/app_info.info
rm -f default.profraw default.prof
genhtml $(TARGETDIR)/app_info.info --output-directory doc/html/coverage
info:
@echo "CURDIR: $(CURDIR)"
@echo "MKFILE_DIR: $(MKFILE_DIR)"
@echo "TARGET: $(TARGET)"
@echo "TARGETDIR: $(TARGETDIR)"
@echo "BUILDDIR: $(BUILDDIR)"
@echo "COMP_DATABASE: $(COMP_DATABASE)"
@echo "CONFIG: $(TOOLCHAIN_CONFIG)"
@echo "VERBOSE: $(VERBOSE)"
@echo "CC: $(CC)"
@echo "CXX: $(CXX)"
@echo "CFLAGS: $(CFLAGS_F)"
@echo "CXXFLAGS: $(CXXFLAGS_F)"
@echo "LDFLAGS: $(LDFLAGS_F)"
@echo "SOURCES:"
@echo "$(SOURCES)" | sed 's,^, ,'
@echo "OBJECTS:"
@echo "$(OBJECTS)" | sed 's,^, ,'
@echo "DEP_FILES:"
@echo "$(DEP_FILES)" | sed 's,^, ,'