-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (80 loc) · 2.7 KB
/
Makefile
File metadata and controls
101 lines (80 loc) · 2.7 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
CC=clang
CFLAGS=-Wall -Werror
LCUNIT=-lcunit
LIBMATH=-lm
LPTHREAD=-lpthread
OBJECTS=objects
HELP=help
SRC=src
# Détecter l'OS
OS := $(shell uname)
ifeq ($(OS), Darwin)
INCLUDES=-I/opt/homebrew/include
LIBS=-L/opt/homebrew/lib
else
INCLUDES =
LIBS =
endif
# Pour ne pas imprimer les commandes
.SILENT:
main: main.o vector.o matrix.o file.o lstsq.o qr.o matrix_th.o vector_th.o lstsq_th.o sparse_matrix.o
$(CC) -o $@ $(patsubst %, $(OBJECTS)/%, $^) $(LIBMATH) $(INCLUDES) $(LIBS) $(LPTHREAD)
echo "Compiled main successfully."
generator_matrix: matrix.o vector.o file.o sparse_matrix.o
$(CC) $(CFLAGS) -o $@ $(HELP)/$@.c $(patsubst %, $(OBJECTS)/%, $^) $(LIBMATH)
./$@
generator_vector: matrix.o vector.o file.o
$(CC) $(CFLAGS) -o $@ $(HELP)/$@.c $(patsubst %, $(OBJECTS)/%, $^) $(LIBMATH)
./$@
benchmark: tests/benchmark.c vector.o matrix.o lstsq.o qr.o matrix_th.o vector_th.o
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ tests/$@.c $(patsubst %, $(OBJECTS)/%, $(filter-out $<,$^)) $(LIBMATH) $(INCLUDES) $(LIBS) $(LPTHREAD)
echo "Compiled benchmark successfully."
bash ./test-performance/scripts/run_benchmark.sh
main.o: $(SRC)/main.c headers/vector.h headers/matrix.h headers/file.h headers/lstsq.h headers/qr.h headers/sparse_matrix.h
echo "Compiling main..."
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ -c $<
vector.o: $(SRC)/vector.c
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ -c $<
vector_th.o: $(SRC)/vector_th.c
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ -c $<
matrix.o: $(SRC)/matrix.c
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ -c $<
sparse_matrix.o: $(SRC)/sparse_matrix.c
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ -c $<
matrix_th.o: $(SRC)/matrix_th.c
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ -c $<
file.o : $(SRC)/file.c
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ -c $<
qr.o: $(SRC)/qr.c
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ -c $<
lstsq.o: $(SRC)/lstsq.c
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ -c $<
lstsq_th.o: $(SRC)/lstsq_th.c
$(CC) $(CFLAGS) -o $(OBJECTS)/$@ -c $<
compile_test: tests/test.c vector.o matrix.o file.o lstsq.o qr.o matrix_th.o vector_th.o lstsq_th.o sparse_matrix.o
echo "Compiling test..."
$(CC) $(CFLAGS) -o test tests/test.c $(patsubst %, $(OBJECTS)/%, $(filter-out $<,$^)) $(INCLUDES) $(LIBS) $(LCUNIT) $(LIBMATH) $(LPTHREAD)
echo "Compiled test successfully."
test: compile_test
./test
valgrind: compile_test
valgrind --error-exitcode=1 --leak-check=full ./test
.PHONY: clean
clean:
rm -f objects/*.o
rm -f main
rm -f test
rm -f generator_matrix
rm -f generator_vector
rm -f approximation.pdf
rm -f vector_a.bin
rm -f vector_b.bin
rm -f matrix_A.bin
rm -f vector_A.bin
rm -f double_A.bin
rm -f sparse_big.bin
rm -f sparse_empty.bin
rm -f sparse_small_A.bin
rm -f coef.bin
rm -f objects/benchmark
rm -rf test-performance/performance-data