-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (31 loc) · 1.27 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
TARGET = facesnap
CUDA_PATH=/opt/cuda/lib64/
X11_LIB_PATH=/usr/X11R6/lib/
SRC_DIR = src
CUDA_SRC_DIR = cuda
OBJ_DIR = obj
CC = g++
NVCC = nvcc
RM = rm -f
NVCCFLAGS = -arch sm_20
CPPFLAGS = -Wall -march=native -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -g -fvar-tracking-assignments -D_FORTIFY_SOURCE=2 -std=c++11 -I./$(CUDA_SRC_DIR)
LDFLAGS = -Wall -Wl,-O1,--sort-common,--as-needed,-z,relro
LDLIBS = -L$(X11_LIB_PATH) -L$(CUDA_PATH) -lm -lpthread -lX11 -lcuda -lcudart
CPPFLAGS += `pkg-config --cflags opencv`
LDLIBS += `pkg-config --libs opencv`
CPP_FILES = $(wildcard $(SRC_DIR)/*.cpp)
CU_FILES = $(wildcard $(CUDA_SRC_DIR)/*.cu)
H_FILES = $(wildcard $(SRC_DIR)/*.h)
CU_H_FILES = $(wildcard $(CUDA_SRC_DIR)/*.cu.h)
OBJ_FILES = $(addprefix $(OBJ_DIR)/,$(notdir $(CPP_FILES:.cpp=.o)))
CUO_FILES = $(addprefix $(OBJ_DIR)/,$(notdir $(CU_FILES:.cu=.cu.o)))
OBJS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(notdir $(CPP_FILES)))
OBJS += $(patsubst %.cu,$(OBJ_DIR)/%.cu.o,$(notdir $(CU_FILES)))
$(TARGET) : $(OBJS)
$(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LDLIBS)
$(OBJ_DIR)/%.cu.o : $(CUDA_SRC_DIR)/%.cu $(CU_H_FILES)
$(NVCC) $(NVCCFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp $(H_FILES)
$(CC) $(CPPFLAGS) -c $< -o $@
clean:
$(RM) $(TARGET) $(OBJ_DIR)/*.o