|
| 1 | +# Copyright 1999-2019 Gentoo Foundation |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | +# $Header: /var/cvsroot/gentoo-x86/media-libs/mesa/mesa-7.9.ebuild,v 1.3 2010/12/05 17:19:14 arfrever Exp $ |
| 4 | + |
| 5 | +EAPI=6 |
| 6 | + |
| 7 | +MESON_AUTO_DEPEND=no |
| 8 | + |
| 9 | +CROS_WORKON_COMMIT="b38c32a57380c228813ec59823fd5510ee93ce4c" |
| 10 | +CROS_WORKON_TREE="70ca3580767be0529cf99593c94d7d7f8ef6abac" |
| 11 | + |
| 12 | +EGIT_REPO_URI="git://anongit.freedesktop.org/mesa/mesa" |
| 13 | +CROS_WORKON_PROJECT="chromiumos/third_party/mesa" |
| 14 | +CROS_WORKON_BLACKLIST="1" |
| 15 | + |
| 16 | +if [[ ${PV} = 9999* ]]; then |
| 17 | + GIT_ECLASS="git-2" |
| 18 | + EXPERIMENTAL="true" |
| 19 | +fi |
| 20 | + |
| 21 | +inherit base multilib flag-o-matic meson toolchain-funcs ${GIT_ECLASS} cros-workon |
| 22 | + |
| 23 | +FOLDER="${PV/_rc*/}" |
| 24 | +[[ ${PV/_rc*/} == ${PV} ]] || FOLDER+="/RC" |
| 25 | + |
| 26 | +DESCRIPTION="OpenGL-like graphic library for Linux" |
| 27 | +HOMEPAGE="http://mesa3d.sourceforge.net/" |
| 28 | + |
| 29 | +#SRC_PATCHES="mirror://gentoo/${P}-gentoo-patches-01.tar.bz2" |
| 30 | +if [[ $PV = 9999* ]] || [[ -n ${CROS_WORKON_COMMIT} ]]; then |
| 31 | + SRC_URI="${SRC_PATCHES}" |
| 32 | +else |
| 33 | + SRC_URI="ftp://ftp.freedesktop.org/pub/mesa/${FOLDER}/${P}.tar.bz2 |
| 34 | + ${SRC_PATCHES}" |
| 35 | +fi |
| 36 | + |
| 37 | +# Most of the code is MIT/X11. |
| 38 | +# ralloc is LGPL-3 |
| 39 | +# GLES[2]/gl[2]{,ext,platform}.h are SGI-B-2.0 |
| 40 | +LICENSE="MIT LGPL-3 SGI-B-2.0" |
| 41 | +SLOT="0" |
| 42 | +KEYWORDS="*" |
| 43 | + |
| 44 | +INTEL_CARDS="intel" |
| 45 | +RADEON_CARDS="amdgpu radeon" |
| 46 | +VIDEO_CARDS="${INTEL_CARDS} ${RADEON_CARDS} freedreno llvmpipe mach64 mga nouveau r128 radeonsi savage sis softpipe tdfx via virgl vmware vc4 v3d" |
| 47 | +for card in ${VIDEO_CARDS}; do |
| 48 | + IUSE_VIDEO_CARDS+=" video_cards_${card}" |
| 49 | +done |
| 50 | + |
| 51 | +IUSE="${IUSE_VIDEO_CARDS} |
| 52 | + +classic debug dri drm egl +gallium -gbm gles1 gles2 kernel_FreeBSD |
| 53 | + kvm_guest llvm +nptl pic selinux shared-glapi vulkan wayland xlib-glx X" |
| 54 | + |
| 55 | +LIBDRM_DEPSTRING=">=x11-libs/libdrm-2.4.60" |
| 56 | + |
| 57 | +REQUIRED_USE="video_cards_amdgpu? ( llvm ) |
| 58 | + video_cards_llvmpipe? ( llvm )" |
| 59 | + |
| 60 | +# keep correct libdrm and dri2proto dep |
| 61 | +# keep blocks in rdepend for binpkg |
| 62 | +RDEPEND=" |
| 63 | + X? ( |
| 64 | + !<x11-base/xorg-server-1.7 |
| 65 | + >=x11-libs/libX11-1.3.99.901 |
| 66 | + x11-libs/libXdamage |
| 67 | + x11-libs/libXext |
| 68 | + x11-libs/libXrandr |
| 69 | + x11-libs/libXxf86vm |
| 70 | + ) |
| 71 | + llvm? ( virtual/libelf ) |
| 72 | + dev-libs/expat |
| 73 | + dev-libs/libgcrypt |
| 74 | + virtual/udev |
| 75 | + ${LIBDRM_DEPSTRING} |
| 76 | +" |
| 77 | + |
| 78 | +DEPEND="${RDEPEND} |
| 79 | + dev-libs/libxml2 |
| 80 | + sys-devel/bison |
| 81 | + sys-devel/flex |
| 82 | + virtual/pkgconfig |
| 83 | + x11-base/xorg-proto |
| 84 | + wayland? ( >=dev-libs/wayland-protocols-1.8 ) |
| 85 | + llvm? ( sys-devel/llvm ) |
| 86 | +" |
| 87 | + |
| 88 | +driver_list() { |
| 89 | + local drivers="$(sort -u <<< "${1// /$'\n'}")" |
| 90 | + echo "${drivers//$'\n'/,}" |
| 91 | +} |
| 92 | + |
| 93 | +src_prepare() { |
| 94 | + # apply patches |
| 95 | + if [[ ${PV} != 9999* && -n ${SRC_PATCHES} ]]; then |
| 96 | + EPATCH_FORCE="yes" \ |
| 97 | + EPATCH_SOURCE="${WORKDIR}/patches" \ |
| 98 | + EPATCH_SUFFIX="patch" \ |
| 99 | + epatch |
| 100 | + fi |
| 101 | + # FreeBSD 6.* doesn't have posix_memalign(). |
| 102 | + if [[ ${CHOST} == *-freebsd6.* ]]; then |
| 103 | + sed -i \ |
| 104 | + -e "s/-DHAVE_POSIX_MEMALIGN//" \ |
| 105 | + configure.ac || die |
| 106 | + fi |
| 107 | + |
| 108 | + default |
| 109 | +} |
| 110 | + |
| 111 | +src_configure() { |
| 112 | + tc-getPROG PKG_CONFIG pkg-config |
| 113 | + |
| 114 | + cros_optimize_package_for_speed |
| 115 | + # For llvmpipe on ARM we'll get errors about being unable to resolve |
| 116 | + # "__aeabi_unwind_cpp_pr1" if we don't include this flag; seems wise |
| 117 | + # to include it for all platforms though. |
| 118 | + use video_cards_llvmpipe && append-flags "-rtlib=libgcc -shared-libgcc" |
| 119 | + |
| 120 | + if use !gallium && use !classic && use !vulkan; then |
| 121 | + ewarn "You enabled neither classic, gallium, nor vulkan " |
| 122 | + ewarn "USE flags. No hardware drivers will be built." |
| 123 | + fi |
| 124 | + |
| 125 | + if use classic; then |
| 126 | + # Configurable DRI drivers |
| 127 | + # Intel code |
| 128 | + dri_driver_enable video_cards_intel i965 |
| 129 | + fi |
| 130 | + |
| 131 | + if use gallium; then |
| 132 | + # Configurable gallium drivers |
| 133 | + gallium_enable video_cards_llvmpipe swrast |
| 134 | + gallium_enable video_cards_softpipe swrast |
| 135 | + |
| 136 | + # Nouveau code |
| 137 | + gallium_enable video_cards_nouveau nouveau |
| 138 | + |
| 139 | + # ATI code |
| 140 | + gallium_enable video_cards_radeon r300 r600 |
| 141 | + gallium_enable video_cards_amdgpu radeonsi |
| 142 | + |
| 143 | + # Freedreno code |
| 144 | + gallium_enable video_cards_freedreno freedreno |
| 145 | + |
| 146 | + gallium_enable video_cards_virgl virgl |
| 147 | + gallium_enable video_cards_vc4 vc4 |
| 148 | + gallium_enable video_cards_v3d v3d |
| 149 | + fi |
| 150 | + |
| 151 | + if use vulkan; then |
| 152 | + vulkan_enable video_cards_intel intel |
| 153 | + vulkan_enable video_cards_amdgpu amd |
| 154 | + fi |
| 155 | + |
| 156 | + LLVM_ENABLE=false |
| 157 | + if use llvm && use !video_cards_softpipe; then |
| 158 | + emesonargs+=( -Dshared-llvm=false ) |
| 159 | + export LLVM_CONFIG=${SYSROOT}/usr/lib/llvm/bin/llvm-config-host |
| 160 | + LLVM_ENABLE=true |
| 161 | + fi |
| 162 | + |
| 163 | + local egl_platforms="" |
| 164 | + if use egl; then |
| 165 | + egl_platforms="surfaceless" |
| 166 | + |
| 167 | + if use drm; then |
| 168 | + egl_platforms="${egl_platforms},drm" |
| 169 | + fi |
| 170 | + |
| 171 | + if use wayland; then |
| 172 | + egl_platforms="${egl_platforms},wayland" |
| 173 | + fi |
| 174 | + |
| 175 | + if use X; then |
| 176 | + egl_platforms="${egl_platforms},x11" |
| 177 | + fi |
| 178 | + fi |
| 179 | + |
| 180 | + if use X; then |
| 181 | + glx="dri" |
| 182 | + else |
| 183 | + glx="disabled" |
| 184 | + fi |
| 185 | + |
| 186 | + append-flags "-UENABLE_SHADER_CACHE" |
| 187 | + |
| 188 | + if use kvm_guest; then |
| 189 | + emesonargs+=( -Ddri-search-path=/opt/google/cros-containers/lib ) |
| 190 | + fi |
| 191 | + |
| 192 | + emesonargs+=( |
| 193 | + -Dglx="${glx}" |
| 194 | + -Dllvm="${LLVM_ENABLE}" |
| 195 | + -Dplatforms="${egl_platforms}" |
| 196 | + $(meson_use egl) |
| 197 | + $(meson_use gbm) |
| 198 | + $(meson_use X gl) |
| 199 | + $(meson_use gles1) |
| 200 | + $(meson_use gles2) |
| 201 | + $(meson_use selinux) |
| 202 | + -Ddri-drivers=$(driver_list "${DRI_DRIVERS[*]}") |
| 203 | + -Dgallium-drivers=$(driver_list "${GALLIUM_DRIVERS[*]}") |
| 204 | + -Dvulkan-drivers=$(driver_list "${VULKAN_DRIVERS[*]}") |
| 205 | + --buildtype $(usex debug debug release) |
| 206 | + ) |
| 207 | + |
| 208 | + meson_src_configure |
| 209 | +} |
| 210 | + |
| 211 | +src_install() { |
| 212 | + meson_src_install |
| 213 | + |
| 214 | + # Remove redundant GLES headers |
| 215 | + rm -f "${D}"/usr/include/{EGL,GLES2,GLES3,KHR}/*.h || die "Removing GLES headers failed." |
| 216 | + |
| 217 | + dodir /usr/$(get_libdir)/dri |
| 218 | + insinto "/usr/$(get_libdir)/dri/" |
| 219 | + insopts -m0755 |
| 220 | + # install the gallium drivers we use |
| 221 | + local gallium_drivers_files=( nouveau_dri.so r300_dri.so r600_dri.so msm_dri.so swrast_dri.so vc4_dri.so v3d_dri.so ) |
| 222 | + for x in ${gallium_drivers_files[@]}; do |
| 223 | + if [ -f "${S}/$(get_libdir)/gallium/${x}" ]; then |
| 224 | + doins "${S}/$(get_libdir)/gallium/${x}" |
| 225 | + fi |
| 226 | + done |
| 227 | + |
| 228 | + # install classic drivers we use |
| 229 | + local classic_drivers_files=( i810_dri.so i965_dri.so nouveau_vieux_dri.so radeon_dri.so r200_dri.so ) |
| 230 | + for x in ${classic_drivers_files[@]}; do |
| 231 | + if [ -f "${S}/$(get_libdir)/${x}" ]; then |
| 232 | + doins "${S}/$(get_libdir)/${x}" |
| 233 | + fi |
| 234 | + done |
| 235 | + |
| 236 | + # Set driconf option to enable S3TC hardware decompression |
| 237 | + insinto "/etc/" |
| 238 | + doins "${FILESDIR}"/drirc |
| 239 | +} |
| 240 | + |
| 241 | +# $1 - VIDEO_CARDS flag (check skipped for "--") |
| 242 | +# other args - names of DRI drivers to enable |
| 243 | +dri_driver_enable() { |
| 244 | + if [[ $1 == -- ]] || use $1; then |
| 245 | + shift |
| 246 | + DRI_DRIVERS+=("$@") |
| 247 | + fi |
| 248 | +} |
| 249 | + |
| 250 | +gallium_enable() { |
| 251 | + if [[ $1 == -- ]] || use $1; then |
| 252 | + shift |
| 253 | + GALLIUM_DRIVERS+=("$@") |
| 254 | + fi |
| 255 | +} |
| 256 | + |
| 257 | +vulkan_enable() { |
| 258 | + if [[ $1 == -- ]] || use $1; then |
| 259 | + shift |
| 260 | + VULKAN_DRIVERS+=("$@") |
| 261 | + fi |
| 262 | +} |
0 commit comments