-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (63 loc) · 1.82 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
CC = g++
RM ?= rm -f
SRC_DIR = source
OBJ_DIR = build
INCLUDE_DIR = include
TESTS_DIR = tests
BIN_DIR = .
MAIN = $(SRC_DIR)/main.cpp
MAINOBJ = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(MAIN))
SRC = $(SRC_DIR)/lexer.cpp \
$(SRC_DIR)/parser.cpp \
$(SRC_DIR)/nodes.cpp \
$(SRC_DIR)/visitor.cpp \
$(SRC_DIR)/expression_nodes.cpp \
$(SRC_DIR)/evaluate_expression.cpp \
$(SRC_DIR)/systemcalls.cpp
SRCOBJ = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC))
LIBSRC =
LIBOBJ = $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(LIBSRC))
SRC_TEST =
OBJ_TEST = $(patsubst $(TESTS_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC_TEST))
CFLAGS = -Wall -Wextra -std=c++17
LDLIBS = -lm
CPPFLAGS = -iquote ./$(INCLUDE_DIR)
CRITFLAGS = -lcriterion
GCOVRFLAGS = --coverage
NAME = $(BIN_DIR)/shukascript
TEST_NAME = $(BIN_DIR)/unit_tests
all: $(NAME)
$(NAME): $(LIBOBJ) $(MAINOBJ) $(SRCOBJ) | $(BIN_DIR)
$(CC) $(LIBOBJ) $(MAINOBJ) $(SRCOBJ) -o $(NAME) \
$(CFLAGS) $(LDLIBS) $(CPPFLAGS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o: $(TESTS_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
clean:
$(RM) $(OBJ_DIR)/*.o
fclean: clean
$(RM) $(NAME) $(TEST_NAME)
re: fclean all
debug: CFLAGS += -ggdb3
debug: re
asan: CC = clang -fsanitize=address
asan: re
$(TEST_NAME): $(OBJ_TEST) $(LIBOBJ) $(SRCOBJ) | $(BIN_DIR)
$(CC) -o $(TEST_NAME) $(CFLAGS) $(CPPFLAGS) \
$(OBJ_TEST) $(SRCOBJ) $(LIBOBJ) $(LDFLAGS) $(LDLIB) \
$(CRITFLAGS) $(GCOVRFLAGS) $(LDLIBS)
tests_run: $(TEST_NAME)
./$(TEST_NAME)
tests_clean:
$(RM) $(OBJ_DIR)/*.gcda
$(RM) $(OBJ_DIR)/*.gcno
$(RM) coverage*
$(RM) $(TEST_NAME)
coverage:
gcovr --html-details coverage && firefox coverage
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
$(BIN_DIR):
mkdir -p $(BIN_DIR)
.PHONY: all clean fclean re debug asan tests_run coverage tests_clean