############################################################################### # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LGPL-2.1-or-later # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program. If not, see # . ############################################################################### SO_NAME := libnvv4l2.so SRCS := libv4l2.c log.c v4l2convert.c v4l2-plugin.c INCLUDES += -I./ -I../include OBJS := $(SRCS:.c=.o) CFLAGS := -fPIC MACHINE = $(shell uname -m) ifeq ($(MACHINE),x86_64) CFLAGS += -DLIBV4L2_PLUGIN_DIR_PATH_X86 DEST_DIR ?= /opt/nvidia/deepstream/deepstream-4.0/lib/ SYM_LINK_DIR = $(DEST_DIR) else DEST_DIR ?= /usr/lib/$(MACHINE)-linux-gnu/nvidia SYM_LINK_DIR = $(shell realpath $(DEST_DIR)/..) endif LDFLAGS := -L$(DEST_DIR) -Wl,-soname,libv4l2.so.0 LIBS := -lv4lconvert -ldl all: $(SO_NAME) %.o: %.c $(CC) -c $< $(CFLAGS) $(INCLUDES) -o $@ $(SO_NAME): $(OBJS) $(CC) -shared -o $(SO_NAME) $(OBJS) $(LIBS) $(LDFLAGS) .PHONY: install install: $(SO_NAME) cp -vp $(SO_NAME) $(DEST_DIR) if [ "$(MACHINE)" = "aarch64" ]; then \ ln -sf nvidia/$(SO_NAME) $(SYM_LINK_DIR)/libv4l2.so.0.0.999999 ; \ else \ ln -sf $(SO_NAME) $(SYM_LINK_DIR)/libv4l2.so.0.0.999999 ; \ fi ln -sf libv4l2.so.0.0.999999 \ $(SYM_LINK_DIR)/libv4l2.so ln -sf libv4l2.so.0.0.999999 \ ${SYM_LINK_DIR}/libv4l2.so.0 .PHONY: clean clean: rm -rf $(OBJS) $(SO_NAME)