nvidia-driver.mk 7.3 KB

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