-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
82 lines (53 loc) · 1.66 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
###########################################################
## USER SPECIFIC DIRECTORIES ##
# CUDA directory:
CUDA_ROOT_DIR=/usr/local/cuda
##########################################################
## CC COMPILER OPTIONS ##
# CC compiler options:
CC=g++
CC_FLAGS=
CC_LIBS=
##########################################################
## NVCC COMPILER OPTIONS ##
# NVCC compiler options:
NVCC=nvcc
NVCC_FLAGS=
NVCC_LIBS=
# CUDA library directory:
CUDA_LIB_DIR= -L$(CUDA_ROOT_DIR)/lib64
# CUDA include directory:
CUDA_INC_DIR= -I$(CUDA_ROOT_DIR)/include
# CUDA linking libraries:
CUDA_LINK_LIBS= -lcudart
##########################################################
## Project file structure ##
# Source file directory:
SRC_DIR = src
# Object file directory:
OBJ_DIR = bin
# Include header file diretory:
INC_DIR = include
##########################################################
## Make variables ##
# Target executable name:
EXE = run_test
# Object files:
OBJS = $(OBJ_DIR)/main.o $(OBJ_DIR)/cuda_kernel.o
##########################################################
## Compile ##
# Link c++ and CUDA compiled object files to target executable:
$(EXE) : $(OBJS)
$(CC) $(CC_FLAGS) $(OBJS) -o $@ $(CUDA_INC_DIR) $(CUDA_LIB_DIR) $(CUDA_LINK_LIBS)
# Compile main .cpp file to object files:
$(OBJ_DIR)/%.o : %.cpp
$(CC) $(CC_FLAGS) -c $< -o $@
# Compile C++ source files to object files:
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp include/%.h
$(CC) $(CC_FLAGS) -c $< -o $@
# Compile CUDA source files to object files:
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cu $(INC_DIR)/%.cuh
$(NVCC) $(NVCC_FLAGS) -c $< -o $@ $(NVCC_LIBS)
# Clean objects in object directory.
clean:
$(RM) bin/* *.o $(EXE)