# $Id$ PNAME="mesa" PVER="11.0.4" PBUILD="r2" SPLIT_PACKAGES="mesa mesa-dev" PCAT="media-libs" HOMEPAGE="http://mesa3d.sourceforge.net/" # hardcoded llvm version for libxatracker LLVM_PVER="3.6.2" MESA_DEPEND=">= dev-libs/expat-2.1 >= dev-libs/libffi-3.2 >= x11-libs/libX11-1.6 >= x11-libs/libXext-1.3 >= x11-libs/libXxf86vm-1.1 >= x11-libs/libXi-1.7 >= x11-libs/libXmu-1.1 >= x11-libs/libdrm-2.4.61 >= x11-libs/libICE-1 >= x11-base/opengl-update-2.3 >= x11-libs/libxcb-1.11 >= x11-libs/libXfixes-5 >= x11-libs/libXdamage-1 >= x11-libs/libxshmfence-1.1 >= sys-libs/libstdc++-5.2 >= sys-fs/libudev-220 >= sys-libs/llvm-libs-${LLVM_PVER} >= dev-libs/openssl-1.0.2" #>= x11-libs/libXvMC-1 # >= x11-libs/libvdpau-1.1 # >= x11-libs/libva-1.5 MESA_PROGS_DEPEND=">= virtual/glut" # mesa-dev runtime deps MESA_DEV_DEPEND=">= dev-libs/expat-dev-2.1 >= dev-libs/libffi-dev-3.2 >= x11-libs/libX11-dev-1.6 >= x11-libs/libXext-dev-1.3 >= x11-libs/libXxf86vm-dev-1.1 >= x11-libs/libXi-dev-1.7 >= x11-libs/libXmu-dev-1.1 >= x11-libs/libdrm-dev-2.4.59 >= x11-libs/libICE-dev-1 >= x11-libs/libxcb-dev-1.11 >= x11-libs/libXfixes-dev-5 >= x11-libs/libXdamage-dev-1 >= x11-libs/libxshmfence-dev-1.1 >= sys-libs/libstdc++-dev-5.2 >= sys-fs/libudev-dev-220 >= dev-libs/openssl-dev-1.0.2" SDEPEND="${MESA_DEPEND} ${MESA_PROGS_DEPEND} >= dev-util/pkgconfig-0.25 >= x11-misc/makedepend-1 >= x11-libs/libXxf86vm-1.1 >= x11-proto/glproto-1.4.17 >= x11-proto/xf86driproto-2.1 >= x11-proto/dri2proto-2.8 >= x11-proto/dri3proto-1 >= x11-proto/presentproto-1.0 >= dev-lang/python-2.7 >= sys-dev/llvm-${LLVM_PVER} ${MESA_DEV_DEPEND}" # must be set before the include of multilib! EMUL_LINUX_32=true sminclude xorg mtools multilib cleanutils msetfeature "!check" # must be set *after* the include of xorg! SRCFILE="${PNAME}-${PVER/_/-}.tar.xz" # libs SRCDIR SRCDIR="${BUILDDIR}/${PNAME}-${PVER/_/-}" # setup_dynamic_dri $impl # impl may be classic or gallium atm setup_dynamic_dri() { local impl="$1" local i local abi [[ -z ${impl} ]] && die "missing dri implementation!" case ${impl} in classic|gallium) ;; *) die "unkown dri implementation '${impl}'!" ;; esac echo "settin up dynamic dri for a '${impl} implementation..." if [[ -z ${MULTILIB_ABIS} ]] then minstalldir /usr/$(mlibdir)/mesa/${impl} || die for i in ${BINDIR}/usr/$(mlibdir)/dri/*_dri.so do echo -n " processing ${i}:" if [ -f ${i} -o -L ${i} ] then echo -n " moving" mv -vf ${i} ${BINDIR}/usr/$(mlibdir)/mesa/${impl} || die "moving ${i}" fi done else for abi in ${MULTILIB_ABIS} do [[ ${abi} = m32 ]] && ABI_LIBDIR="lib" [[ ${abi} = m64 ]] && ABI_LIBDIR="lib64" minstalldir /usr/$(mlibdir)/mesa/${impl} || die for i in ${BINDIR}/usr/$(mlibdir)/dri/*_dri.so do echo -n " processing ${i}" if [ -f ${i} -o -L ${i} ] then echo -n " moving" mv -vf ${i} ${BINDIR}/usr/$(mlibdir)/mesa/${impl} || die "moving ${i}" fi echo " done" done done fi } SRC_URI=( ftp://ftp.freedesktop.org/pub/mesa/${PVER%_*}/${SRCFILE} mirror://${PNAME}/${SRCFILE} ) #UP2DATE="updatecmd ftp://ftp.freedesktop.org/pub/mesa/current | highesttarball xz" UP2DATE="updatecmd ftp://ftp.freedesktop.org/pub/mesa/ | grep '/[0-9].*' | sed 's:.*/\(.*\)/:\1:' | upsort_pipe" split_info_mesa() { DESCRIPTION="Mesa3D OpenGL graphics library." DEPEND="${MESA_DEPEND}" PROVIDE="virtual/opengl" } split_info_mesa-dev() { DESCRIPTION="Dev package for mesa" DEPEND="== media-libs/mesa-${PVER} ${MESA_DEV_DEPEND}" PROVIDE="virtual/opengl-dev" } src_prepare() { munpack ${SRCFILE} || die # no debug code in the drives (gentoo) all-abis 'find src/mesa/drivers/dri -name *.[hc] -exec egrep -l "\#define\W+DO_DEBUG\W+1" {} \; | xargs --no-run-if-empty sed -i -re "s/\#define\W+DO_DEBUG\W+1/\#define DO_DEBUG 0/" ;' # get rid of glut includes all-abis rm -f include/GL/glut*h || die # fix an error in the libva detection # all-abis 'sed -i "s:libva = 0.31.1:libva >= 0.31.1:" configure.ac' || die mautoreconf || die } src_compile() { # build without rtti and exeptions, fixes issues with llvm as well export CXXFLAGS="${CXXFLAGS} -fno-rtti -fno-exceptions -DNDEBUG" # texture-float has patent issues in non european contries # disable this feature if this legal concern is affected local myconf="--enable-texture-float" mconfigure \ --with-dri-driverdir=/usr/'$(mlibdir)'/dri \ --with-dri-drivers=i915,i965,r200,radeon,nouveau,swrast \ --with-gallium-drivers=r300,r600,radeonsi,nouveau,svga,swrast \ --with-egl-platforms=x11,drm \ --disable-debug \ --enable-glx-tls \ --enable-asm \ --enable-shared-glapi \ --enable-egl \ --enable-gles1 \ --enable-gles2 \ --enable-gbm \ --enable-osmesa \ --enable-xa \ --enable-gallium-egl \ --enable-gallium-llvm \ --disable-vdpau \ --enable-llvm-shared-libs \ ${myconf} \ || die # --enable-va \ # # only build software renderer on multilib arches for 32Bit # if [[ ${ARCH} = x86_64 ]] # then # only-m32 "echo 'DRI_DIRS =' >> configs/autoconf" || die # fi mmake -j1 || die } src_install_mesa() { mmake DESTDIR=${BINDIR} install || die # remove all la files find ${BINDIR} -name \*.la | xargs rm -fv # setup included for dynamic opengl # only target arch needed on multilib systems for abi in ${MULTILIB_ABIS} do [[ ${abi} = m32 ]] && ABI_LIBDIR="lib" [[ ${abi} = m64 ]] && ABI_LIBDIR="lib64" cd ${SRCDIR}-${abi} # setup dynamic opengl minstalldir /usr/$(mlibdir)/opengl/xorg/lib || die minstalldir /usr/$(mlibdir)/opengl/xorg/extensions || die local x for x in ${BINDIR}/usr/$(mlibdir)/lib{EGL,GL*,OpenVG}.so.* do if [ -f ${x} -o -L ${x} ] then mv -fv ${x} ${BINDIR}/usr/$(mlibdir)/opengl/xorg/lib || die "${x}" fi done # export LIBGL_DRIVER_PATH location. # we are using '/usr/lib/dri' as hardcoded location. # but nvidia and ati are using '/usr/$(mlibdir)/xorg/modules/dri' # LIBGL_DRIVER_PATH overwrites the hardcoded location and # if nvidia or ati driver are installed # the dri modules will never be found by libGL # use "LIBGL_DEBUG=verbose glxinfo" to check this issue minstalldir /etc/env.d || die MCONFIG=/etc/env.d/09mesa-${abi} mclearconfig || die maddconfig "LIBGL_DRIVERS_PATH=/usr/$(mlibdir)/dri" || die done zapmost ${BINDIR} \ usr/$(mlibdir)/*.so.* \ $([[ $(mlibdir) != lib ]] && echo 'usr/lib/*.so.*') \ usr/$(mlibdir)/dri \ $([[ $(mlibdir) != lib ]] && echo 'usr/lib/dri') \ usr/$(mlibdir)/opengl \ $([[ $(mlibdir) != lib ]] && echo 'usr/lib/opengl') \ || die # usr/$(mlibdir)/egl \ # $([[ $(mlibdir) != lib ]] && echo 'usr/lib/egl') } src_install_mesa-dev() { mmake DESTDIR=${BINDIR} install || die # remove all la files find ${BINDIR} -name \*.la | xargs rm -fv # setup included for dynamic opengl # only target arch needed on multilib systems minstalldir /usr/$(mlibdir)/opengl/xorg/include/GL || die for x in ${BINDIR}/usr/include/GL/{gl.h,glx.h,glext.h,glxext.h} do if [ -f ${x} -o -L ${x} ] then mv -fv ${x} ${BINDIR}/usr/$(mlibdir)/opengl/xorg/include/GL || die "${x}" fi done for x in ${BINDIR}/usr/include/{EGL,GLES*,VG,KHR} do if [ -d ${x} ] then mv -fv ${x} ${BINDIR}/usr/$(mlibdir)/opengl/xorg/include || die "${x}" fi done for abi in ${MULTILIB_ABIS} do [[ ${abi} = m32 ]] && ABI_LIBDIR="lib" [[ ${abi} = m64 ]] && ABI_LIBDIR="lib64" cd ${SRCDIR}-${abi} # setup dynamic opengl minstalldir /usr/$(mlibdir)/opengl/xorg/lib || die minstalldir /usr/$(mlibdir)/opengl/xorg/extensions || die local x for x in ${BINDIR}/usr/$(mlibdir)/lib{EGL,GL*,OpenVG}.{la,a,so} do if [ -f ${x} -o -L ${x} ] then mv -fv ${x} ${BINDIR}/usr/$(mlibdir)/opengl/xorg/lib || die "${x}" fi done done # includes in mesa package rm -r ${BINDIR}/usr/$(mlibdir)/*.so.* || die mdelete -r /usr/$(mlibdir)/dri || die # mdelete -r /usr/$(mlibdir)/egl || die if [[ $(mlibdir) != lib ]] then rm -r ${BINDIR}/usr/lib/*.so.* || die mdelete -r /usr/lib/dri || die # mdelete -r /usr/lib/egl || die fi } postinstall_mesa() { ${MROOT}/usr/sbin/dri-update --use-old gallium }