-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
70 lines (47 loc) · 2.28 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
PROJECT_ROOT := $(shell pwd)
GCC ?= g++
CCFLAGS := -std=c++11 -g
CUDA_PATH ?= /usr/local/cuda
NVCC := $(CUDA_PATH)/bin/nvcc
NVCCFLAGS := $(CCFLAGS)
LDFLAGS := -Wl,-rpath=$(PROJECT_ROOT)/lib/ffmpeg -L$(PROJECT_ROOT)/lib/ffmpeg -lavformat -lavcodec -lavutil -lswscale -lswresample # ffmpeg library
LDFLAGS += -Wl,-rpath=$(PROJECT_ROOT)/lib/opencv -L$(PROJECT_ROOT)/lib/opencv -lavformat -lopencv_core -lopencv_imgproc -lopencv_highgui -lz -lpthread # opencv library
LDFLAGS += -L$(CUDA_PATH)/lib64/stubs -lcuda
LDFLAGS += -L$(CUDA_PATH)/lib64 -lcudart
LDFLAGS += -shared
ifndef CPU_ONLY
LDFLAGS += -Wl,-rpath=/usr/lib/nvidia-415 -L/usr/lib/nvidia-415 -lnvcuvid # nvcuvid
else
LDFLAGS += -Wl,-rpath=$(PROJECT_ROOT)/lib/nvcuvid -L$(PROJECT_ROOT)/lib/nvcuvid -lnvcuvid
endif
# Project includes
INCLUDES := -I./include
INCLUDES += -I./include/opencv
INCLUDES += -I./include/ffmpeg
INCLUDES += -I./include/NvDecoder
INCLUDES += -I./include/cuda
INCLUDES += -I./include/Utils
# CUDA includes
INCLUDES += -I$(CUDA_PATH)/include
# pybind11 includes
INCLUDES += $(shell python3 -m pybind11 --includes)
SUFFIX ?= $(shell python3-config --extension-suffix)
BUILD_DIR := build
$(BUILD_DIR)/PyDecoder$(SUFFIX): $(BUILD_DIR)/PyDecoder.o $(BUILD_DIR)/CPUDecoder.o $(BUILD_DIR)/GPUDecoder.o $(BUILD_DIR)/NvDecoder.o $(BUILD_DIR)/DeviceChecker.o $(BUILD_DIR)/ColorSpace.o $(BUILD_DIR)/AudioDec.o
$(GCC) $(CCFLAGS) -o $@ $^ $(LDFLAGS)
$(BUILD_DIR)/PyDecoder.o: python/PyDecoder.cpp
$(GCC) $(CCFLAGS) -fPIC $(INCLUDES) -o $@ -c $<
$(BUILD_DIR)/CPUDecoder.o: src/CpuDec.cpp
$(GCC) $(CCFLAGS) -fPIC $(INCLUDES) -o $@ -c $<
$(BUILD_DIR)/GPUDecoder.o: src/GpuDec.cpp
$(GCC) $(CCFLAGS) -fPIC $(INCLUDES) -o $@ -c $<
$(BUILD_DIR)/AudioDec.o: src/AudioDec.cpp
$(GCC) $(CCFLAGS) -fPIC $(INCLUDES) -o $@ -c $<
$(BUILD_DIR)/NvDecoder.o: src/NvDecoder/NvDecoder.cpp
$(GCC) $(CCFLAGS) -fPIC $(INCLUDES) -o $@ -c $<
$(BUILD_DIR)/DeviceChecker.o: src/CheckDevice.cpp
$(GCC) $(CCFLAGS) -fPIC $(INCLUDES) -o $@ -c $<
$(BUILD_DIR)/ColorSpace.o: src/Utils/ColorSpace.cu
$(NVCC) $(NVCCFLAGS) -Xcompiler -fPIC $(INCLUDES) -o $@ -c $<
clean:
rm -rf $(BUILD_DIR)/PyDecoder$(SUFFIX) $(BUILD_DIR)/PyDecoder.o $(BUILD_DIR)/CPUDecoder.o $(BUILD_DIR)/GPUDecoder.o $(BUILD_DIR)/NvDecoder.o $(BUILD_DIR)/DeviceChecker.o $(BUILD_DIR)/ColorSpace.o