Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 1 | DESCRIPTION = "libGLES for ZynqMP with Mali 400" |
| 2 | |
| 3 | LICENSE = "Proprietary" |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 4 | LIC_FILES_CHKSUM = "file://EULA;md5=82e466d0ed92c5a15f568dbe6b31089c" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 5 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 6 | inherit features_check update-alternatives |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 7 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 8 | ANY_OF_DISTRO_FEATURES = "x11 fbdev wayland" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 9 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 10 | PROVIDES += "virtual/libgles1 virtual/libgles2 virtual/egl virtual/libgbm" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 11 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 12 | FILESEXTRAPATHS_prepend := "${THISDIR}/files:" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 13 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 14 | REPO ?= "git://github.com/Xilinx/mali-userspace-binaries.git;protocol=https" |
Andrew Geissler | 7eb438a | 2020-11-30 19:53:16 -0600 | [diff] [blame] | 15 | BRANCH ?= "rel-v2020.2" |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 16 | SRCREV ?= "da73805e3e011382c4d014ac10037cd193aaa9a0" |
| 17 | BRANCHARG = "${@['nobranch=1', 'branch=${BRANCH}'][d.getVar('BRANCH', True) != '']}" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 18 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 19 | PV = "r9p0-01rel0" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 20 | SRC_URI = " \ |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 21 | ${REPO};${BRANCHARG} \ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 22 | file://egl.pc \ |
| 23 | file://glesv1_cm.pc \ |
| 24 | file://glesv1.pc \ |
| 25 | file://glesv2.pc \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 26 | file://gbm.pc \ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 27 | " |
| 28 | |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 29 | COMPATIBLE_MACHINE = "^$" |
| 30 | COMPATIBLE_MACHINE_zynqmpeg = "zynqmpeg" |
| 31 | COMPATIBLE_MACHINE_zynqmpev = "zynqmpev" |
| 32 | |
Andrew Geissler | 7eb438a | 2020-11-30 19:53:16 -0600 | [diff] [blame] | 33 | PACKAGE_ARCH = "${SOC_VARIANT_ARCH}" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 34 | |
| 35 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 36 | S = "${WORKDIR}/git" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 37 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 38 | # If were switching at runtime, we would need all RDEPENDS needed for all backends available |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 39 | X11RDEPENDS = "libxdamage libxext libx11 libdrm libxfixes" |
| 40 | X11DEPENDS = "libxdamage libxext virtual/libx11 libdrm libxfixes" |
| 41 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 42 | # Don't install runtime dependencies for other backends unless the DISTRO supports it |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 43 | RDEPENDS_${PN} = " \ |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 44 | kernel-module-mali \ |
| 45 | ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '${X11RDEPENDS}', '', d)} \ |
| 46 | " |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 47 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 48 | # We dont build anything but we want to avoid QA warning build-deps |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 49 | DEPENDS = "\ |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 50 | ${@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 |
| 56 | MALI_BACKEND_DEFAULT ?= "x11" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 57 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 58 | USE_X11 = "${@bb.utils.contains("DISTRO_FEATURES", "x11", "yes", "no", d)}" |
| 59 | USE_FB = "${@bb.utils.contains("DISTRO_FEATURES", "fbdev", "yes", "no", d)}" |
| 60 | USE_WL = "${@bb.utils.contains("DISTRO_FEATURES", "wayland", "yes", "no", d)}" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 61 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 62 | MONOLITHIC_LIBMALI = "libMali.so.9.0" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 63 | |
| 64 | do_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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 75 | install -m 0644 ${S}/${PV}/glesHeaders/EGL/*.h ${D}${includedir}/EGL/ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 76 | install -d -m 0655 ${D}${includedir}/GLES |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 77 | install -m 0644 ${S}/${PV}/glesHeaders/GLES/*.h ${D}${includedir}/GLES/ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 78 | install -d -m 0655 ${D}${includedir}/GLES2 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 79 | install -m 0644 ${S}/${PV}/glesHeaders/GLES2/*.h ${D}${includedir}/GLES2/ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 80 | install -d -m 0655 ${D}${includedir}/KHR |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 81 | install -m 0644 ${S}/${PV}/glesHeaders/KHR/*.h ${D}${includedir}/KHR/ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 82 | |
| 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 90 | install -d ${D}${includedir} |
| 91 | |
| 92 | cp -a --no-preserve=ownership ${S}/${PV}/${ARCH_PLATFORM_DIR}/common/*.so* ${D}${libdir} |
| 93 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 94 | 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 Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 96 | |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 97 | 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 Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 110 | sed -i -e 's/^#if defined(MESA_EGL_NO_X11_HEADERS)$/#if (1)/' ${D}${includedir}/EGL/eglplatform.h |
| 111 | fi |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 112 | 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 |
| 125 | PACKAGES += "${PN}-x11 ${PN}-fbdev ${PN}-wayland ${PN}-headless" |
| 126 | |
| 127 | # This is default/common for all alternatives |
| 128 | ALTERNATIVE_LINK_NAME[libmali-xlnx] = "${libdir}/${MONOLITHIC_LIBMALI}" |
| 129 | |
| 130 | |
| 131 | # Declare alternatives and corresponding library location |
| 132 | ALTERNATIVE_${PN}-x11 = "libmali-xlnx" |
| 133 | ALTERNATIVE_TARGET_libmali-xlnx-x11[libmali-xlnx] = "${libdir}/x11/${MONOLITHIC_LIBMALI}" |
| 134 | |
| 135 | ALTERNATIVE_${PN}-fbdev = "libmali-xlnx" |
| 136 | ALTERNATIVE_TARGET_libmali-xlnx-fbdev[libmali-xlnx] = "${libdir}/fbdev/${MONOLITHIC_LIBMALI}" |
| 137 | |
| 138 | ALTERNATIVE_${PN}-wayland = "libmali-xlnx" |
| 139 | ALTERNATIVE_TARGET_libmali-xlnx-wayland[libmali-xlnx] = "${libdir}/wayland/${MONOLITHIC_LIBMALI}" |
| 140 | |
| 141 | ALTERNATIVE_${PN}-headless = "libmali-xlnx" |
| 142 | ALTERNATIVE_TARGET_libmali-xlnx-headless[libmali-xlnx] = "${libdir}/headless/${MONOLITHIC_LIBMALI}" |
| 143 | |
| 144 | # Set priorities according to what we prveiously defined |
| 145 | ALTERNATIVE_PRIORITY_libmali-xlnx-x11[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "x11", "20", "10", d)}" |
| 146 | ALTERNATIVE_PRIORITY_libmali-xlnx-fbdev[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "fbdev", "20", "10", d)}" |
| 147 | ALTERNATIVE_PRIORITY_libmali-xlnx-wayland[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "wayland", "20", "10", d)}" |
| 148 | |
| 149 | # If misconfigured, fallback to headless |
| 150 | ALTERNATIVE_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 |
| 154 | DEBIAN_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. |
| 160 | python 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 Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | |
| 175 | # Inhibit warnings about files being stripped |
| 176 | INHIBIT_PACKAGE_DEBUG_SPLIT = "1" |
| 177 | INHIBIT_PACKAGE_STRIP = "1" |
| 178 | INHIBIT_SYSROOT_STRIP = "1" |
| 179 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 180 | RREPLACES_${PN} = "libegl libgles1 libglesv1-cm1 libgles2 libglesv2-2 libgbm" |
| 181 | RPROVIDES_${PN} = "libegl libgles1 libglesv1-cm1 libgles2 libglesv2-2 libgbm" |
| 182 | RCONFLICTS_${PN} = "libegl libgles1 libglesv1-cm1 libgles2 libglesv2-2 libgbm" |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 183 | |
| 184 | # These libraries shouldn't get installed in world builds unless something |
| 185 | # explicitly depends upon them. |
| 186 | EXCLUDE_FROM_WORLD = "1" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 187 | FILES_${PN} += "${libdir}/*" |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 188 | |
| 189 | do_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 | } |