#!/bin/bash # mesa.SlackBuild # Heavily based on the original Slackware build scripts, # Modified by Stuart Winter # # Copyright 2006, 2007 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Record toolchain & other info for the build log: slackbuildinfo DEMOVERS=8.3.0 # Paths to skeleton port's source & real Slackware source tree: export CWD=$SLACKSOURCE/$PKGSERIES/$PKGNAM export PORTCWD=$PWD # Temporary build locations: export TMPBUILD=$TMP/build-$PKGNAM #export PKG=$TMP/package-$PKGNAM export PKG=/tmp/package-mesa mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD # Be sure this list is up-to-date: # ( "sis" driver doesn't compile on ARM. ) # Original list for Mesa 9.x: #DRI_DRIVERS="i915,i965,nouveau,r200,radeon,swrast" # Slackware x86's DRI list (i915 & i965 require libdrm_intel which won't build on ARM, so we need to remove # them from the list): DRI_DRIVERS="nouveau,r200,radeon,swrast" EGL_PLATFORMS="drm,x11" # Determine the configuration options for the known architectures: case $ARCH in arm) export GALLIUM_DRIVERS=" nouveau r600 r300 svga swrast" # export GALLIUM_DRIVERS="nouveau,r300,r600,svga,radeonsi,swrast" #export SLKARCHCONFARGS="--enable-openvg --enable-gallium-egl" ;; esac # Mesa configure function: function buildmesa() { # Clean up from the 1st pass: cd / rm -rf $TMPBUILD && mkdir -vpm755 $TMPBUILD cd $TMPBUILD # Extract source: echo "Unpacking sources..." tar xvvf $CWD/${PKGNAM}-${VERSION}.tar.xz || exit 1 cd $PKGNAM-$VERSION || exit 1 slackhousekeeping # Let's kill the warning about operating on a dangling symlink: rm -f src/gallium/state_trackers/d3d1x/w32api # Apply patches: # if /bin/ls $CWD/patches/*.patch 1> /dev/null 2> /dev/null ; then for patch in $CWD/patches/*.patch ; do patch -p1 < $patch || exit 1 ; done fi # Apply patches from Debian (for ARM and others) if [ -f $PORTCWD/sources/mesa*diff* ]; then xz -dc $PORTCWD/sources/mesa*diff* | patch -p1 for i in debian/patches/*diff* ; do auto_apply_patch $i || exit 1 done fi # Tell configure script to find the includes: #autoreconf -vfi -I include/ || exit 1 # Running autogen to avoid problems if our autotools don't match upstream's: #automake # Don't worry if Mako is not present: #sed -i "s,AX_CHECK_PYTHON_MAKO_MODULE(\$PYTHON_MAKO_REQUIRED),,g" configure.ac zcat $CWD/mesa.no.mako.diff.gz | patch -p1 --verbose || exit 1 # This doesn't fully do the trick. See below. ;-) #./autogen.sh # Fix detection of libLLVM when built with CMake -- not yet on ARM since we don't # build llvm with cmake. #sed -i 's/LLVM_SO_NAME=.*/LLVM_SO_NAME=LLVM/' configure.ac # Seems to need this to avoid tripping over a different libtool version: autoreconf -fi # These config options aren't for ARM: # Configure: CFLAGS="$SLKCFLAGS" \ ./configure \ $SLKARCHCONFARGS \ --prefix=/usr \ --sysconfdir=/etc \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --mandir=/usr/man \ --docdir=/usr/doc/${PKGNAM}-$VERSION \ --with-dri-driverdir=/usr/lib${LIBDIRSUFFIX}/xorg/modules/dri \ --with-dri-drivers="$DRI_DRIVERS" \ --with-gallium-drivers="$GALLIUM_DRIVERS" \ --with-egl-platforms="$EGL_PLATFORMS" \ --enable-texture-float \ --enable-gallium-llvm \ --enable-llvm-shared-libs \ --enable-egl \ --enable-xa \ --enable-osmesa \ --enable-dri \ --enable-dri3 \ --enable-shared-glapi \ --enable-gbm \ --enable-glx \ --enable-glx-tls \ --enable-gles1 \ --enable-gles2 \ --enable-vdpau \ --enable-nine \ --build=$ARCH-slackware-linux-gnueabi \ $@ || exit 1 # Build: make $NUMJOBS || make || exit 1 # Install into package: make install DESTDIR=$PKG || exit 1 # Install onto filesystem so that the demos can find the # includes: make install || exit 1 } # We two a two-pass build of mesa. The first is with DRI support so that # we can build the DRI header file, GL/internal/dri_interface.h for xorg-server. # I think that we could build the xorg-server package without DRI (it's just a config option) # but I'm not sure what else would break. # This way seems to be good compromise. # # The header file will be installed into the package, and then we can # proceed to the 2nd pass: cat << EOF ********************************************************************* ** Building 1st pass of Mesa, enabling DRI to get header file ** ********************************************************************* EOF buildmesa \ --with-driver=dri || exit 1 # 2nd pass: # cat << EOF ********************************************************************* ** Building 2nd pass of Mesa, enabling xlib as the default driver ** ********************************************************************* EOF # --disable-egl \ # For Mesa 9.x, I copied the DRI lines from above in to here as # the configure script seems to default to including some Intel cards # which require libdrm_intel to be installed on the system. # This is just a trick to feed it some info about the cards to stop # the configure script from complaining. buildmesa \ --with-driver=xlib \ --disable-gl-osmesa || exit 1 # --disable-glut || exit 1 # Now install the demos ( cd $TMPBUILD cat << EOF ********************************************************************* ** Building Mesa Demos ** ********************************************************************* EOF rm -rf mesa-demos-$DEMOVERS tar xf $CWD/mesa-demos-$DEMOVERS.tar.?z* || exit 1 cd mesa-demos-$DEMOVERS chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; CFLAGS="$SLKCFLAGS -I$PWD/include/GL/glut.h" \ ./configure \ --prefix=/usr \ --build=$ARCH-slackware-linux # Build and install gears and glinfo, as well as a few other demos make -C src/demos gears glinfo make -C src/xdemos \ glthreads glxcontexts glxdemo glxgears glxgears_fbconfig \ glxheads glxinfo glxpbdemo glxpixmap mkdir -p $PKG/usr/bin cp -a src/demos/{gears,glinfo} $PKG/usr/bin for i in glthreads glxcontexts glxdemo glxgears glxgears_fbconfig \ glxheads glxinfo glxpbdemo glxpixmap ; do cp -a src/xdemos/$i $PKG/usr/bin ; done ) mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION/html cp -fav \ docs/COPYING* docs/relnotes/relnotes-${VERSION}*.html docs/README* docs/GL* \ $PKG/usr/doc/$PKGNAM-$VERSION cp -fav docs/*.html $PKG/usr/doc/$PKGNAM-$VERSION/html rm -f $PKG/usr/doc/$PKGNAM-$VERSION/html/relnotes*.html # I know this is messy but the Slackware configure options # for xorg-server looks for Mesa source in here, and it's easier # to do this than modify the config options: ( cd $TMPBUILD echo "Archiving compiled mesa source..." tar -Ixz -pcf $PORTCWD/mesa-compiled.tar.xz $PKGNAM-$VERSION ) # If necessary, start the fakeroot server so we can set file/dir ownerships: start_fakeroot # Apply generic Slackware packaging policies: cd $PKG slackstripall # strip all .a archives and all ELFs slackgzpages -i # compress man & info pages and delete usr/info/dir slackslack # chown -R root:root, chmod -R og-w, slackchown, slack644docs slackdesc # install slack-desc and doinst.sh slackmp # run makepkg -l y -c n # Perform any final checks on the package: cd $PKG slackhlinks # search for any hard links