The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / nvidia-driver / nvidia-driver.mk
1 ################################################################################
2 #
3 # nvidia-driver
4 #
5 ################################################################################
6
7 NVIDIA_DRIVER_VERSION = 346.35
8 NVIDIA_DRIVER_SUFFIX = $(if $(BR2_x86_64),_64)
9 NVIDIA_DRIVER_SITE = ftp://download.nvidia.com/XFree86/Linux-x86$(NVIDIA_DRIVER_SUFFIX)/$(NVIDIA_DRIVER_VERSION)
10 NVIDIA_DRIVER_SOURCE = NVIDIA-Linux-x86$(NVIDIA_DRIVER_SUFFIX)-$(NVIDIA_DRIVER_VERSION).run
11 NVIDIA_DRIVER_LICENSE = NVIDIA Software License
12 NVIDIA_DRIVER_LICENSE_FILES = LICENSE
13 NVIDIA_DRIVER_REDISTRIBUTE = NO
14 NVIDIA_DRIVER_INSTALL_STAGING = YES
15
16 ifeq ($(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.
23 NVIDIA_DRIVER_DEPENDENCIES = mesa3d-headers xlib_libX11 xlib_libXext
24 NVIDIA_DRIVER_PROVIDES = libgl libegl libgles
25
26 # We have two variables that contains a list of libraries to install:
27 #   NVIDIA_DRIVER_LIBS
28 #       contains the libraries whose filename end up in .so.$(VERSION); rather
29 #       than duplicate the version string for all of them, we just store their
30 #       basename, and append the version string below.
31 #   NVIDIA_DRIVER_LIBS_NO_VERSION
32 #       contains all libraries the do not use the NVidia version; since there
33 #       is currently only one such library, we store its full name.
34
35 # Each line corresponds to a specific set of libraries
36 NVIDIA_DRIVER_LIBS = \
37         libEGL libGLESv1_CM libGLESv2 libGL \
38         libnvidia-glcore libnvidia-eglcore libnvidia-glsi \
39         tls/libnvidia-tls \
40         libvdpau libvdpau_nvidia \
41         libnvidia-ml
42
43 # Install the gl.pc file
44 define NVIDIA_DRIVER_INSTALL_GL_DEV
45         $(INSTALL) -D -m 0644 $(@D)/libGL.la $(STAGING_DIR)/usr/lib/libGL.la
46         $(SED) 's:__GENERATED_BY__:Buildroot:' $(STAGING_DIR)/usr/lib/libGL.la
47         $(SED) 's:__LIBGL_PATH__:/usr/lib:' $(STAGING_DIR)/usr/lib/libGL.la
48         $(SED) 's:-L[^[:space:]]\+::' $(STAGING_DIR)/usr/lib/libGL.la
49         $(INSTALL) -D -m 0644 package/nvidia-driver/gl.pc $(STAGING_DIR)/usr/lib/pkgconfig/gl.pc
50 endef
51
52 # Those libraries are 'private' libraries requiring an agreement with
53 # NVidia to develop code for those libs. There seems to be no restriction
54 # on using those libraries (e.g. if the user has such an agreement, or
55 # wants to run a third-party program developped under such an agreement).
56 ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_PRIVATE_LIBS),y)
57 NVIDIA_DRIVER_LIBS += libnvidia-ifr libnvidia-fbc
58 endif
59
60 # We refer to the destination path; the origin file has no directory component
61 NVIDIA_DRIVER_X_MODS = drivers/nvidia_drv.so \
62         extensions/libglx.so.$(NVIDIA_DRIVER_VERSION) \
63         libnvidia-wfb.so.$(NVIDIA_DRIVER_VERSION)
64
65 endif # X drivers
66
67 ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_CUDA),y)
68 NVIDIA_DRIVER_LIBS += libcuda libnvidia-compiler libnvcuvid libnvidia-encode
69 ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_CUDA_PROGS),y)
70 NVIDIA_DRIVER_PROGS = nvidia-cuda-mps-control nvidia-cuda-mps-server
71 endif
72 endif
73
74 ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_OPENCL),y)
75 NVIDIA_DRIVER_LIBS_NO_VERSION += libOpenCL.so.1.0.0
76 NVIDIA_DRIVER_LIBS += libnvidia-opencl
77 endif
78
79 # The downloaded archive is in fact an auto-extract script. So, it can run
80 # virtually everywhere, and it is fine enough to provide useful options.
81 # Except it can't extract into an existing (even empty) directory.
82 define NVIDIA_DRIVER_EXTRACT_CMDS
83         $(SHELL) $(DL_DIR)/$(NVIDIA_DRIVER_SOURCE) --extract-only --target \
84                 $(@D)/tmp-extract
85         mv $(@D)/tmp-extract/* $(@D)/tmp-extract/.manifest $(@D)
86         rm -rf $(@D)/tmp-extract
87 endef
88
89 # Build and install the kernel modules if needed
90 ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_MODULE),y)
91
92 NVIDIA_DRIVER_DEPENDENCIES += linux
93
94 # NVidia uses the legacy naming scheme for the x86 architecture, when i386
95 # and x86_64 were still considered two separate architectures in the Linux
96 # kernel.
97 NVIDIA_DRIVER_ARCH = $(if $(BR2_i386),i386,$(BR2_ARCH))
98
99 NVIDIA_DRIVER_MOD_DIRS = kernel
100 NVIDIA_DRIVER_MOD_FILES = kernel/nvidia.ko
101 # nvidia-uvm.ko only available for x86_64
102 ifeq ($(BR2_x86_64)$(BR2_PACKAGE_NVIDIA_DRIVER_CUDA),yy)
103 NVIDIA_DRIVER_MOD_DIRS += kernel/uvm
104 NVIDIA_DRIVER_MOD_FILES += kernel/uvm/nvidia-uvm.ko
105 endif
106
107 # We can not use '$(MAKE) -C $(@D)/$${dir}' because NVidia's uses its own
108 # Makefile to build a kernel module, which includes a lot of assumptions
109 # on where to find its own sub-Makefile fragments, and fails if make is
110 # not run from the directory where the module's source files are. Hence
111 # our little trick to cd in there first.
112 # That's also the reason why we do not use LINUX_MAKE_FLAGS or the other
113 # linux-specific variables, since NVidia's Makefile does not understand
114 # them.
115 define NVIDIA_DRIVER_BUILD_CMDS
116         for dir in $(NVIDIA_DRIVER_MOD_DIRS); do \
117                 (cd $(@D)/$${dir} && \
118                   $(MAKE) SYSSRC="$(LINUX_DIR)" SYSOUT="$(LINUX_DIR)" \
119                                 CC="$(TARGET_CC)" LD="$(TARGET_LD)" HOSTCC="$(HOSTCC)" \
120                                 ARCH=$(NVIDIA_DRIVER_ARCH) module) || exit 1; \
121         done
122 endef
123
124 # We do not use module-install because NVidia's Makefile requires root.
125 # Also, we do not install it in the expected location (in nvidia/ rather
126 # than in kernel/drivers/video/)
127 define NVIDIA_DRIVER_INSTALL_KERNEL_MODULE
128         for mod in $(NVIDIA_DRIVER_MOD_FILES); do \
129                 $(INSTALL) -D -m 0644 $(@D)/$${mod} \
130                         $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/nvidia/$${mod##*/} \
131                 || exit 1; \
132         done
133         $(HOST_DIR)/sbin/depmod -a -b $(TARGET_DIR) $(LINUX_VERSION_PROBED)
134 endef
135
136 endif # BR2_PACKAGE_NVIDIA_DRIVER_MODULE == y
137
138 # Helper to install libraries
139 # $1: destination directory (target or staging)
140 #
141 # For all libraries that need it, we append the NVidia version string.
142 # Then for all libraries, we install them and create a symlink using
143 # their SONAME, so we can link to them at runtime; we also create the
144 # no-version symlink, so we can link to them at build time.
145 define NVIDIA_DRIVER_INSTALL_LIBS
146         for libpath in $(addsuffix .so.$(NVIDIA_DRIVER_VERSION),$(NVIDIA_DRIVER_LIBS)) \
147                    $(NVIDIA_DRIVER_LIBS_NO_VERSION); \
148         do \
149                 libname="$${libpath##*/}"; \
150                 $(INSTALL) -D -m 0644 $(@D)/$${libpath} $(1)/usr/lib/$${libname}; \
151                 libsoname="$$( $(TARGET_READELF) -d "$(@D)/$${libpath}" \
152                        |sed -r -e '/.*\(SONAME\).*\[(.*)\]$$/!d; s//\1/;' )"; \
153                 if [ -n "$${libsoname}" -a "$${libsoname}" != "$${libname}" ]; then \
154                         ln -sf $${libname} $(1)/usr/lib/$${libsoname}; \
155                 fi; \
156                 baseso="$${libname/.so*}.so"; \
157                 if [ -n "$${baseso}" -a "$${baseso}" != "$${libname}" ]; then \
158                         ln -sf $${libname} $(1)/usr/lib/$${baseso}; \
159                 fi; \
160         done
161 endef
162
163 # For staging, install libraries and development files
164 define NVIDIA_DRIVER_INSTALL_STAGING_CMDS
165         $(call NVIDIA_DRIVER_INSTALL_LIBS,$(STAGING_DIR))
166         $(NVIDIA_DRIVER_INSTALL_GL_DEV)
167 endef
168
169 # For target, install libraries and X.org modules
170 define NVIDIA_DRIVER_INSTALL_TARGET_CMDS
171         $(call NVIDIA_DRIVER_INSTALL_LIBS,$(TARGET_DIR))
172         for m in $(NVIDIA_DRIVER_X_MODS); do \
173                 $(INSTALL) -D -m 0644 $(@D)/$${m##*/} \
174                         $(TARGET_DIR)/usr/lib/xorg/modules/$${m}; \
175         done
176         for p in $(NVIDIA_DRIVER_PROGS); do \
177                 $(INSTALL) -D -m 0755 $(@D)/$${p} \
178                         $(TARGET_DIR)/usr/bin/$${p}; \
179         done
180         $(NVIDIA_DRIVER_INSTALL_KERNEL_MODULE)
181 endef
182
183 $(eval $(generic-package))