forked from ledaiduongvnth/nvinfer-custom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
80 lines (61 loc) · 2.67 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
################################################################################
# Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.
#################################################################################
CUDA_VER=10.2
ifeq ($(CUDA_VER),)
$(error "CUDA_VER is not set")
endif
NVCC:=/usr/local/cuda-$(CUDA_VER)/bin/nvcc
CXX:= g++
SRCS:= gstnvinfer.cpp gstnvinfer_allocator.cpp gstnvinfer_property_parser.cpp \
gstnvinfer_meta_utils.cpp gstnvinfer_impl.cpp aligner.cpp nvdsinfer_backend.cpp nvdsinfer_context_impl.cpp \
nvdsinfer_context_impl_capi.cpp nvdsinfer_context_impl_output_parsing.cpp nvdsinfer_func_utils.cpp \
nvdsinfer_model_builder.cpp nvdsinfer_conversion.cu
INCS:= $(wildcard *.h)
LIB:=libnvdsgst_inferonnx.so
NVDS_VERSION:=5.0
CFLAGS+= -fPIC -std=c++11 -DDS_VERSION=\"5.0.0\" \
-I /usr/local/cuda-$(CUDA_VER)/include \
-I ./includes \
-I ./libs/nvdsinfer -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 \
-I /usr/lib/x86_64-linux-gnu/glib-2.0/include -DNDEBUG
GST_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/gst-plugins/
LIB_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/
LIBS := -shared -Wl,-no-undefined \
-L/usr/local/cuda-$(CUDA_VER)/lib64/ -lcudart \
-lnvinfer -lnvinfer_plugin -lnvonnxparser -lnvparsers \
-L/usr/local/cuda-$(CUDA_VER)/lib64/ -lcudart \
-lopencv_objdetect -lopencv_imgproc -lopencv_core
LIBS+= -L$(LIB_INSTALL_DIR) -lnvdsgst_helper -lnvdsgst_meta -lnvds_meta \
-lnvds_infer -lnvbufsurface -lnvbufsurftransform -ldl -lpthread \
-Wl,-rpath,$(LIB_INSTALL_DIR)
LIBS+= -L$(LIB_INSTALL_DIR) -lnvdsgst_helper -lnvdsgst_meta -lnvds_meta \
-lnvds_inferutils -ldl \
-Wl,-rpath,$(LIB_INSTALL_DIR)
OBJS:= $(SRCS:.cpp=.o)
OBJS:= $(OBJS:.cu=.o)
PKGS:= gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0 opencv
CFLAGS+=$(shell pkg-config --cflags $(PKGS)) -std=c++14
LIBS+=$(shell pkg-config --libs $(PKGS))
ifeq ($(shell uname -m), aarch64)
CFLAGS+=-DIS_TEGRA
LIBS+=-lcuda
endif
all: $(LIB)
%.o: %.cpp $(INCS) Makefile
$(CXX) -c -o $@ $(CFLAGS) $<
%.o: %.cu $(INCS) Makefile
@echo $(CFLAGS)
$(NVCC) -c -o $@ --compiler-options '-fPIC' $<
$(LIB): $(OBJS) $(DEP) Makefile
$(CXX) -o $@ $(OBJS) $(LIBS)
install: $(LIB)
cp -rv $(LIB) $(GST_INSTALL_DIR)
clean:
rm -rf $(OBJS) $(LIB)