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