-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
133 lines (104 loc) · 5.56 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
SRC_PREFIX=src/
BIN_PREFIX=bin/
LIBS_PREFIX=.libs/
OBJS_PREFIX=.objs/
CC=gcc
CFLAGS=-g -Wall -Wextra -std=c99 -O3 -I$(SRC_PREFIX)macro/
all: $(BIN_PREFIX)test
MATRIX_SRC_PREFIX=$(SRC_PREFIX)matrix/
MATRIX_SRC=$(shell find $(MATRIX_SRC_PREFIX) -maxdepth 1 -name '*.c')
MATRIX_OBJS_PREFIX=$(OBJS_PREFIX)matrix/
MATRIX_OBJS=$(patsubst $(MATRIX_SRC_PREFIX)%.c,$(MATRIX_OBJS_PREFIX)%.o,$(MATRIX_SRC))
MATRIX_LIB_PREFIX=$(LIBS_PREFIX)matrix/
MATRIX_LIB=$(MATRIX_LIB_PREFIX)matrix.a
$(MATRIX_LIB): $(MATRIX_OBJS)
mkdir -p $(MATRIX_LIB_PREFIX)
ar rcs $@ $^
$(MATRIX_OBJS_PREFIX)%.o: $(MATRIX_SRC_PREFIX)%.c $(MATRIX_SRC_PREFIX)%.h
mkdir -p $(MATRIX_OBJS_PREFIX)
$(CC) $(CFLAGS) -c $< -o $@
UTILS_SRC_PREFIX=$(SRC_PREFIX)utils/
UTILS_SRC=$(shell find $(UTILS_SRC_PREFIX) -maxdepth 1 -name '*.c')
UTILS_OBJS_PREFIX=$(OBJS_PREFIX)utils/
UTILS_OBJS=$(patsubst $(UTILS_SRC_PREFIX)%.c,$(UTILS_OBJS_PREFIX)%.o,$(UTILS_SRC))
UTILS_LIB_PREFIX=$(LIBS_PREFIX)utils/
UTILS_LIB=$(UTILS_LIB_PREFIX)utils.a
$(UTILS_LIB): $(UTILS_OBJS)
mkdir -p $(UTILS_LIB_PREFIX)
ar rcs $@ $^
$(UTILS_OBJS_PREFIX)%.o: $(UTILS_SRC_PREFIX)%.c $(UTILS_SRC_PREFIX)%.h
mkdir -p $(UTILS_OBJS_PREFIX)
$(CC) $(CFLAGS) -I$(MATRIX_SRC_PREFIX) -c $< -o $@
VALIDATION_SRC_PREFIX=$(SRC_PREFIX)validation/
VALIDATION_SRC=$(shell find $(VALIDATION_SRC_PREFIX) -maxdepth 1 -name '*.c')
VALIDATION_OBJS_PREFIX=$(OBJS_PREFIX)validation/
VALIDATION_OBJS=$(patsubst $(VALIDATION_SRC_PREFIX)%.c,$(VALIDATION_OBJS_PREFIX)%.o,$(VALIDATION_SRC))
VALIDATION_LIB_PREFIX=$(LIBS_PREFIX)validation/
VALIDATION_LIB=$(VALIDATION_LIB_PREFIX)validation.a
$(VALIDATION_LIB): $(VALIDATION_OBJS)
mkdir -p $(VALIDATION_LIB_PREFIX)
ar rcs $@ $^
$(VALIDATION_OBJS_PREFIX)%.o: $(VALIDATION_SRC_PREFIX)%.c $(VALIDATION_SRC_PREFIX)%.h
mkdir -p $(VALIDATION_OBJS_PREFIX)
$(CC) $(CFLAGS) -I$(MATRIX_SRC_PREFIX) -c $< -o $@
MATRIX_ALGO_SRC_PREFIX=$(SRC_PREFIX)matrix_algo/
MATRIX_ALGO_SRC=$(shell find $(MATRIX_ALGO_SRC_PREFIX) -maxdepth 1 -name '*.c')
MATRIX_ALGO_OBJS_PREFIX=$(OBJS_PREFIX)matrix_algo/
MATRIX_ALGO_OBJS=$(patsubst $(MATRIX_ALGO_SRC_PREFIX)%.c,$(MATRIX_ALGO_OBJS_PREFIX)%.o,$(MATRIX_ALGO_SRC))
MATRIX_ALGO_LIB_PREFIX=$(LIBS_PREFIX)matrix_algo/
MATRIX_ALGO_LIB=$(MATRIX_ALGO_LIB_PREFIX)matrix_algo.a
$(MATRIX_ALGO_LIB): $(MATRIX_ALGO_OBJS)
mkdir -p $(MATRIX_ALGO_LIB_PREFIX)
ar rcs $@ $^
$(MATRIX_ALGO_OBJS_PREFIX)%.o: $(MATRIX_ALGO_SRC_PREFIX)%.c
mkdir -p $(MATRIX_ALGO_OBJS_PREFIX)
$(CC) $(CFLAGS) -I$(MATRIX_SRC_PREFIX) -c $< -o $@
DEFLATION_SRC_PREFIX=$(SRC_PREFIX)deflation/
DEFLATION_SRC=$(shell find $(DEFLATION_SRC_PREFIX) -maxdepth 1 -name '*.c')
DEFLATION_OBJS_PREFIX=$(OBJS_PREFIX)deflation/
DEFLATION_OBJS=$(patsubst $(DEFLATION_SRC_PREFIX)%.c,$(DEFLATION_OBJS_PREFIX)%.o,$(DEFLATION_SRC))
DEFLATION_LIB_PREFIX=$(LIBS_PREFIX)deflation/
DEFLATION_LIB=$(DEFLATION_LIB_PREFIX)deflation.a
$(DEFLATION_LIB): $(DEFLATION_OBJS)
mkdir -p $(DEFLATION_LIB_PREFIX)
ar rcs $@ $^
$(DEFLATION_OBJS_PREFIX)%.o: $(DEFLATION_SRC_PREFIX)%.c $(DEFLATION_SRC_PREFIX)%.h
mkdir -p $(DEFLATION_OBJS_PREFIX)
$(CC) $(CFLAGS) -I$(MATRIX_SRC_PREFIX) -I$(MATRIX_ALGO_SRC_PREFIX) -I$(UTILS_SRC_PREFIX) -c $< -o $@
SECULAR_EQUATION_SRC_PREFIX=$(SRC_PREFIX)secular_equation/
SECULAR_EQUATION_SRC=$(shell find $(SECULAR_EQUATION_SRC_PREFIX) -maxdepth 1 -name '*.c')
SECULAR_EQUATION_OBJS_PREFIX=$(OBJS_PREFIX)secular_equation/
SECULAR_EQUATION_OBJS=$(patsubst $(SECULAR_EQUATION_SRC_PREFIX)%.c,$(SECULAR_EQUATION_OBJS_PREFIX)%.o,$(SECULAR_EQUATION_SRC))
SECULAR_EQUATION_LIB_PREFIX=$(LIBS_PREFIX)secular_equation/
SECULAR_EQUATION_LIB=$(SECULAR_EQUATION_LIB_PREFIX)secular_equation.a
$(SECULAR_EQUATION_LIB): $(SECULAR_EQUATION_OBJS)
mkdir -p $(SECULAR_EQUATION_LIB_PREFIX)
ar rcs $@ $^
$(SECULAR_EQUATION_OBJS_PREFIX)%.o: $(SECULAR_EQUATION_SRC_PREFIX)%.c $(SECULAR_EQUATION_SRC_PREFIX)%.h
mkdir -p $(SECULAR_EQUATION_OBJS_PREFIX)
$(CC) $(CFLAGS) -I$(MATRIX_SRC_PREFIX) -I$(UTILS_SRC_PREFIX) -c $< -o $@
DIVIDE_AND_CONQUER_SRC_PREFIX=$(SRC_PREFIX)divide_and_conquer/
DIVIDE_AND_CONQUER_SRC=$(shell find $(DIVIDE_AND_CONQUER_SRC_PREFIX) -maxdepth 1 -name '*.c')
DIVIDE_AND_CONQUER_OBJS_PREFIX=$(OBJS_PREFIX)divide_and_conquer/
DIVIDE_AND_CONQUER_OBJS=$(patsubst $(DIVIDE_AND_CONQUER_SRC_PREFIX)%.c,$(DIVIDE_AND_CONQUER_OBJS_PREFIX)%.o,$(DIVIDE_AND_CONQUER_SRC))
DIVIDE_AND_CONQUER_LIB_PREFIX=$(LIBS_PREFIX)divide_and_conquer/
DIVIDE_AND_CONQUER_LIB=$(DIVIDE_AND_CONQUER_LIB_PREFIX)divide_and_conquer.a
$(DIVIDE_AND_CONQUER_LIB): $(DIVIDE_AND_CONQUER_OBJS)
mkdir -p $(DIVIDE_AND_CONQUER_LIB_PREFIX)
ar rcs $@ $^
$(DIVIDE_AND_CONQUER_OBJS_PREFIX)%.o: $(DIVIDE_AND_CONQUER_SRC_PREFIX)%.c $(DIVIDE_AND_CONQUER_SRC_PREFIX)%.h
mkdir -p $(DIVIDE_AND_CONQUER_OBJS_PREFIX)
$(CC) $(CFLAGS) -I$(MATRIX_SRC_PREFIX) -I$(UTILS_SRC_PREFIX) -I$(MATRIX_ALGO_SRC_PREFIX) -I$(DEFLATION_SRC_PREFIX) -I$(SECULAR_EQUATION_SRC_PREFIX) -c $< -o $@
TEST_SRC_PREFIX=$(SRC_PREFIX)
TEST_SRC=$(shell find $(TEST_SRC_PREFIX) -maxdepth 1 -name '*.c')
TEST_OBJS_PREFIX=$(OBJS_PREFIX)
TEST_OBJS=$(patsubst $(TEST_SRC_PREFIX)%.c,$(TEST_OBJS_PREFIX)%.o,$(TEST_SRC))
$(TEST_OBJS_PREFIX)%.o: $(TEST_SRC_PREFIX)%.c
mkdir -p $(TEST_OBJS_PREFIX)
$(CC) $(CFLAGS) -I$(MATRIX_SRC_PREFIX) -I$(UTILS_SRC_PREFIX) -I$(VALIDATION_SRC_PREFIX) -I$(DIVIDE_AND_CONQUER_SRC_PREFIX) -I$(MATRIX_ALGO_SRC_PREFIX) -I$(DEFLATION_SRC_PREFIX) -I$(SECULAR_EQUATION_SRC_PREFIX) -c $< -o $@
$(BIN_PREFIX)test: $(TEST_OBJS) $(MATRIX_LIB) $(UTILS_LIB) $(VALIDATION_LIB) $(DIVIDE_AND_CONQUER_LIB) $(DEFLATION_LIB) $(SECULAR_EQUATION_LIB) $(MATRIX_ALGO_LIB)
mkdir -p $(BIN_PREFIX)
$(CC) $(CFLAGS) $^ -o $@ -lm
.PHONY: clean
clean:
rm -rf $(BIN_PREFIX) $(OBJS_PREFIX) $(LIBS_PREFIX)