-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (38 loc) · 1.38 KB
/
Copy pathMakefile
File metadata and controls
53 lines (38 loc) · 1.38 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
CC = gcc
CFLAGS = -O3 -Wall -mavx2 -mfma -flto -g -Wno-stringop-truncation
SRC_DIR = src
INC_DIR = include
BUILD_DIR = build
FTYPE ?= DOUBLE
VEC ?= EXPL
TIMER ?=
TIMER_FREQ ?= 1
DEFINE = -D$(FTYPE) -D$(VEC) -DTIMER_LOG_FREQ=$(TIMER_LOG_FREQ)
INCLUDE = -I$(INC_DIR) -I$(SRC_DIR)
LIBS = -lm
ifeq ($(TIMER), ON)
DEFINE += -DTIMER
endif
SOLVER_OBJS = solver.o momentum.o pressure.o output.o thread-array.o
UNIT_TEST_OBJS = unit-test.o momentum-test.o pressure-test.o
CONVERGENCE_TEST_OBJS = $(SOLVER_OBJS) convergence-test.o
solver: mkdir-build $(BUILD_DIR)/solver
#tests: mkdir-build $(BUILD_DIR)/unit-test $(BUILD_DIR)/convergence-test $(BUILD_DIR)/convergence-pressure-test
tests: mkdir-build $(BUILD_DIR)/convergence-test
mkdir-build:
mkdir -p $(BUILD_DIR)/objs
$(BUILD_DIR)/solver: $(addprefix $(BUILD_DIR)/objs/, $(SOLVER_OBJS) main.o)
$(CC) $^ $(LIBS) -o $@
$(BUILD_DIR)/unit-test: $(addprefix $(BUILD_DIR)/objs/, $(UNIT_TEST_OBJS))
$(CC) $^ $(LIBS) -o $@
$(BUILD_DIR)/convergence-test: $(addprefix $(BUILD_DIR)/objs/, $(CONVERGENCE_TEST_OBJS))
$(CC) $^ $(LIBS) -o $@
$(BUILD_DIR)/convergence-pressure-test: $(BUILD_DIR)/objs/convergence-pressure-test.o
$(CC) $^ $(LIBS) -o $@
$(BUILD_DIR)/objs/%.o: $(SRC_DIR)/%.c
$(CC) -c $^ $(CFLAGS) $(INCLUDE) $(DEFINE) -o $@
$(BUILD_DIR)/objs/%.o: tests/%.c
$(CC) -c $^ $(CFLAGS) $(INCLUDE) $(DEFINE) -o $@
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)