This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
117 lines (93 loc) · 3.5 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
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
###########################################################################
#
# "Simulační studie účinnosti zásad cache z pohledu globálních CDN"
# IMS projekt, FIT VUT 2024
# @author: onegen <xkrame00@stud.fit.vutbr.cz>
#
###########################################################################
TARGET = sim
ARC_NAME = 10_xkrame00
DOC_NAME = study
SRC_DIR = src
OBJ_DIR = obj
INCLUDE_DIR = include
DOC_DIR = doc
CPP = g++
CPPFLAGS = -std=c++20 -I$(INCLUDE_DIR) \
-isystem$(INCLUDE_DIR)/third-party -lsimlib
EXTRA_CPPFLAGS = -Wall -Wextra -Werror -pedantic \
-fdata-sections -ffunction-sections
RELEASE_CPPFLAGS = -DNDEBUG -O2 -march=native
DEBUG_CPPFLAGS = -g -Og -fsanitize=undefined
LINT_FLAGS = --format-style=file -fix-errors \
-checks="bugprone-*,google-*,performance-*,readability-*"
###########################################################################
INCLUDES := $(shell find $(INCLUDE_DIR) -name '*.hpp')
SRCS := $(shell find $(SRC_DIR) -name '*.cpp')
OBJS := $(SRCS:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
DOC = $(DOC_NAME).pdf
DOC_SRC = $(DOC_DIR)/$(DOC_NAME).typ
ARC_TAR = $(ARC_NAME).tar
ARC = $(ARC_TAR).gz
PIGZ := $(shell which pigz 2>/dev/null)
ifdef PIGZ
COMPRESSOR := pigz
else
COMPRESSOR := gzip
endif
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
###########################################################################
.PHONY: build debug run doc help clean lint format archive
build: EXTRA_CPPFLAGS += $(RELEASE_CPPFLAGS)
build: $(TARGET)
debug: EXTRA_CPPFLAGS += $(DEBUG_CPPFLAGS)
debug: $(TARGET)
run: $(TARGET)
./$(TARGET) $(ARGS)
archive: $(ARC)
$(OBJS): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp
@mkdir -p $(dir $@)
$(CPP) $(CPPFLAGS) $(EXTRA_CPPFLAGS) -c $< -o $@
$(TARGET): $(OBJS)
$(CPP) $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(SRCS) -o $(TARGET)
@echo "Simulation exe 'sim' compiled!"
@echo "Run with: 'make run' OR './sim'"
@echo " For usage info: 'make run -- --help' OR './sim --help'"
doc:
@if [ -f $(DOC_SRC) ]; then \
$(MAKE) $(DOC); \
else \
echo "Documentation source files not found included, skipping."; \
exit 0; \
fi
$(DOC): $(DOC_SRC)
typst compile $(DOC_SRC)
mv $(DOC_DIR)/$(DOC) $(DOC)
clean:
rm -f $(TARGET) $(ARC)
rm -rf $(OBJ_DIR)
format:
clang-format -i $(SRCS) $(INCLUDES)
lint:
clang-tidy $(SRCS) $(LINT_FLAGS) -- $(CPPFLAGS)
$(ARC_TAR): doc
tar -czf $(ARC_TAR) Makefile $(DOC) $(SRC_DIR) $(INCLUDE_DIR)
$(ARC): $(ARC_TAR)
$(COMPRESSOR) --best $(ARC_TAR)
help:
@echo "Simulační studie účinnosti zásad cache z pohledu globálních CDN"
@echo " IMS projekt, FIT VUT 2024/25"
@echo "@author onegen <xkrame00@vutbr.cz>"
@echo ""
@echo "Usage: make [TARGET]"
@echo "TARGETs:"
@echo " build compile and link the project (default)"
@echo " debug compile and link the project with debug flags"
@echo " run run the simulation, see: 'make run -- --help'"
@echo " clean clean objects and executables"
@echo " format run formatter (req. clang-format)"
@echo " lint run linter (req. clang-tidy)"
@echo " archive create a .tar.gz archive of this project"
@echo " help print this message"
%::
@true