-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·102 lines (52 loc) · 1.78 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
# Makefile for TP3
# by Lorenzo Carneiro Magalhaes
#* VARIABLES DECLARATION AND AMBIENT SETTING
CC = g++
CFLAGS = -std=c++17 -Wall -O3 -g
INCLUDE_DIR = include
BIN_DIR = bin
OBJ_DIR = obj
SRC_DIR = src
OUT_DIR = out
TESTS_DIR = src/tests
SOURCES := $(shell find $(SRC_DIR) -name '*.cpp')
OBJECTS := $(subst $(SRC_DIR),$(OBJ_DIR),$(SOURCES:%.cpp=%.o))
ANALISAMEM = $(BIN_DIR)/analisamem
EXE = $(BIN_DIR)/$(PROG_NAME)
PROG_NAME = main
#------------------------------------------------------------------------------------
#* TESTS
exectest: out bin
./$(BIN_DIR)/main -i $(TESTS_DIR)/input_05.txt -o $(OUT_DIR)/out.txt -t hash
diff $(OUT_DIR)/out.txt $(TESTS_DIR)/output_05.txt
./$(BIN_DIR)/main -i $(TESTS_DIR)/input_05.txt -o $(OUT_DIR)/out.txt -t tree
diff $(OUT_DIR)/out.txt $(TESTS_DIR)/output_05.txt
#* EXECUTES ALL
# generates exe file and generates perf log
all: out
@make -s clean bin exectest
#* COMPILE
# links objects and generates the executable
$(PROG_NAME): $(OBJECTS)
$(CC) $(CFLAGS) $(OBJ_DIR)/*.o -o $(BIN_DIR)/$@
# compiles single cpp file
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CC) -I $(INCLUDE_DIR) $(CFLAGS) -c $< -o $@
bin: $(PROG_NAME)
#* OTHER FUNCTIONS
# plot:
# gnuplot $(OUT_DIR)/*.gp
# analisamem:
# gcc $(C_INCLUDE) -g $(SRC_DIR)/analisamem.c $(SRC_DIR)/pilhaindexada.c -o $(BIN_DIR)/analisamem
# runs valgrind (for debug)
valgrind:
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt ./$(BIN_DIR)/main -i ent.txt -o $(OUT_DIR)/out.txt -t tree
#* AUXILIARY FUNCTIONS
# makes out dir
out:
@if test -d $(OUT_DIR); then rm -rf $(OUT_DIR); fi
@mkdir $(OUT_DIR)
#* CLEAN
# make the directories clean
clean:
@rm -rf *.out $(OBJ_DIR)/* $(EXE) -r out *.gp *.gpdat *.png bin/* valgrind-out.txt