|
| 1 | +################################################################################ |
| 2 | +# Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved. |
| 3 | +# |
| 4 | +# Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | +# copy of this software and associated documentation files (the "Software"), |
| 6 | +# to deal in the Software without restriction, including without limitation |
| 7 | +# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | +# and/or sell copies of the Software, and to permit persons to whom the |
| 9 | +# Software is furnished to do so, subject to the following conditions: |
| 10 | +# |
| 11 | +# The above copyright notice and this permission notice shall be included in |
| 12 | +# all copies or substantial portions of the Software. |
| 13 | +# |
| 14 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 19 | +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 | +# DEALINGS IN THE SOFTWARE. |
| 21 | +################################################################################# |
| 22 | +#enable this flag to use optimized dsexample plugin |
| 23 | +#it can also be exported from command line |
| 24 | + |
| 25 | +WITH_OPENCV?=1 |
| 26 | + |
| 27 | +CUDA_VER?=11.4 |
| 28 | +ifeq ($(CUDA_VER),) |
| 29 | + $(error "CUDA_VER is not set") |
| 30 | +endif |
| 31 | +TARGET_DEVICE = $(shell gcc -dumpmachine | cut -f1 -d -) |
| 32 | + |
| 33 | +CXX:= g++ |
| 34 | +NVCC:= nvcc |
| 35 | + |
| 36 | +SRCS:= $(wildcard *.cpp) |
| 37 | +CUSRCS:=$(wildcard *.cu) |
| 38 | +INCS:= $(wildcard *.h) |
| 39 | +LIB:=libnvdsgst_dscustomplugin.so |
| 40 | + |
| 41 | +NVDS_VERSION:=6.2 |
| 42 | + |
| 43 | +CFLAGS+= -fPIC -DDS_VERSION=\"6.2.0\" \ |
| 44 | + -I /usr/local/cuda-$(CUDA_VER)/include \ |
| 45 | + -I ../../includes \ |
| 46 | + -I/usr/src/jetson_multimedia_api/include \ |
| 47 | + -I/usr/include/aarch64-linux-gnu \ |
| 48 | + -I/usr/include/gstreamer-1.0/gst \ |
| 49 | + -I/opt/nvidia/deepstream/deepstream-6.2/sources/includes |
| 50 | + |
| 51 | +GST_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/gst-plugins/ |
| 52 | +LIB_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/ |
| 53 | + |
| 54 | +LIBS := -shared -Wl,-no-undefined \ |
| 55 | + -L/usr/local/cuda-$(CUDA_VER)/lib64/ -lcudart -ldl \ |
| 56 | + -L/usr/lib/aarch64-linux-gnu/ -lnvinfer_plugin \ |
| 57 | + -L/usr/lib/aarch64-linux-gnu/tegra/ -lEGL -lGLESv2 \ |
| 58 | + -L/usr/lib/aarch64-linux-gnu/tegra/ -lcuda -lnvbuf_utils \ |
| 59 | + -L/usr/local/cuda-$(CUDA_VER)/lib64/ -lcudart \ |
| 60 | + -L/usr/lib/aarch64-linux-gnu/ -lopencv_cudaimgproc \ |
| 61 | + -L/opt/nvidia/deepstream/deepstream-6.2/includes \ |
| 62 | + -L/opt/nvidia/deepstream/deepstream-6.2/lib/ -lnvdsgst_helper -lnvdsgst_meta -lnvds_meta -lnvbufsurface -lnvbufsurftransform -lnvinfer -lnvparsers -lnvonnxparser |
| 63 | +OBJS:= $(SRCS:.cpp=.o) $(CUSRCS:.cu=.o) |
| 64 | + |
| 65 | +PKGS:= gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0 |
| 66 | + |
| 67 | +ifeq ($(WITH_OPENCV),1) |
| 68 | +CFLAGS+= -I /usr/local/include/opencv4 |
| 69 | +PKGS+= opencv4 |
| 70 | +endif |
| 71 | + |
| 72 | +CFLAGS+=$(shell pkg-config --cflags $(PKGS)) |
| 73 | +LIBS+=$(shell pkg-config --libs $(PKGS)) |
| 74 | + |
| 75 | +all: $(LIB) |
| 76 | + |
| 77 | +%.o: %.cu Makefile |
| 78 | + $(NVCC) -c -o $@ -arch compute_87 --compiler-options '-fPIC' $< |
| 79 | + |
| 80 | +%.o: %.cpp $(INCS) Makefile |
| 81 | + @echo $(CFLAGS) |
| 82 | + $(CXX) -c -o $@ $(CFLAGS) $< |
| 83 | + |
| 84 | +$(LIB): $(OBJS) $(DEP) Makefile |
| 85 | + @echo $(CFLAGS) |
| 86 | + $(CXX) -o $@ $(OBJS) $(LIBS) |
| 87 | + |
| 88 | +$(DEP): $(DEP_FILES) |
| 89 | + $(MAKE) -C dsexample_lib/ |
| 90 | + |
| 91 | +install: $(LIB) |
| 92 | + cp -rv $(LIB) $(GST_INSTALL_DIR) |
| 93 | + |
| 94 | +clean: |
| 95 | + rm -rf *.so *.o |
0 commit comments