1
1
# Define the compiler and its flags during compilation
2
2
CC = g++
3
-
4
- FLAGS = -g -Wall -std=c++11 -I $(INC_DIR ) -O3
3
+ FLAGS = -g -Wall -std=c++11 -I $(INC_DIR ) -O3 -fsanitize=address
5
4
6
5
# Setup constants for code directories
7
6
INC_DIR = include
@@ -10,76 +9,90 @@ OBJ_DIR = build
10
9
EXE_DIR = bin
11
10
TST_DIR = tests
12
11
13
- # make all builds evrything
14
- all : build bin $(EXE_DIR ) /graph_node_test $(EXE_DIR ) /graph_test $(EXE_DIR ) /test_distance $(EXE_DIR ) /test_data_vectors $(EXE_DIR ) /test_recall $(EXE_DIR ) /main
12
+ # make all builds everything
13
+ all : code test
14
+
15
+ # Compile only the main code
16
+ code : build bin $(EXE_DIR ) /main
17
+
18
+ # Compile all test executables
19
+ test : build bin $(EXE_DIR ) /graph_node_test $(EXE_DIR ) /graph_test $(EXE_DIR ) /test_distance $(EXE_DIR ) /test_data_vectors $(EXE_DIR ) /test_recall
20
+ @echo " Running all tests:"
21
+ $(EXE_DIR ) /graph_node_test
22
+ $(EXE_DIR ) /graph_test
23
+ $(EXE_DIR ) /test_distance
24
+ $(EXE_DIR ) /test_data_vectors
25
+ $(EXE_DIR ) /test_recall
26
+
27
+ # Run tests with valgrind
28
+ valgrind : test
29
+ valgrind --leak-check=full $(EXE_DIR ) /graph_node_test
30
+ valgrind --leak-check=full $(EXE_DIR ) /graph_test
31
+ valgrind --leak-check=full $(EXE_DIR ) /test_distance
32
+ valgrind --leak-check=full $(EXE_DIR ) /test_data_vectors
33
+ valgrind --leak-check=full $(EXE_DIR ) /test_recall
34
+
35
+ # Define the rule for the main executable
36
+ $(EXE_DIR ) /main : $(OBJ_DIR ) /main.o $(OBJ_DIR ) /read_vectors.o $(OBJ_DIR ) /distance_functions.o
37
+ $(CC ) $(FLAGS ) -o $(EXE_DIR ) /main $(OBJ_DIR ) /main.o $(OBJ_DIR ) /read_vectors.o $(OBJ_DIR ) /distance_functions.o
38
+
39
+ $(OBJ_DIR ) /main.o : main.cpp $(INC_DIR ) /DataStructures/Graph/graph.h $(INC_DIR ) /read_data.h $(INC_DIR ) /DataStructures/DataVector/DataVector.h
40
+ $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /main.o -c main.cpp
41
+
42
+ # Rule to create read_vectors.o
43
+ $(OBJ_DIR ) /read_vectors.o : $(SRC_DIR ) /read_vectors.cpp $(INC_DIR ) /read_data.h $(INC_DIR ) /DataStructures/DataVector/DataVector.h
44
+ $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /read_vectors.o -c $(SRC_DIR ) /read_vectors.cpp
45
+
46
+ # Rule to create distance_functions.o
47
+ $(OBJ_DIR ) /distance_functions.o : $(SRC_DIR ) /distance_functions.cpp $(INC_DIR ) /distance.h
48
+ $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /distance_functions.o -c $(SRC_DIR ) /distance_functions.cpp
15
49
50
+ # Test executables and object file rules
16
51
17
- # Graph node test executable is being compiled here
18
- $(EXE_DIR ) /graph_node_test : $(OBJ_DIR ) /graph_node_test.o $( INC_DIR ) /DataStructures/Graph/graph_node.h $( INC_DIR ) /DataStructures/Graph/graph.h
52
+ # Build graph_node_test executable
53
+ $(EXE_DIR ) /graph_node_test : $(OBJ_DIR ) /graph_node_test.o
19
54
$(CC ) $(FLAGS ) -o $(EXE_DIR ) /graph_node_test $(OBJ_DIR ) /graph_node_test.o
20
55
21
- $(OBJ_DIR ) /graph_node_test.o : $(TST_DIR ) /graph_node_test.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /DataStructures/Graph/graph_node.h $( INC_DIR ) /DataStructures/Graph/graph.h
56
+ $(OBJ_DIR ) /graph_node_test.o : $(TST_DIR ) /graph_node_test.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /DataStructures/Graph/graph_node.h
22
57
$(CC ) $(FLAGS ) -o $(OBJ_DIR ) /graph_node_test.o -c $(TST_DIR ) /graph_node_test.cc
23
58
24
- # Graph test executable is being compiled here
25
- $(EXE_DIR ) /graph_test : $(OBJ_DIR ) /graph_test.o $( INC_DIR ) /DataStructures/Graph/graph.h
59
+ # Build graph_test executable
60
+ $(EXE_DIR ) /graph_test : $(OBJ_DIR ) /graph_test.o
26
61
$(CC ) $(FLAGS ) -o $(EXE_DIR ) /graph_test $(OBJ_DIR ) /graph_test.o
27
62
28
63
$(OBJ_DIR ) /graph_test.o : $(TST_DIR ) /graph_test.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /DataStructures/Graph/graph.h
29
64
$(CC ) $(FLAGS ) -o $(OBJ_DIR ) /graph_test.o -c $(TST_DIR ) /graph_test.cc
30
65
31
-
32
- # Test distance executable is being compiled here
33
- $(EXE_DIR ) /test_distance : $(OBJ_DIR ) /test_distance.o $(OBJ_DIR ) /distance_functions.o $(INC_DIR ) /DataStructures/Graph/graph.h $(INC_DIR ) /distance.h
66
+ # Build test_distance executable
67
+ $(EXE_DIR ) /test_distance : $(OBJ_DIR ) /test_distance.o $(OBJ_DIR ) /distance_functions.o
34
68
$(CC ) $(FLAGS ) -o $(EXE_DIR ) /test_distance $(OBJ_DIR ) /test_distance.o $(OBJ_DIR ) /distance_functions.o
35
69
36
- $(OBJ_DIR ) /test_distance.o : $(TST_DIR ) /test_distance.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /DataStructures/Graph/graph .h
70
+ $(OBJ_DIR ) /test_distance.o : $(TST_DIR ) /test_distance.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /distance .h
37
71
$(CC ) $(FLAGS ) -o $(OBJ_DIR ) /test_distance.o -c $(TST_DIR ) /test_distance.cc
38
72
39
- $(OBJ_DIR ) /distance_functions.o : $(SRC_DIR ) /distance_functions.cpp $(INC_DIR ) /distance.h
40
- $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /distance_functions.o -c $(SRC_DIR ) /distance_functions.cpp
41
-
42
- # read_vector executable is being compiled here
43
- $(EXE_DIR ) /test_data_vectors : $(OBJ_DIR ) /test_data_vectors.o $(OBJ_DIR ) /read_vectors.o $(INC_DIR ) /DataStructures/DataVector/DataVector.h $(INC_DIR ) /read_data.h
73
+ # Build test_data_vectors executable
74
+ $(EXE_DIR ) /test_data_vectors : $(OBJ_DIR ) /test_data_vectors.o $(OBJ_DIR ) /read_vectors.o
44
75
$(CC ) $(FLAGS ) -o $(EXE_DIR ) /test_data_vectors $(OBJ_DIR ) /test_data_vectors.o $(OBJ_DIR ) /read_vectors.o
45
76
46
- $(OBJ_DIR ) /test_data_vectors.o : $(TST_DIR ) /test_data_vectors.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /DataStructures/DataVector/DataVector .h
77
+ $(OBJ_DIR ) /test_data_vectors.o : $(TST_DIR ) /test_data_vectors.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /read_data .h
47
78
$(CC ) $(FLAGS ) -o $(OBJ_DIR ) /test_data_vectors.o -c $(TST_DIR ) /test_data_vectors.cc
48
79
49
- # Testing Recall
50
- $(EXE_DIR ) /test_recall : $(OBJ_DIR ) /test_recall.o $( INC_DIR ) /Evaluation/recall.h
80
+ # Build test_recall executable
81
+ $(EXE_DIR ) /test_recall : $(OBJ_DIR ) /test_recall.o
51
82
$(CC ) $(FLAGS ) -o $(EXE_DIR ) /test_recall $(OBJ_DIR ) /test_recall.o
52
83
53
84
$(OBJ_DIR ) /test_recall.o : $(TST_DIR ) /test_recall.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /Evaluation/recall.h
54
85
$(CC ) $(FLAGS ) -o $(OBJ_DIR ) /test_recall.o -c $(TST_DIR ) /test_recall.cc
55
86
56
- # main files
57
- $(EXE_DIR ) /main : $(OBJ_DIR ) /main.o $(OBJ_DIR ) /read_vectors.o $(OBJ_DIR ) /distance_functions.o $(INC_DIR ) /DataStructures/Graph/graph.h $(INC_DIR ) /read_data.h $(INC_DIR ) /DataStructures/DataVector/DataVector.h $(INC_DIR ) /Algorithms/GreedySearch.h
58
- $(CC ) $(FLAGS ) -o $(EXE_DIR ) /main $(OBJ_DIR ) /main.o $(OBJ_DIR ) /read_vectors.o $(OBJ_DIR ) /distance_functions.o
59
-
60
- $(OBJ_DIR ) /main.o : main.cpp $(INC_DIR ) /DataStructures/Graph/graph.h $(INC_DIR ) /read_data.h $(INC_DIR ) /DataStructures/DataVector/DataVector.h
61
- $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /main.o -c main.cpp
62
-
63
- $(OBJ_DIR ) /read_vectors.o : $(SRC_DIR ) /read_vectors.cpp $(INC_DIR ) /read_data.h $(INC_DIR ) /DataStructures/DataVector/DataVector.h
64
- $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /read_vectors.o -c $(SRC_DIR ) /read_vectors.cpp
65
-
66
-
67
-
68
- # build directory creation
69
- # (every object file goes here)
87
+ # Directories creation
70
88
build :
71
- mkdir build
89
+ mkdir -p $( OBJ_DIR )
72
90
73
-
74
- # bin directory creation
75
- # (every executable file goes here)
76
91
bin :
77
- mkdir bin
78
-
92
+ mkdir -p $(EXE_DIR )
79
93
80
94
# Clean command to clean the workspace
81
95
.PHONY : clean
82
-
83
96
clean :
84
- rm -r -f bin
85
- rm -r -f build
97
+ rm -r -f $( EXE_DIR )
98
+ rm -r -f $( OBJ_DIR )
0 commit comments