-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (84 loc) · 2.56 KB
/
Copy pathMakefile
File metadata and controls
141 lines (84 loc) · 2.56 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
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
MAKE = make -j 8
# Define compiler with OpenMP.
CXX = g++ -std=c++17 -fopenmp
# Define compiler serial version.
CXXSERIAL = g++ -std=c++17
# Program executable.
EXE := DRP2D
# Source files directory.
SRC_DIR := src
# Object files directory.
OBJ_DIR := obj
# Binary directory.
BIN_DIR := bin
# Dependency directory.
DEP_DIR := Dependencies
# Extract source files.
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
# Specify object files.
OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRCS))
# Dependency files.
DEPS := $(patsubst $(SRC_DIR)/%.cpp,$(DEP_DIR)/%.d,$(SRCS))
# Compiler include files.
INCLUDE = -Iinclude
# Compiler debug flags.
CXX_DBGFLAGS = -g -Wall -DENABLE_NAN_CHECK #-Werror
# Optimization flags
#CXX_OPTFLAGS = -O2 -msse4.2 -ffast-math -funroll-loops -ftree-vectorize -ftree-vectorizer-verbose=2 -fopt-info-loop-optimized -march=native
#CXX_OPTFLAGS = -O2 -mavx2 -mfma -ffast-math -funroll-loops -ftree-vectorize -ftree-vectorizer-verbose=2 -fopt-info-loop-optimized -march=native
CXX_OPTFLAGS = -O2 -mavx2 -mfma -ffast-math -funroll-loops -ftree-vectorize -ftree-vectorizer-verbose=2 -march=native
# OpenMP flags.
CXX_OMP = -DHAVE_OPENMP
# Compiler flags.
CXXFLAGS = $(CXX_OPTFLAGS) $(CXX_STDFLAGS) $(CXX_OMP) $(MPI_FLAGS)
#CXXFLAGS = #-fconcepts
# Linker flags.
LDFLAGS = -Llib -flto
# Blas/lapack flags.
LD_BLAS = -llapack -lblas
# Linker libraries to link.
LDLIBS = -lm $(LD_BLAS)
# Linked.
LD := $(CXX)
# Dependency flags.
#DEPFLAGS = -MT $@ -MMD -MP -MF $(DEP_DIR)/$*.d
DEPFLAGS = -MMD -MT $@ -MP -MF $(DEP_DIR)/$*.d
# Target executable.
TARGET := $(BIN_DIR)/$(EXE)
# Preprocessor flags.
CPPFLAGS = $(INCLUDE)
# Link object files to binary.
LINK.o = $(LD) $(LDFLAGS) $(LDLIBS)
# Compile commands.
COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DEPFLAGS)
##.PHONY: all clean
##
##all:
## @echo "$(BIN_DIR)/$(EXE)"
## @echo " "
## $(BIN_DIR)/$(EXE)
##
##$(BIN_DIR)/$(EXE):
## @echo "hola!"
#$(BIN_DIR)/$(EXE): $(OBJS)
# $(LINK.o) $^ -o $@
.PHONY: all clean debug
default: all
debug: CXXFLAGS = -DDEBUG $(CXX_DBGFLAGS)
debug: $(TARGET)
debugSerial: COMPILE.cc = $(CXXSERIAL) -DDEBUG $(CXX_DBGFLAGS) $(CPPFLAGS) $(DEPFLAGS) -w
debugSerial: $(TARGET)
standard: COMPILE.cc = $(CXXSERIAL) $(CPPFLAGS) $(DEPFLAGS)
standard: $(TARGET)
all:
$(MAKE) $(TARGET)
$(TARGET): $(OBJS)
$(LINK.o) $^ -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(DEP_DIR)/%.d | $(DEP_DIR)
$(COMPILE.cc) -o $@ -c $<
$(DEPS):
$(DEP_DIR): ; @mkdir -p $@
.PRECIOUS: $(DEP_DIR)/%.d
clean:
$(RM) $(OBJS) $(DEPS) $(TARGET)
-include $(wildcard $(DEPS))