# SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NvidiaProprietary # # NVIDIA CORPORATION, its affiliates and licensors retain all intellectual # property and proprietary rights in and to this material, related # documentation and any modifications thereto. Any use, reproduction, # disclosure or distribution of this material and related documentation # without an express license agreement from NVIDIA CORPORATION or # its affiliates is strictly prohibited. # # Location of common libraries LIB_DIR = /usr/lib/aarch64-linux-gnu # NOTE: This directory PATH will be moved from "tegra" to "nvidia". TEGRA_LIB_DIR ?= /usr/lib/aarch64-linux-gnu/tegra # Location of the CUDA Toolkit CUDA_PATH ?= /usr/local/cuda # Location of NVSCI header NVSCI_HEADER_DIR ?= /usr/include/nvsci_headers NVSCI_LIB_DIR = $(TEGRA_LIB_DIR) GCC ?= g++ NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(GCC) # internal flags NVCCFLAGS := CCFLAGS := LDFLAGS := # Extra user flags EXTRA_NVCCFLAGS ?= EXTRA_LDFLAGS ?= EXTRA_CCFLAGS ?= override abi := aarch64 LDFLAGS += --dynamic-linker=/lib/ld-linux-aarch64.so.1 # Debug build flags dbg = 0 ifeq ($(dbg),1) NVCCFLAGS += -g -G TARGET := debug else TARGET := release endif ALL_CCFLAGS := ALL_CCFLAGS += $(NVCCFLAGS) ALL_CCFLAGS += $(EXTRA_NVCCFLAGS) ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS)) ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS)) ALL_LDFLAGS := ALL_LDFLAGS += $(ALL_CCFLAGS) ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS)) ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS)) ################################################################################ # Common includes and paths INCLUDES := -I./ LIBRARIES := -L$(LIB_DIR) CUDA_SEARCH_PATH ?= $(CUDA_PATH)/lib64/stubs CUDA_SEARCH_PATH += $(CUDA_PATH)/lib/stubs CUDA_SEARCH_PATH += $(CUDA_PATH)/targets/aarch64-linux/lib/stubs CUDALIB ?= $(shell find -L $(CUDA_SEARCH_PATH) -maxdepth 1 -name libcuda.so 2> /dev/null) ifeq ("$(CUDALIB)","") $(error ERROR - libcuda.so not found, CUDA Driver is not installed or CUDA_PATH is not correctly set.) else CUDALIB := $(shell echo $(CUDALIB) | sed "s/ .*//" | sed "s/\/libcuda.so//" ) LIBRARIES += -L$(CUDALIB) -lcuda -lrt endif # Includes and paths for NVSCI libraries NVSCIBUFHEADER := $(shell find -L $(NVSCI_HEADER_DIR) -name nvscibuf.h -print 2>/dev/null) NVSCISYNCHEADER := $(shell find -L $(NVSCI_HEADER_DIR) -name nvscisync.h -print 2>/dev/null) NVSCIIPCHEADER := $(shell find -L $(NVSCI_HEADER_DIR) -name nvsciipc.h -print 2>/dev/null) ifeq ("$(NVSCIBUFHEADER)","") $(error ERROR - nvscibuf.h not found in $(NVSCI_HEADER_DIR)) endif ifeq ("$(NVSCISYNCHEADER)","") $(error ERROR - nvscisync.h not found in $(NVSCI_HEADER_DIR)) endif ifeq ("$(NVSCIIPCHEADER)","") $(error ERROR - nvsciipc.h not found in $(NVSCI_HEADER_DIR)) endif INCLUDES += -I$(NVSCI_HEADER_DIR) LIBRARIES += -L$(NVSCI_LIB_DIR) -lnvscibuf -lnvscisync -lnvscievent -lnvsciipc -lnvscistream ALL_CCFLAGS += --std=c++11 --threads 0 ################################################################################ # Target rules OUTPUT := rawstream all: build build: $(OUTPUT) OBJ := rawstream_consumer.o OBJ += rawstream_cuda.o OBJ += rawstream_ipc_linux.o OBJ += rawstream_main.o OBJ += rawstream_producer.o %.o: %.c $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) -o $@ -c $< $(OUTPUT): $(OBJ) $(NVCC) $(ALL_LDFLAGS) -o $@ $+ $(LIBRARIES) run: build $(OUTPUT) testrun: build clean: rm -f $(OBJ) $(OUTPUT) clobber: clean