-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
120 lines (95 loc) · 2.81 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
include make.inc
.SUFFIXES:
.SUFFIXES: .o .cu .cpp .h
#
# ------
# Target
# ------
#
TGT=ipic-gpu
EXEC=${TGT}.e
#
# -----------
# Directories
# -----------
#
CDA_DIR=${CURDIR}/cuda
SRC_DIR=${CURDIR}/src
OBJ_DIR=${CURDIR}/obj
INC_DIR=${CURDIR}/include
MAIN_DIR=${CURDIR}/main
#
# -----
# Files
# -----
#
CPP_FILES = $(wildcard $(SRC_DIR)/*.cpp) $(wildcard $(MAIN_DIR)/*.cpp)
CU_FILES = $(wildcard $(CDA_DIR)/*.cu)
H_FILES = $(wildcard $(SRC_DIR)/*.h)
#
# -------
# Objects
# -------
#
OBJ_FILES = $(addprefix $(OBJ_DIR)/,$(notdir $(CPP_FILES:.cpp=.o)))
CUO_FILES = $(addprefix $(OBJ_DIR)/,$(notdir $(CU_FILES:.cu=.cu.o)))
#
# ---------------
# Makefile labels
# ---------------
#
LIBRARIES=
all : noacc
gpu : src cuda
@echo " --------------------------------------------------- "
@echo " Creating GPU executable: "
@$(NVCC) $(OBJ_FILES) $(CUO_FILES) $(LIRARIES) -o $(EXEC)
@echo " $(CURDIR)/$(EXEC) "
@echo " --------------------------------------------------- "
cuda : $(CUO_FILES)
@echo " --------------------------------------------------- "
@echo " CUDA files compiled"
@echo " --------------------------------------------------- "
src : $(OBJ_FILES)
@echo " --------------------------------------------------- "
@echo " SRCE files compiled"
@echo " --------------------------------------------------- "
noacc : src
@echo " --------------------------------------------------- "
@echo " Creating CPU executable: "
@$(CPP) $(OBJ_FILES) $(LIRARIES) -o $(EXEC)
@echo " $(CURDIR)/$(EXEC) "
@echo " --------------------------------------------------- "
clean :
@echo " --------------------------------------------------- "
@echo " Cleaning the project... "
@$(RM) $(OBJ_FILES) $(CUO_FILES) $(EXEC)
@echo " ... Object files and executable deleted."
@echo " --------------------------------------------------- "
#
# -----------
# Compilation
# -----------
#
INCLUDES=-I$(CURDIR)
$(OBJ_DIR)/%.o : $(MAIN_DIR)/%.cpp $(H_FILES)
@echo " --------------------------------------------------- "
@echo " Compiling MAIN file: " $<
@$(CPP) $(CCFLAGS) $(INCLUDES) $(DACC) -c -o $@ $<
@echo " MAIN file compiled : " $@
@touch $@
@echo " --------------------------------------------------- "
$(OBJ_DIR)/%.cu.o : $(CDA_DIR)/%.cu $(H_FILES)
@echo " --------------------------------------------------- "
@echo " CUDA compiling KERNEL file: " $<
@$(NVCC) $(NVCCFLAGS) $(INCLUDES) $(DACC) -c -o $@ $<
@echo " CUDA KERNEL file compiled : " $@
@touch $@
@echo " --------------------------------------------------- "
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp $(H_FILES)
@echo " --------------------------------------------------- "
@echo " SRCE compiling file: " $<
@$(CPP) $(CCFLAGS) $(INCLUDES) $(DACC) -c -o $@ $<
@echo " SRCE file compiled : " $@
@touch $@
@echo " --------------------------------------------------- "