blob: 5c45b2bafe1ecac1080b62be99432a09912e6ce0 [file] [log] [blame]
Brad Bishop286d45c2018-10-02 15:21:57 -04001DESCRIPTION = "libGLES for ZynqMP with Mali 400"
2
3LICENSE = "Proprietary"
Andrew Geissler84ad7c52020-06-27 00:00:16 -05004LIC_FILES_CHKSUM = "file://EULA;md5=82e466d0ed92c5a15f568dbe6b31089c"
Brad Bishop286d45c2018-10-02 15:21:57 -04005
Andrew Geissler84ad7c52020-06-27 00:00:16 -05006inherit features_check update-alternatives
Brad Bishop286d45c2018-10-02 15:21:57 -04007
Andrew Geissler84ad7c52020-06-27 00:00:16 -05008ANY_OF_DISTRO_FEATURES = "x11 fbdev wayland"
Brad Bishop286d45c2018-10-02 15:21:57 -04009
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080010PROVIDES += "virtual/libgles1 virtual/libgles2 virtual/egl virtual/libgbm"
Brad Bishop286d45c2018-10-02 15:21:57 -040011
Andrew Geissler84ad7c52020-06-27 00:00:16 -050012FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
Brad Bishop286d45c2018-10-02 15:21:57 -040013
Andrew Geissler84ad7c52020-06-27 00:00:16 -050014REPO ?= "git://github.com/Xilinx/mali-userspace-binaries.git;protocol=https"
Andrew Geissler7eb438a2020-11-30 19:53:16 -060015BRANCH ?= "rel-v2020.2"
Andrew Geissler84ad7c52020-06-27 00:00:16 -050016SRCREV ?= "da73805e3e011382c4d014ac10037cd193aaa9a0"
17BRANCHARG = "${@['nobranch=1', 'branch=${BRANCH}'][d.getVar('BRANCH', True) != '']}"
Brad Bishop286d45c2018-10-02 15:21:57 -040018
Andrew Geissler84ad7c52020-06-27 00:00:16 -050019PV = "r9p0-01rel0"
Brad Bishop286d45c2018-10-02 15:21:57 -040020SRC_URI = " \
Andrew Geissler84ad7c52020-06-27 00:00:16 -050021 ${REPO};${BRANCHARG} \
Brad Bishop286d45c2018-10-02 15:21:57 -040022 file://egl.pc \
23 file://glesv1_cm.pc \
24 file://glesv1.pc \
25 file://glesv2.pc \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080026 file://gbm.pc \
Brad Bishop286d45c2018-10-02 15:21:57 -040027 "
28
Brad Bishop286d45c2018-10-02 15:21:57 -040029COMPATIBLE_MACHINE = "^$"
30COMPATIBLE_MACHINE_zynqmpeg = "zynqmpeg"
31COMPATIBLE_MACHINE_zynqmpev = "zynqmpev"
32
Andrew Geissler7eb438a2020-11-30 19:53:16 -060033PACKAGE_ARCH = "${SOC_VARIANT_ARCH}"
Brad Bishop286d45c2018-10-02 15:21:57 -040034
35
Andrew Geissler84ad7c52020-06-27 00:00:16 -050036S = "${WORKDIR}/git"
Brad Bishop286d45c2018-10-02 15:21:57 -040037
Andrew Geissler84ad7c52020-06-27 00:00:16 -050038# If were switching at runtime, we would need all RDEPENDS needed for all backends available
Brad Bishop286d45c2018-10-02 15:21:57 -040039X11RDEPENDS = "libxdamage libxext libx11 libdrm libxfixes"
40X11DEPENDS = "libxdamage libxext virtual/libx11 libdrm libxfixes"
41
Andrew Geissler84ad7c52020-06-27 00:00:16 -050042# Don't install runtime dependencies for other backends unless the DISTRO supports it
Brad Bishop286d45c2018-10-02 15:21:57 -040043RDEPENDS_${PN} = " \
Andrew Geissler84ad7c52020-06-27 00:00:16 -050044 kernel-module-mali \
45 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '${X11RDEPENDS}', '', d)} \
46"
Brad Bishop286d45c2018-10-02 15:21:57 -040047
Andrew Geissler84ad7c52020-06-27 00:00:16 -050048# We dont build anything but we want to avoid QA warning build-deps
Brad Bishop286d45c2018-10-02 15:21:57 -040049DEPENDS = "\
Andrew Geissler84ad7c52020-06-27 00:00:16 -050050 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '${X11DEPENDS}', '', d)} \
51 ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland libdrm', '', d)} \
52"
53
54
55# x11 is default, set to "fbdev" , "wayland", or "headless" if required
56MALI_BACKEND_DEFAULT ?= "x11"
Brad Bishop286d45c2018-10-02 15:21:57 -040057
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080058USE_X11 = "${@bb.utils.contains("DISTRO_FEATURES", "x11", "yes", "no", d)}"
59USE_FB = "${@bb.utils.contains("DISTRO_FEATURES", "fbdev", "yes", "no", d)}"
60USE_WL = "${@bb.utils.contains("DISTRO_FEATURES", "wayland", "yes", "no", d)}"
Brad Bishop286d45c2018-10-02 15:21:57 -040061
Andrew Geissler84ad7c52020-06-27 00:00:16 -050062MONOLITHIC_LIBMALI = "libMali.so.9.0"
Brad Bishop286d45c2018-10-02 15:21:57 -040063
64do_install() {
65 #Identify the ARCH type
66 ${TARGET_PREFIX}gcc --version > ARCH_PLATFORM
67 if grep -q aarch64 "ARCH_PLATFORM"; then
68 ARCH_PLATFORM_DIR=aarch64-linux-gnu
69 else
70 ARCH_PLATFORM_DIR=arm-linux-gnueabihf
71 fi
72
73 # install headers
74 install -d -m 0655 ${D}${includedir}/EGL
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080075 install -m 0644 ${S}/${PV}/glesHeaders/EGL/*.h ${D}${includedir}/EGL/
Brad Bishop286d45c2018-10-02 15:21:57 -040076 install -d -m 0655 ${D}${includedir}/GLES
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080077 install -m 0644 ${S}/${PV}/glesHeaders/GLES/*.h ${D}${includedir}/GLES/
Brad Bishop286d45c2018-10-02 15:21:57 -040078 install -d -m 0655 ${D}${includedir}/GLES2
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080079 install -m 0644 ${S}/${PV}/glesHeaders/GLES2/*.h ${D}${includedir}/GLES2/
Brad Bishop286d45c2018-10-02 15:21:57 -040080 install -d -m 0655 ${D}${includedir}/KHR
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080081 install -m 0644 ${S}/${PV}/glesHeaders/KHR/*.h ${D}${includedir}/KHR/
Brad Bishop286d45c2018-10-02 15:21:57 -040082
83 install -d ${D}${libdir}/pkgconfig
84 install -m 0644 ${WORKDIR}/egl.pc ${D}${libdir}/pkgconfig/egl.pc
85 install -m 0644 ${WORKDIR}/glesv2.pc ${D}${libdir}/pkgconfig/glesv2.pc
86 install -m 0644 ${WORKDIR}/glesv1.pc ${D}${libdir}/pkgconfig/glesv1.pc
87 install -m 0644 ${WORKDIR}/glesv1_cm.pc ${D}${libdir}/pkgconfig/glesv1_cm.pc
88
89 install -d ${D}${libdir}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080090 install -d ${D}${includedir}
91
92 cp -a --no-preserve=ownership ${S}/${PV}/${ARCH_PLATFORM_DIR}/common/*.so* ${D}${libdir}
93
Andrew Geissler84ad7c52020-06-27 00:00:16 -050094 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/headless/${MONOLITHIC_LIBMALI} ${D}${libdir}/headless/${MONOLITHIC_LIBMALI}
95 ln -snf headless/${MONOLITHIC_LIBMALI} ${D}${libdir}/${MONOLITHIC_LIBMALI}
Brad Bishop286d45c2018-10-02 15:21:57 -040096
Andrew Geissler84ad7c52020-06-27 00:00:16 -050097 if [ "${USE_FB}" = "yes" ]; then
98 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/fbdev/${MONOLITHIC_LIBMALI} ${D}${libdir}/fbdev/${MONOLITHIC_LIBMALI}
99 if [ "${MALI_BACKEND_DEFAULT}" = "fbdev" ]; then
100 ln -snf fbdev/${MONOLITHIC_LIBMALI} ${D}${libdir}/${MONOLITHIC_LIBMALI}
101 fi
102 fi
103 if [ "${USE_X11}" = "yes" ]; then
104 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/x11/${MONOLITHIC_LIBMALI} ${D}${libdir}/x11/${MONOLITHIC_LIBMALI}
105 if [ "${MALI_BACKEND_DEFAULT}" = "x11" ]; then
106 ln -snf x11/${MONOLITHIC_LIBMALI} ${D}${libdir}/${MONOLITHIC_LIBMALI}
107 fi
108 else
109 # We cant rely on the fact that all apps will use pkgconfig correctly
Brad Bishop286d45c2018-10-02 15:21:57 -0400110 sed -i -e 's/^#if defined(MESA_EGL_NO_X11_HEADERS)$/#if (1)/' ${D}${includedir}/EGL/eglplatform.h
111 fi
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500112 if [ "${USE_WL}" = "yes" ]; then
113 install -m 0644 ${S}/${PV}/glesHeaders/GBM/gbm.h ${D}${includedir}/
114 install -m 0644 ${WORKDIR}/gbm.pc ${D}${libdir}/pkgconfig/gbm.pc
115 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/wayland/${MONOLITHIC_LIBMALI} ${D}${libdir}/wayland/${MONOLITHIC_LIBMALI}
116 if [ "${MALI_BACKEND_DEFAULT}" = "wayland" ]; then
117 ln -snf wayland/${MONOLITHIC_LIBMALI} ${D}${libdir}/${MONOLITHIC_LIBMALI}
118 fi
119 fi
120}
121
122
123# We need separate packages to provide multiple alternatives, at this point we install
124# everything on the default one but that can be split if necessary
125PACKAGES += "${PN}-x11 ${PN}-fbdev ${PN}-wayland ${PN}-headless"
126
127# This is default/common for all alternatives
128ALTERNATIVE_LINK_NAME[libmali-xlnx] = "${libdir}/${MONOLITHIC_LIBMALI}"
129
130
131# Declare alternatives and corresponding library location
132ALTERNATIVE_${PN}-x11 = "libmali-xlnx"
133ALTERNATIVE_TARGET_libmali-xlnx-x11[libmali-xlnx] = "${libdir}/x11/${MONOLITHIC_LIBMALI}"
134
135ALTERNATIVE_${PN}-fbdev = "libmali-xlnx"
136ALTERNATIVE_TARGET_libmali-xlnx-fbdev[libmali-xlnx] = "${libdir}/fbdev/${MONOLITHIC_LIBMALI}"
137
138ALTERNATIVE_${PN}-wayland = "libmali-xlnx"
139ALTERNATIVE_TARGET_libmali-xlnx-wayland[libmali-xlnx] = "${libdir}/wayland/${MONOLITHIC_LIBMALI}"
140
141ALTERNATIVE_${PN}-headless = "libmali-xlnx"
142ALTERNATIVE_TARGET_libmali-xlnx-headless[libmali-xlnx] = "${libdir}/headless/${MONOLITHIC_LIBMALI}"
143
144# Set priorities according to what we prveiously defined
145ALTERNATIVE_PRIORITY_libmali-xlnx-x11[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "x11", "20", "10", d)}"
146ALTERNATIVE_PRIORITY_libmali-xlnx-fbdev[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "fbdev", "20", "10", d)}"
147ALTERNATIVE_PRIORITY_libmali-xlnx-wayland[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "wayland", "20", "10", d)}"
148
149# If misconfigured, fallback to headless
150ALTERNATIVE_PRIORITY_libmali-xlnx-headless[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "headless", "20", "15", d)}"
151
152
153# Package gets renamed on the debian class, but we want to keep -xlnx
154DEBIAN_NOAUTONAME_libmali-xlnx = "1"
155
156# Update alternatives will actually have separate postinst scripts (one for each package)
157# This wont work for us, so we create a common postinst script and we pass that as the general
158# libmali-xlnx postinst script, but we defer execution to run on first boot (pkg_postinst_ontarget).
159# This will avoid ldconfig removing the symbolic links when creating the root filesystem.
160python populate_packages_updatealternatives_append () {
161 # We need to remove the 'fake' libmali-xlnx before creating any links
162 libdir = d.getVar('libdir')
163 common_postinst = "#!/bin/sh\nrm " + libdir + "/${MONOLITHIC_LIBMALI}\n"
164 for pkg in (d.getVar('PACKAGES') or "").split():
165 # Not all packages provide an alternative (e.g. ${PN}-lic)
166 postinst = d.getVar('pkg_postinst_%s' % pkg)
167 if postinst:
168 old_postinst = postinst
169 new_postinst = postinst.replace('#!/bin/sh','')
170 common_postinst += new_postinst
171 d.setVar('pkg_postinst_ontarget_%s' % 'libmali-xlnx', common_postinst)
Brad Bishop286d45c2018-10-02 15:21:57 -0400172}
173
174
175# Inhibit warnings about files being stripped
176INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
177INHIBIT_PACKAGE_STRIP = "1"
178INHIBIT_SYSROOT_STRIP = "1"
179
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800180RREPLACES_${PN} = "libegl libgles1 libglesv1-cm1 libgles2 libglesv2-2 libgbm"
181RPROVIDES_${PN} = "libegl libgles1 libglesv1-cm1 libgles2 libglesv2-2 libgbm"
182RCONFLICTS_${PN} = "libegl libgles1 libglesv1-cm1 libgles2 libglesv2-2 libgbm"
Brad Bishop286d45c2018-10-02 15:21:57 -0400183
184# These libraries shouldn't get installed in world builds unless something
185# explicitly depends upon them.
186EXCLUDE_FROM_WORLD = "1"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800187FILES_${PN} += "${libdir}/*"
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500188
189do_package_append() {
190
191 shlibswork_dir = d.getVar('SHLIBSWORKDIR')
192 pkg_filename = d.getVar('PN') + ".list"
193 shlibs_file = os.path.join(shlibswork_dir, pkg_filename)
194 lines = ""
195 with open(shlibs_file, "r") as f:
196 lines = f.readlines()
197 with open(shlibs_file, "w") as f:
198 for line in lines:
199 if d.getVar('MALI_BACKEND_DEFAULT') in line.strip("\n"):
200 f.write(line)
201}