1################################################################################ 2# 3# nvidia-driver 4# 5################################################################################ 6 7NVIDIA_DRIVER_VERSION = 390.132 8NVIDIA_DRIVER_SUFFIX = $(if $(BR2_x86_64),_64) 9NVIDIA_DRIVER_SITE = http://download.nvidia.com/XFree86/Linux-x86$(NVIDIA_DRIVER_SUFFIX)/$(NVIDIA_DRIVER_VERSION) 10NVIDIA_DRIVER_SOURCE = NVIDIA-Linux-x86$(NVIDIA_DRIVER_SUFFIX)-$(NVIDIA_DRIVER_VERSION)$(if $(BR2_x86_64),-no-compat32).run 11NVIDIA_DRIVER_LICENSE = NVIDIA Software License 12NVIDIA_DRIVER_LICENSE_FILES = LICENSE 13NVIDIA_DRIVER_REDISTRIBUTE = NO 14NVIDIA_DRIVER_INSTALL_STAGING = YES 15 16ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_XORG),y) 17 18# Since nvidia-driver are binary blobs, the below dependencies are not 19# strictly speaking build dependencies of nvidia-driver. However, they 20# are build dependencies of packages that depend on nvidia-driver, so 21# they should be built prior to those packages, and the only simple 22# way to do so is to make nvidia-driver depend on them. 23NVIDIA_DRIVER_DEPENDENCIES += mesa3d-headers xlib_libX11 xlib_libXext 24NVIDIA_DRIVER_PROVIDES += libgl libegl libgles 25 26# libGL.so.$(NVIDIA_DRIVER_VERSION) is the legacy libGL.so library; it 27# has been replaced with libGL.so.1.0.0. Installing both is technically 28# possible, but great care must be taken to ensure they do not conflict, 29# so that EGL still works. The legacy library exposes an NVidia-specific 30# API, so it should not be needed, except for legacy, binary-only 31# applications (in other words: we don't care). 32# 33# libGL.so.1.0.0 is the new vendor-neutral library, aimed at replacing 34# the old libGL.so.$(NVIDIA_DRIVER_VERSION) library. The latter contains 35# NVidia extensions (which is deemed bad now), while the former follows 36# the newly-introduced vendor-neutral "dispatching" API/ABI: 37# https://github.com/aritger/linux-opengl-abi-proposal/blob/master/linux-opengl-abi-proposal.txt 38# However, this is not very useful to us, as we don't support multiple 39# GL providers at the same time on the system, which this proposal is 40# aimed at supporting. 41# 42# So we only install the legacy library for now. 43NVIDIA_DRIVER_LIBS_GL = \ 44 libGLX.so.0 \ 45 libGL.so.$(NVIDIA_DRIVER_VERSION) \ 46 libGLX_nvidia.so.$(NVIDIA_DRIVER_VERSION) 47 48NVIDIA_DRIVER_LIBS_EGL = \ 49 libEGL.so.1.1.0 \ 50 libGLdispatch.so.0 \ 51 libEGL_nvidia.so.$(NVIDIA_DRIVER_VERSION) 52 53NVIDIA_DRIVER_LIBS_GLES = \ 54 libGLESv1_CM.so.1.2.0 \ 55 libGLESv2.so.2.1.0 \ 56 libGLESv1_CM_nvidia.so.$(NVIDIA_DRIVER_VERSION) \ 57 libGLESv2_nvidia.so.$(NVIDIA_DRIVER_VERSION) 58 59NVIDIA_DRIVER_LIBS_MISC = \ 60 libnvidia-eglcore.so.$(NVIDIA_DRIVER_VERSION) \ 61 libnvidia-egl-wayland.so.1.0.2 \ 62 libnvidia-glcore.so.$(NVIDIA_DRIVER_VERSION) \ 63 libnvidia-glsi.so.$(NVIDIA_DRIVER_VERSION) \ 64 tls/libnvidia-tls.so.$(NVIDIA_DRIVER_VERSION) \ 65 libvdpau_nvidia.so.$(NVIDIA_DRIVER_VERSION):vdpau/ \ 66 libnvidia-ml.so.$(NVIDIA_DRIVER_VERSION) 67 68NVIDIA_DRIVER_LIBS += \ 69 $(NVIDIA_DRIVER_LIBS_GL) \ 70 $(NVIDIA_DRIVER_LIBS_EGL) \ 71 $(NVIDIA_DRIVER_LIBS_GLES) \ 72 $(NVIDIA_DRIVER_LIBS_MISC) 73 74# Install the gl.pc file 75define NVIDIA_DRIVER_INSTALL_GL_DEV 76 $(INSTALL) -D -m 0644 $(@D)/libGL.la $(STAGING_DIR)/usr/lib/libGL.la 77 $(SED) 's:__GENERATED_BY__:Buildroot:' $(STAGING_DIR)/usr/lib/libGL.la 78 $(SED) 's:__LIBGL_PATH__:/usr/lib:' $(STAGING_DIR)/usr/lib/libGL.la 79 $(SED) 's:-L[^[:space:]]\+::' $(STAGING_DIR)/usr/lib/libGL.la 80 $(INSTALL) -D -m 0644 package/nvidia-driver/gl.pc $(STAGING_DIR)/usr/lib/pkgconfig/gl.pc 81 $(INSTALL) -D -m 0644 package/nvidia-driver/egl.pc $(STAGING_DIR)/usr/lib/pkgconfig/egl.pc 82endef 83 84# Those libraries are 'private' libraries requiring an agreement with 85# NVidia to develop code for those libs. There seems to be no restriction 86# on using those libraries (e.g. if the user has such an agreement, or 87# wants to run a third-party program developed under such an agreement). 88ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_PRIVATE_LIBS),y) 89NVIDIA_DRIVER_LIBS += \ 90 libnvidia-ifr.so.$(NVIDIA_DRIVER_VERSION) \ 91 libnvidia-fbc.so.$(NVIDIA_DRIVER_VERSION) 92endif 93 94# We refer to the destination path; the origin file has no directory component 95NVIDIA_DRIVER_LIBS += \ 96 nvidia_drv.so:xorg/modules/drivers/ \ 97 libglx.so.$(NVIDIA_DRIVER_VERSION):xorg/modules/extensions/ 98 99# libglx needs a symlink according to the driver README. It has no SONAME 100define NVIDIA_DRIVER_SYMLINK_LIBGLX 101 ln -sf libglx.so.$(NVIDIA_DRIVER_VERSION) \ 102 $(TARGET_DIR)/usr/lib/xorg/modules/extensions/libglx.so 103endef 104 105endif # X drivers 106 107ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_CUDA),y) 108NVIDIA_DRIVER_LIBS += \ 109 libcuda.so.$(NVIDIA_DRIVER_VERSION) \ 110 libnvidia-compiler.so.$(NVIDIA_DRIVER_VERSION) \ 111 libnvcuvid.so.$(NVIDIA_DRIVER_VERSION) \ 112 libnvidia-fatbinaryloader.so.$(NVIDIA_DRIVER_VERSION) \ 113 libnvidia-ptxjitcompiler.so.$(NVIDIA_DRIVER_VERSION) \ 114 libnvidia-encode.so.$(NVIDIA_DRIVER_VERSION) 115ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_CUDA_PROGS),y) 116NVIDIA_DRIVER_PROGS = nvidia-cuda-mps-control nvidia-cuda-mps-server 117endif 118endif 119 120ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_OPENCL),y) 121NVIDIA_DRIVER_LIBS += \ 122 libOpenCL.so.1.0.0 \ 123 libnvidia-opencl.so.$(NVIDIA_DRIVER_VERSION) 124NVIDIA_DRIVER_DEPENDENCIES += mesa3d-headers 125NVIDIA_DRIVER_PROVIDES += libopencl 126endif 127 128# Build and install the kernel modules if needed 129ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_MODULE),y) 130 131NVIDIA_DRIVER_MODULES = nvidia nvidia-modeset nvidia-drm 132ifeq ($(BR2_x86_64),y) 133NVIDIA_DRIVER_MODULES += nvidia-uvm 134endif 135 136# They can't do everything like everyone. They need those variables, 137# because they don't recognise the usual variables set by the kernel 138# build system. We also need to tell them what modules to build. 139NVIDIA_DRIVER_MODULE_MAKE_OPTS = \ 140 NV_KERNEL_SOURCES="$(LINUX_DIR)" \ 141 NV_KERNEL_OUTPUT="$(LINUX_DIR)" \ 142 NV_KERNEL_MODULES="$(NVIDIA_DRIVER_MODULES)" 143 144NVIDIA_DRIVER_MODULE_SUBDIRS = kernel 145 146$(eval $(kernel-module)) 147 148endif # BR2_PACKAGE_NVIDIA_DRIVER_MODULE == y 149 150# The downloaded archive is in fact an auto-extract script. So, it can run 151# virtually everywhere, and it is fine enough to provide useful options. 152# Except it can't extract into an existing (even empty) directory. 153define NVIDIA_DRIVER_EXTRACT_CMDS 154 $(SHELL) $(NVIDIA_DRIVER_DL_DIR)/$(NVIDIA_DRIVER_SOURCE) --extract-only --target \ 155 $(@D)/tmp-extract 156 chmod u+w -R $(@D) 157 mv $(@D)/tmp-extract/* $(@D)/tmp-extract/.manifest $(@D) 158 rm -rf $(@D)/tmp-extract 159endef 160 161# Helper to install libraries 162# $1: library name 163# $2: target directory 164# 165# For all libraries, we install them and create a symlink using 166# their SONAME, so we can link to them at runtime; we also create 167# the no-version symlink, so we can link to them at build time. 168define NVIDIA_DRIVER_INSTALL_LIB 169 $(INSTALL) -D -m 0644 $(@D)/$(1) $(2)$(notdir $(1)) 170 libsoname="$$( $(TARGET_READELF) -d "$(@D)/$(1)" \ 171 |sed -r -e '/.*\(SONAME\).*\[(.*)\]$$/!d; s//\1/;' )"; \ 172 if [ -n "$${libsoname}" -a "$${libsoname}" != "$(notdir $(1))" ]; then \ 173 ln -sf $(notdir $(1)) $(2)$${libsoname}; \ 174 fi 175 baseso=$(firstword $(subst .,$(space),$(notdir $(1)))).so; \ 176 if [ -n "$${baseso}" -a "$${baseso}" != "$(notdir $(1))" ]; then \ 177 ln -sf $(notdir $(1)) $(2)$${baseso}; \ 178 fi 179endef 180 181# Helper to install libraries 182# $1: destination directory (target or staging) 183define NVIDIA_DRIVER_INSTALL_LIBS 184 $(foreach lib,$(NVIDIA_DRIVER_LIBS), 185 $(call NVIDIA_DRIVER_INSTALL_LIB,$(word 1,$(subst :, ,$(lib))), \ 186 $(1)/usr/lib/$(word 2,$(subst :, ,$(lib)))) 187 ) 188endef 189 190# For staging, install libraries and development files 191define NVIDIA_DRIVER_INSTALL_STAGING_CMDS 192 $(call NVIDIA_DRIVER_INSTALL_LIBS,$(STAGING_DIR)) 193 $(NVIDIA_DRIVER_INSTALL_GL_DEV) 194endef 195 196# For target, install libraries and X.org modules 197define NVIDIA_DRIVER_INSTALL_TARGET_CMDS 198 $(call NVIDIA_DRIVER_INSTALL_LIBS,$(TARGET_DIR)) 199 $(foreach p,$(NVIDIA_DRIVER_PROGS), \ 200 $(INSTALL) -D -m 0755 $(@D)/$(p) \ 201 $(TARGET_DIR)/usr/bin/$(p) 202 ) 203 $(NVIDIA_DRIVER_SYMLINK_LIBGLX) 204 $(NVIDIA_DRIVER_INSTALL_KERNEL_MODULE) 205endef 206 207# Due to a conflict with xserver_xorg-server, this needs to be performed when 208# finalizing the target filesystem to make sure this version is used. 209NVIDIA_DRIVER_TARGET_FINALIZE_HOOKS += NVIDIA_DRIVER_SYMLINK_LIBGLX 210 211$(eval $(generic-package)) 212