| 1 |
# Copyright 1999-2012 Gentoo Foundation |
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
# $Header: /var/cvsroot/gentoo-x86/media-libs/mesa/mesa-8.1_rc1_pre20120724.ebuild,v 1.7 2012/10/05 06:08:59 naota Exp $ |
| 4 |
|
| 5 |
EAPI=4 |
| 6 |
|
| 7 |
EGIT_REPO_URI="git://anongit.freedesktop.org/mesa/mesa" |
| 8 |
|
| 9 |
if [[ ${PV} = 9999* ]]; then |
| 10 |
GIT_ECLASS="git-2" |
| 11 |
EXPERIMENTAL="true" |
| 12 |
fi |
| 13 |
|
| 14 |
inherit base autotools multilib flag-o-matic toolchain-funcs ${GIT_ECLASS} |
| 15 |
|
| 16 |
OPENGL_DIR="xorg-x11" |
| 17 |
|
| 18 |
MY_PN="${PN/m/M}" |
| 19 |
MY_P="${MY_PN}-${PV/_/-}" |
| 20 |
MY_SRC_P="${MY_PN}Lib-${PV/_/-}" |
| 21 |
|
| 22 |
FOLDER="${PV/_rc*/}" |
| 23 |
|
| 24 |
DESCRIPTION="OpenGL-like graphic library for Linux" |
| 25 |
HOMEPAGE="http://mesa3d.sourceforge.net/" |
| 26 |
|
| 27 |
#SRC_PATCHES="mirror://gentoo/${P}-gentoo-patches-01.tar.bz2" |
| 28 |
if [[ $PV = 9999* ]]; then |
| 29 |
SRC_URI="${SRC_PATCHES}" |
| 30 |
else |
| 31 |
SRC_URI="mirror://gentoo/${P}.tar.xz |
| 32 |
${SRC_PATCHES}" |
| 33 |
fi |
| 34 |
|
| 35 |
# The code is MIT/X11. |
| 36 |
# GLES[2]/gl[2]{,ext,platform}.h are SGI-B-2.0 |
| 37 |
LICENSE="MIT SGI-B-2.0" |
| 38 |
SLOT="0" |
| 39 |
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~x86-freebsd ~amd64-linux ~ia64-linux ~x86-linux ~sparc-solaris ~x64-solaris ~x86-solaris" |
| 40 |
|
| 41 |
INTEL_CARDS="i915 i965 intel" |
| 42 |
RADEON_CARDS="r100 r200 r300 r600 radeon radeonsi" |
| 43 |
VIDEO_CARDS="${INTEL_CARDS} ${RADEON_CARDS} nouveau vmware" |
| 44 |
for card in ${VIDEO_CARDS}; do |
| 45 |
IUSE_VIDEO_CARDS+=" video_cards_${card}" |
| 46 |
done |
| 47 |
|
| 48 |
IUSE="${IUSE_VIDEO_CARDS} |
| 49 |
bindist +classic debug +egl g3dvl +gallium gbm gles1 gles2 +llvm +nptl |
| 50 |
openvg osmesa pax_kernel pic r600-llvm-compiler selinux +shared-glapi vdpau |
| 51 |
wayland xvmc xa xorg kernel_FreeBSD" |
| 52 |
|
| 53 |
REQUIRED_USE=" |
| 54 |
g3dvl? ( gallium ) |
| 55 |
llvm? ( gallium ) |
| 56 |
openvg? ( egl gallium ) |
| 57 |
gbm? ( shared-glapi ) |
| 58 |
g3dvl? ( || ( vdpau xvmc ) ) |
| 59 |
vdpau? ( g3dvl ) |
| 60 |
r600-llvm-compiler? ( gallium llvm || ( video_cards_r600 video_cards_radeon ) ) |
| 61 |
xa? ( gallium ) |
| 62 |
xorg? ( gallium ) |
| 63 |
xvmc? ( g3dvl ) |
| 64 |
video_cards_intel? ( || ( classic gallium ) ) |
| 65 |
video_cards_i915? ( || ( classic gallium ) ) |
| 66 |
video_cards_i965? ( classic ) |
| 67 |
video_cards_nouveau? ( || ( classic gallium ) ) |
| 68 |
video_cards_radeon? ( || ( classic gallium ) ) |
| 69 |
video_cards_r100? ( classic ) |
| 70 |
video_cards_r200? ( classic ) |
| 71 |
video_cards_r300? ( gallium ) |
| 72 |
video_cards_r600? ( gallium ) |
| 73 |
video_cards_radeonsi? ( gallium llvm ) |
| 74 |
video_cards_vmware? ( gallium ) |
| 75 |
" |
| 76 |
|
| 77 |
LIBDRM_DEPSTRING=">=x11-libs/libdrm-2.4.34" |
| 78 |
# not a runtime dependency of this package, but dependency of packages which |
| 79 |
# depend on this package, bug #342393 |
| 80 |
EXTERNAL_DEPEND=" |
| 81 |
>=x11-proto/dri2proto-2.6 |
| 82 |
>=x11-proto/glproto-1.4.15-r1 |
| 83 |
" |
| 84 |
# keep correct libdrm and dri2proto dep |
| 85 |
# keep blocks in rdepend for binpkg |
| 86 |
# gtest file collision bug #411825 |
| 87 |
RDEPEND="${EXTERNAL_DEPEND} |
| 88 |
!<x11-base/xorg-server-1.7 |
| 89 |
!<=x11-proto/xf86driproto-2.0.3 |
| 90 |
classic? ( app-admin/eselect-mesa ) |
| 91 |
gallium? ( app-admin/eselect-mesa ) |
| 92 |
>=app-admin/eselect-opengl-1.2.6 |
| 93 |
dev-libs/expat |
| 94 |
gbm? ( sys-fs/udev ) |
| 95 |
>=x11-libs/libX11-1.3.99.901 |
| 96 |
x11-libs/libXdamage |
| 97 |
x11-libs/libXext |
| 98 |
x11-libs/libXxf86vm |
| 99 |
>=x11-libs/libxcb-1.8 |
| 100 |
vdpau? ( >=x11-libs/libvdpau-0.4.1 ) |
| 101 |
wayland? ( dev-libs/wayland ) |
| 102 |
xorg? ( |
| 103 |
x11-base/xorg-server |
| 104 |
x11-libs/libdrm[libkms] |
| 105 |
) |
| 106 |
xvmc? ( >=x11-libs/libXvMC-1.0.6 ) |
| 107 |
${LIBDRM_DEPSTRING}[video_cards_nouveau?,video_cards_vmware?] |
| 108 |
" |
| 109 |
for card in ${INTEL_CARDS}; do |
| 110 |
RDEPEND="${RDEPEND} |
| 111 |
video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_intel] ) |
| 112 |
" |
| 113 |
done |
| 114 |
|
| 115 |
for card in ${RADEON_CARDS}; do |
| 116 |
RDEPEND="${RDEPEND} |
| 117 |
video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_radeon] ) |
| 118 |
" |
| 119 |
done |
| 120 |
|
| 121 |
DEPEND="${RDEPEND} |
| 122 |
llvm? ( |
| 123 |
>=sys-devel/llvm-2.9 |
| 124 |
r600-llvm-compiler? ( >=sys-devel/llvm-3.1 ) |
| 125 |
video_cards_radeonsi? ( >=sys-devel/llvm-3.1 ) |
| 126 |
) |
| 127 |
=dev-lang/python-2* |
| 128 |
dev-libs/libxml2[python] |
| 129 |
sys-devel/bison |
| 130 |
sys-devel/flex |
| 131 |
virtual/pkgconfig |
| 132 |
x11-misc/makedepend |
| 133 |
>=x11-proto/xextproto-7.0.99.1 |
| 134 |
x11-proto/xf86driproto |
| 135 |
x11-proto/xf86vidmodeproto |
| 136 |
" |
| 137 |
|
| 138 |
S="${WORKDIR}/${MY_P}" |
| 139 |
|
| 140 |
# It is slow without texrels, if someone wants slow |
| 141 |
# mesa without texrels +pic use is worth the shot |
| 142 |
QA_EXECSTACK="usr/lib*/opengl/xorg-x11/lib/libGL.so*" |
| 143 |
QA_WX_LOAD="usr/lib*/opengl/xorg-x11/lib/libGL.so*" |
| 144 |
|
| 145 |
# Think about: ggi, fbcon, no-X configs |
| 146 |
|
| 147 |
pkg_setup() { |
| 148 |
# workaround toc-issue wrt #386545 |
| 149 |
use ppc64 && append-flags -mminimal-toc |
| 150 |
} |
| 151 |
|
| 152 |
src_unpack() { |
| 153 |
default |
| 154 |
if [[ ${PV} = 9999* ]]; then |
| 155 |
git-2_src_unpack |
| 156 |
fi |
| 157 |
mv "${WORKDIR}"/${PN}-*/ "${WORKDIR}"/${MY_P} || die |
| 158 |
} |
| 159 |
|
| 160 |
src_prepare() { |
| 161 |
# apply patches |
| 162 |
if [[ ${PV} != 9999* && -n ${SRC_PATCHES} ]]; then |
| 163 |
EPATCH_FORCE="yes" \ |
| 164 |
EPATCH_SOURCE="${WORKDIR}/patches" \ |
| 165 |
EPATCH_SUFFIX="patch" \ |
| 166 |
epatch |
| 167 |
fi |
| 168 |
|
| 169 |
# relax the requirement that r300 must have llvm, bug 380303 |
| 170 |
epatch "${FILESDIR}"/${PN}-8.1-dont-require-llvm-for-r300.patch |
| 171 |
|
| 172 |
# fix for hardened pax_kernel, bug 240956 |
| 173 |
[[ ${PV} != 9999* ]] && epatch "${FILESDIR}"/glx_ro_text_segm.patch |
| 174 |
|
| 175 |
# Solaris needs some recent POSIX stuff in our case |
| 176 |
if [[ ${CHOST} == *-solaris* ]] ; then |
| 177 |
sed -i -e "s/-DSVR4/-D_POSIX_C_SOURCE=200112L/" configure.ac || die |
| 178 |
fi |
| 179 |
|
| 180 |
# Tests fail against python-3, bug #407887 |
| 181 |
sed -i 's|/usr/bin/env python|/usr/bin/env python2|' src/glsl/tests/compare_ir || die |
| 182 |
|
| 183 |
# Fix bash-ism test bug 435496 |
| 184 |
epatch "${FILESDIR}"/${PN}-8.0.4-configure-bsd.patch |
| 185 |
|
| 186 |
base_src_prepare |
| 187 |
|
| 188 |
eautoreconf |
| 189 |
} |
| 190 |
|
| 191 |
src_configure() { |
| 192 |
local myconf |
| 193 |
|
| 194 |
if use classic; then |
| 195 |
# Configurable DRI drivers |
| 196 |
driver_enable swrast |
| 197 |
|
| 198 |
# Intel code |
| 199 |
driver_enable video_cards_i915 i915 |
| 200 |
driver_enable video_cards_i965 i965 |
| 201 |
if ! use video_cards_i915 && \ |
| 202 |
! use video_cards_i965; then |
| 203 |
driver_enable video_cards_intel i915 i965 |
| 204 |
fi |
| 205 |
|
| 206 |
# Nouveau code |
| 207 |
driver_enable video_cards_nouveau nouveau |
| 208 |
|
| 209 |
# ATI code |
| 210 |
driver_enable video_cards_r100 radeon |
| 211 |
driver_enable video_cards_r200 r200 |
| 212 |
if ! use video_cards_r100 && \ |
| 213 |
! use video_cards_r200; then |
| 214 |
driver_enable video_cards_radeon radeon r200 |
| 215 |
fi |
| 216 |
fi |
| 217 |
|
| 218 |
if use egl; then |
| 219 |
myconf+=" |
| 220 |
--with-egl-platforms=x11$(use wayland && echo ",wayland")$(use gbm && echo ",drm") |
| 221 |
$(use_enable gallium gallium-egl) |
| 222 |
" |
| 223 |
fi |
| 224 |
|
| 225 |
if use gallium; then |
| 226 |
myconf+=" |
| 227 |
$(use_enable g3dvl gallium-g3dvl) |
| 228 |
$(use_enable llvm gallium-llvm) |
| 229 |
$(use_enable openvg) |
| 230 |
$(use_enable r600-llvm-compiler) |
| 231 |
$(use_enable vdpau) |
| 232 |
$(use_enable xvmc) |
| 233 |
" |
| 234 |
gallium_enable swrast |
| 235 |
gallium_enable video_cards_vmware svga |
| 236 |
gallium_enable video_cards_nouveau nouveau |
| 237 |
gallium_enable video_cards_i915 i915 |
| 238 |
if ! use video_cards_i915; then |
| 239 |
gallium_enable video_cards_intel i915 |
| 240 |
fi |
| 241 |
|
| 242 |
gallium_enable video_cards_r300 r300 |
| 243 |
gallium_enable video_cards_r600 r600 |
| 244 |
gallium_enable video_cards_radeonsi radeonsi |
| 245 |
if ! use video_cards_r300 && \ |
| 246 |
! use video_cards_r600; then |
| 247 |
gallium_enable video_cards_radeon r300 r600 |
| 248 |
fi |
| 249 |
fi |
| 250 |
|
| 251 |
# x86 hardened pax_kernel needs glx-rts, bug 240956 |
| 252 |
if use pax_kernel; then |
| 253 |
myconf+=" |
| 254 |
$(use_enable x86 glx-rts) |
| 255 |
" |
| 256 |
fi |
| 257 |
|
| 258 |
use userland_GNU || export INDENT=cat |
| 259 |
|
| 260 |
econf \ |
| 261 |
--enable-dri \ |
| 262 |
--enable-glx \ |
| 263 |
$(use_enable !bindist texture-float) \ |
| 264 |
$(use_enable debug) \ |
| 265 |
$(use_enable egl) \ |
| 266 |
$(use_enable gbm) \ |
| 267 |
$(use_enable gles1) \ |
| 268 |
$(use_enable gles2) \ |
| 269 |
$(use_enable nptl glx-tls) \ |
| 270 |
$(use_enable osmesa) \ |
| 271 |
$(use_enable !pic asm) \ |
| 272 |
$(use_enable shared-glapi) \ |
| 273 |
$(use_enable xa) \ |
| 274 |
$(use_enable xorg) \ |
| 275 |
--with-dri-drivers=${DRI_DRIVERS} \ |
| 276 |
--with-gallium-drivers=${GALLIUM_DRIVERS} \ |
| 277 |
${myconf} |
| 278 |
} |
| 279 |
|
| 280 |
src_install() { |
| 281 |
base_src_install |
| 282 |
|
| 283 |
find "${ED}" -name '*.la' -exec rm -f {} + || die |
| 284 |
|
| 285 |
if use !bindist; then |
| 286 |
dodoc docs/patents.txt |
| 287 |
fi |
| 288 |
|
| 289 |
# Save the glsl-compiler for later use |
| 290 |
if ! tc-is-cross-compiler; then |
| 291 |
dobin "${S}"/src/glsl/glsl_compiler |
| 292 |
fi |
| 293 |
|
| 294 |
# Install config file for eselect mesa |
| 295 |
insinto /usr/share/mesa |
| 296 |
newins "${FILESDIR}/eselect-mesa.conf.8.1" eselect-mesa.conf |
| 297 |
|
| 298 |
# Move libGL and others from /usr/lib to /usr/lib/opengl/blah/lib |
| 299 |
# because user can eselect desired GL provider. |
| 300 |
ebegin "Moving libGL and friends for dynamic switching" |
| 301 |
local x |
| 302 |
local gl_dir="/usr/$(get_libdir)/opengl/${OPENGL_DIR}/" |
| 303 |
dodir ${gl_dir}/{lib,extensions,include/GL} |
| 304 |
for x in "${ED}"/usr/$(get_libdir)/lib{EGL,GL*,OpenVG}.{la,a,so*}; do |
| 305 |
if [ -f ${x} -o -L ${x} ]; then |
| 306 |
mv -f "${x}" "${ED}${gl_dir}"/lib \ |
| 307 |
|| die "Failed to move ${x}" |
| 308 |
fi |
| 309 |
done |
| 310 |
for x in "${ED}"/usr/include/GL/{gl.h,glx.h,glext.h,glxext.h}; do |
| 311 |
if [ -f ${x} -o -L ${x} ]; then |
| 312 |
mv -f "${x}" "${ED}${gl_dir}"/include/GL \ |
| 313 |
|| die "Failed to move ${x}" |
| 314 |
fi |
| 315 |
done |
| 316 |
for x in "${ED}"/usr/include/{EGL,GLES*,VG,KHR}; do |
| 317 |
if [ -d ${x} ]; then |
| 318 |
mv -f "${x}" "${ED}${gl_dir}"/include \ |
| 319 |
|| die "Failed to move ${x}" |
| 320 |
fi |
| 321 |
done |
| 322 |
eend $? |
| 323 |
|
| 324 |
if use classic || use gallium; then |
| 325 |
ebegin "Moving DRI/Gallium drivers for dynamic switching" |
| 326 |
local gallium_drivers=( i915_dri.so i965_dri.so r300_dri.so r600_dri.so swrast_dri.so ) |
| 327 |
keepdir /usr/$(get_libdir)/dri |
| 328 |
dodir /usr/$(get_libdir)/mesa |
| 329 |
for x in ${gallium_drivers[@]}; do |
| 330 |
if [ -f "${S}/$(get_libdir)/gallium/${x}" ]; then |
| 331 |
mv -f "${ED}/usr/$(get_libdir)/dri/${x}" "${ED}/usr/$(get_libdir)/dri/${x/_dri.so/g_dri.so}" \ |
| 332 |
|| die "Failed to move ${x}" |
| 333 |
insinto "/usr/$(get_libdir)/dri/" |
| 334 |
if [ -f "${S}/$(get_libdir)/${x}" ]; then |
| 335 |
insopts -m0755 |
| 336 |
doins "${S}/$(get_libdir)/${x}" |
| 337 |
fi |
| 338 |
fi |
| 339 |
done |
| 340 |
for x in "${ED}"/usr/$(get_libdir)/dri/*.so; do |
| 341 |
if [ -f ${x} -o -L ${x} ]; then |
| 342 |
mv -f "${x}" "${x/dri/mesa}" \ |
| 343 |
|| die "Failed to move ${x}" |
| 344 |
fi |
| 345 |
done |
| 346 |
pushd "${ED}"/usr/$(get_libdir)/dri || die "pushd failed" |
| 347 |
ln -s ../mesa/*.so . || die "Creating symlink failed" |
| 348 |
# remove symlinks to drivers known to eselect |
| 349 |
for x in ${gallium_drivers[@]}; do |
| 350 |
if [ -f ${x} -o -L ${x} ]; then |
| 351 |
rm "${x}" || die "Failed to remove ${x}" |
| 352 |
fi |
| 353 |
done |
| 354 |
popd |
| 355 |
eend $? |
| 356 |
fi |
| 357 |
} |
| 358 |
|
| 359 |
pkg_postinst() { |
| 360 |
# Switch to the xorg implementation. |
| 361 |
echo |
| 362 |
eselect opengl set --use-old ${OPENGL_DIR} |
| 363 |
|
| 364 |
# switch to xorg-x11 and back if necessary, bug #374647 comment 11 |
| 365 |
OLD_IMPLEM="$(eselect opengl show)" |
| 366 |
if [[ ${OPENGL_DIR}x != ${OLD_IMPLEM}x ]]; then |
| 367 |
eselect opengl set ${OPENGL_DIR} |
| 368 |
eselect opengl set ${OLD_IMPLEM} |
| 369 |
fi |
| 370 |
|
| 371 |
# Select classic/gallium drivers |
| 372 |
if use classic || use gallium; then |
| 373 |
eselect mesa set --auto |
| 374 |
fi |
| 375 |
|
| 376 |
# warn about patent encumbered texture-float |
| 377 |
if use !bindist; then |
| 378 |
elog "USE=\"bindist\" was not set. Potentially patent encumbered code was" |
| 379 |
elog "enabled. Please see patents.txt for an explanation." |
| 380 |
fi |
| 381 |
|
| 382 |
local using_radeon r_flag |
| 383 |
for r_flag in ${RADEON_CARDS}; do |
| 384 |
if use video_cards_${r_flag}; then |
| 385 |
using_radeon=1 |
| 386 |
break |
| 387 |
fi |
| 388 |
done |
| 389 |
|
| 390 |
if [[ ${using_radeon} = 1 ]] && ! has_version media-libs/libtxc_dxtn; then |
| 391 |
elog "Note that in order to have full S3TC support, it is necessary to install" |
| 392 |
elog "media-libs/libtxc_dxtn as well. This may be necessary to get nice" |
| 393 |
elog "textures in some apps, and some others even require this to run." |
| 394 |
fi |
| 395 |
} |
| 396 |
|
| 397 |
# $1 - VIDEO_CARDS flag |
| 398 |
# other args - names of DRI drivers to enable |
| 399 |
# TODO: avoid code duplication for a more elegant implementation |
| 400 |
driver_enable() { |
| 401 |
case $# in |
| 402 |
# for enabling unconditionally |
| 403 |
1) |
| 404 |
DRI_DRIVERS+=",$1" |
| 405 |
;; |
| 406 |
*) |
| 407 |
if use $1; then |
| 408 |
shift |
| 409 |
for i in $@; do |
| 410 |
DRI_DRIVERS+=",${i}" |
| 411 |
done |
| 412 |
fi |
| 413 |
;; |
| 414 |
esac |
| 415 |
} |
| 416 |
|
| 417 |
gallium_enable() { |
| 418 |
case $# in |
| 419 |
# for enabling unconditionally |
| 420 |
1) |
| 421 |
GALLIUM_DRIVERS+=",$1" |
| 422 |
;; |
| 423 |
*) |
| 424 |
if use $1; then |
| 425 |
shift |
| 426 |
for i in $@; do |
| 427 |
GALLIUM_DRIVERS+=",${i}" |
| 428 |
done |
| 429 |
fi |
| 430 |
;; |
| 431 |
esac |
| 432 |
} |