Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ CFLAGS += -Iinclude -Werror=implicit-function-declaration
# driver, whereas the unversioned libnvidia-ml.so symlink only comes with
# -dev packages or the CUDA toolkit. Some distributions keep it outside
# ld's default search path, so use the directory registered with ldconfig.
# Keep it out of LDFLAGS: that is a user variable, and a value passed on the
# command line or exported by a packaging system would replace it and drop -L.
LDCONFIG ?= /sbin/ldconfig
NVML_CACHE_PATTERN = libnvidia-ml\.so\.1 \(libc6,
NVML_LIBDIR ?= $(shell $(LDCONFIG) -p 2>/dev/null | awk '/$(NVML_CACHE_PATTERN)/{print $$NF; exit}' | xargs -r dirname)
LDFLAGS += $(if $(NVML_LIBDIR),-L$(NVML_LIBDIR))
LIBS = -l:libnvidia-ml.so.1 -ljansson -lncursesw
NVML_LDFLAGS = $(if $(NVML_LIBDIR),-L$(NVML_LIBDIR))
LIBS = $(NVML_LDFLAGS) -l:libnvidia-ml.so.1 -ljansson -lncursesw

SRCDIR = src
BUILDDIR = build
Expand Down
4 changes: 2 additions & 2 deletions tests/test_makefile_nvml_detection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ chmod +x "$tmp_dir/ldconfig"
# shellcheck disable=SC2016
ldflags=$(make -C "$repo_dir" --no-print-directory -s \
LDCONFIG="$tmp_dir/ldconfig" \
--eval='print-nvml-ldflags:;@echo $(LDFLAGS)' print-nvml-ldflags)
--eval='print-nvml-ldflags:;@echo $(NVML_LDFLAGS)' print-nvml-ldflags)
[ "$ldflags" = "-L/test/nvidia" ]

# shellcheck disable=SC2016
override_flags=$(make -C "$repo_dir" --no-print-directory -s \
LDCONFIG=/does/not/exist NVML_LIBDIR=/vendor/lib \
--eval='print-nvml-override:;@echo $(LDFLAGS)' print-nvml-override)
--eval='print-nvml-override:;@echo $(NVML_LDFLAGS)' print-nvml-override)
[ "$override_flags" = "-L/vendor/lib" ]
Loading