-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
173 lines (114 loc) · 4.77 KB
/
Makefile
File metadata and controls
173 lines (114 loc) · 4.77 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
CATCH2_LIB_DIR?=$(CURDIR)/Catch2/build/src
mkfile_path := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
ROOT_DIR := $(shell cd $(shell dirname $(mkfile_path)); pwd)
BUILD_DIR := $(ROOT_DIR)/build
COVERAGE_DIR := $(BUILD_DIR)/coverage
# Target directories
SRC_DIR := $(ROOT_DIR)/src
OBJ_DIR := $(BUILD_DIR)/obj
BIN_DIR := $(BUILD_DIR)
INCLUDES := -I$(SRC_DIR) -I/usr/include/libdwarf -I$(ROOT_DIR)/CRCpp/inc
# External directories
CATCH2_DIR := $(ROOT_DIR)/Catch2
# Unit test directories
UT_SRC_DIR := $(ROOT_DIR)/unit-test
UT_OBJ_DIR := $(BUILD_DIR)/ut_obj
UT_OBJ_32BIT_DIR := $(BUILD_DIR)/ut_obj_32
UT_BIN_DIR := $(BUILD_DIR)
UT_INCLUDES := -I$(CATCH2_DIR)/extras
# Target files
EXE := $(BIN_DIR)/juicer
SRC := $(wildcard $(SRC_DIR)/*.cpp)
OBJ := $(SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
# Unit test files
UT_EXE := $(UT_BIN_DIR)/juicer-ut
UT_EXE_32BIT := $(UT_BIN_DIR)/juicer-ut-32
UT_SRC := $(wildcard $(UT_SRC_DIR)/*.cpp) $(filter-out $(SRC_DIR)/main.cpp, $(SRC))
UT_OBJ := $(UT_SRC:$(UT_SRC_DIR)/%.cpp=$(UT_OBJ_DIR)/%.o)
UT_OBJ := $(UT_OBJ:$(SRC_DIR)/%.cpp=$(UT_OBJ_DIR)/%.o)
UT_SRC_32 := $(wildcard $(UT_SRC_DIR)/test_file*.cpp)
UT_OBJ_32 := $(UT_SRC_32:$(UT_SRC_DIR)/test_file%.cpp=$(UT_OBJ_32BIT_DIR)/test_file%.o)
UT_OBJ_32 := $(UT_OBJ_32:$(UT_SRC_DIR)/test_file%.cpp=$(UT_OBJ_32BIT_DIR)/test_file%.o)
GIT_VERSION := "$(shell git describe --tags --abbrev=0)($(shell git rev-parse --short HEAD))"
# Set target flags
CPPFLAGS := -MMD -MP -std=c++17 -fmessage-length=0 $(INCLUDES)
CFLAGS := -Wall -g3 -DJUICER_VERSION=\"$(GIT_VERSION)\"
CFLAGS_32BIT := -Wall -g3 -m32
LDFLAGS := -Llib
LDLIBS := -lm -ldwarf -lsqlite3 -lelf -lcrypto
# Set unit test flags
UT_CPPFLAGS := $(CPPFLAGS) $(UT_INCLUDES)
UT_CFLAGS := $(CFLAGS) --coverage
UT_CFLAGS_32BIT := $(CFLAGS_32BIT) --coverage
UT_LDFLAGS := $(LDFLAGS) -L$(CATCH2_LIB_DIR)
UT_LDLIBS := $(LDLIBS) -lgcov -lCatch2Main -lCatch2
# Set tools
CC := g++
LD := g++
.PHONY: all clean run-tests coverage docs
# Target recipes
$(EXE): $(OBJ)
$(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(OBJ_DIR):
mkdir -p $@
# Unit test recipes
$(UT_EXE): $(UT_OBJ)
$(LD) $(UT_LDFLAGS) $^ $(UT_LDLIBS) -o $@
$(UT_EXE_32BIT): $(UT_OBJ_32)
$(UT_OBJ_DIR)/%.o: $(UT_SRC_DIR)/%.cpp | $(UT_OBJ_DIR)
$(CC) $(UT_CPPFLAGS) $(UT_CFLAGS) -c $< -o $@
$(UT_OBJ_DIR)/%.o: $(UT_SRC_DIR)/%.cpp | $(UT_OBJ_DIR)
$(CC) $(UT_CPPFLAGS) $(UT_CFLAGS) -c $< -o $@
$(UT_OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(UT_OBJ_DIR)
$(CC) $(UT_CPPFLAGS) $(UT_CFLAGS) -c $< -o $@
$(UT_OBJ_32BIT_DIR)/test_file%.o: $(UT_SRC_DIR)/test_file%.cpp | $(UT_OBJ_32BIT_DIR)
$(CC) $(UT_CPPFLAGS) $(UT_CFLAGS_32BIT) -c $< -o $@
$(UT_OBJ_DIR):
mkdir -p $@
$(UT_OBJ_32BIT_DIR):
mkdir -p $@
run-tests: build_catch2 $(UT_EXE_32BIT) | $(UT_EXE)
-(cd $(BUILD_DIR); $(UT_EXE))
build-tests: | $(UT_EXE)
coverage: $(COVERAGE_DIR)/index.html
# Configure the Catch2 project with CMake.
configure_catch2:
@echo "Creating build directory..."
@mkdir -p $(CATCH2_DIR)/build
@echo "Configuring project with CMake..."
@cd $(CATCH2_DIR)/build && cmake ..
# Build the Catch2 project.
build_catch2: configure_catch2
@echo "Building project..."
@$(MAKE) -C $(CATCH2_DIR)/build
$(COVERAGE_DIR)/index.html: | run-tests
mkdir -p $(COVERAGE_DIR)
(cd $(COVERAGE_DIR); gcovr $(ROOT_DIR) --root $(ROOT_DIR) --object-directory $(UT_OBJ_DIR) --filter $(ROOT_DIR)/src/ --html --html-details -o index.html)
all: build_catch2 $(EXE) $(UT_EXE) $(UT_EXE_32BIT)
clean:
@$(RM) -Rf $(BUILD_DIR)
-include $(UT_OBJ:.o=.d)
-include $(OBJ:.o=.d)
docker-ubuntu18-build:
@sudo docker build --no-cache -t juicer:ubuntu18 -f Dockerfile.ubuntu18 .
docker-ubuntu22-build:
@sudo docker build --no-cache -t juicer:ubuntu22 -f Dockerfile.ubuntu22 .
docker-ubuntu20-build:
@sudo docker build --no-cache -t juicer:ubuntu20 -f Dockerfile.ubuntu20 .
docker-ubuntu22-build-dev:
@sudo docker build --no-cache -t juicer-dev:ubuntu22 -f Dockerfile.ubuntu22.dev .
@sudo docker run -v .:/home/docker/juicer -it juicer-dev:ubuntu22 bash
docker-ubuntu20-build-dev:
@sudo docker build --no-cache -t juicer-dev:ubuntu20 -f Dockerfile.ubuntu20.dev .
@sudo docker run -v .:/home/docker/juicer -it juicer-dev:ubuntu20 bash
docker-ubuntu18-build-dev:
@sudo docker build --no-cache -t juicer-dev:ubuntu18 -f Dockerfile.ubuntu18 .
@sudo docker run -v .:/home/docker/juicer -it juicer-dev:ubuntu18 bash
check-format:
@python3 clang_format_all.py --config clang_format_all_config.yaml
docs:
@doxygen doxy_config
format:
@python3 clang_format_all.py --config clang_format_all_config_format.yaml