Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 268 lines (224 sloc) 8.03 KB
#!/bin/sh
#-- mesa-compat32 for Slackware --
# Build script by Phantom X <megaphantomx at bol.com.br>
# Suggested usage: $ mesa.SlackBuild 2>&1 | tee build.log
#--
# Copyright 2008-2016 Phantom X, Goiania, Brazil.
# Copyright 2006 Martijn Dekker, Groningen, Netherlands.
#
# 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.
# http://www.mesa3d.org/
PACKAGER_ID=${PACKAGER_ID:-$USER}
PACKAGER=${PACKAGER:-$USER@$HOSTNAME}
# Set YES for native build with gcc >= 4.2
SB_NATIVE=${SB_NATIVE:-NO}
# Set to YES to replicate slackbuild and patches
SB_REP=${SB_REP:-YES}
CWD=$(pwd)
TMP=${TMP:-/tmp}
PNAME=Mesa
PNAME2=mesa
NAME=mesa-compat32
PKG=${PKG:-${TMP}/package-${NAME}}
VERSION=${VERSION:-13.0.2}
if [ "$( echo ${VERSION} | cut -d . -f 3 )" -eq 0 ] ;then
SVER=$(echo ${VERSION} | cut -d- -f1 | cut -d . -f 1-2 )
else
SVER=$(echo ${VERSION} | cut -d- -f1 )
fi
if [ "${SB_NATIVE}" = "YES" ] ;then
ARCH32=${ARCH32:-$(linux32 uname -m)}
else
ARCH32=${ARCH32:-i686}
fi
SLKTARGET32=${SLKTARGET32:-i586}
SLKDTARGET=${SLKDTARGET:-slackware}
BUILD=${BUILD:-1}
NJOBS=${NJOBS:-$(( $(getconf _NPROCESSORS_ONLN) + 1 ))}
DOCDIR=${PKG}/usr/doc/${NAME}-${VERSION}
SBDIR=${PKG}/usr/src/slackbuilds/${PNAME2}
PKGDEST=${PKGDEST:-${CWD}}
PKGFORMAT=${PKGFORMAT:-txz}
PKGNAME=${NAME}-$(echo ${VERSION} | tr - . )-${ARCH32}-${BUILD}${PACKAGER_ID}
DATE=$(LC_ALL=C date +%d-%b-%Y)
SRCDIR=${PNAME2}-${VERSION}
SRCARCHIVE=${SRCDIR}.tar.xz
DL_PROG=${DL_PROG:-wget}
DL_TO=${DL_TO:-5}
DL_OPTS=${DL_OPTS:-"--timeout=${DL_TO}"}
MIRROR_SF=${MIRROR_SF:-http://prdownloads.sourceforge.net}
DL_URL="ftp://ftp.freedesktop.org/pub/mesa/${VERSION}"
DL_URL2="${MIRROR_SF}/mesa3d"
DL_URLB="http://www.mesa3d.org/beta"
DL_URLB2="ftp://ftp.freedesktop.org/pub/mesa/beta"
# if source is not present, download in source rootdir if possible
test -r ${CWD}/${SRCARCHIVE} || ${DL_PROG} ${DL_OPTS} ${DL_URLB}/${SRCARCHIVE} || ${DL_PROG} ${DL_OPTS} ${DL_URLB2}/${SRCARCHIVE}
test -r ${CWD}/${SRCARCHIVE} || ${DL_PROG} ${DL_OPTS} ${DL_URL}/${SRCARCHIVE} || ${DL_PROG} ${DL_OPTS} ${DL_URL2}/${SRCARCHIVE} || exit 1
[ "$1" = "--dlsrc" ] && exit 0
if [ "${SB_NATIVE}" = "YES" ] ;then
SLKCFLAGS="-O2 -march=native -mtune=native -pipe"
[ "${SB_ECFLAGS}" ] && SLKCFLAGS="${SLKCFLAGS} ${SB_ECFLAGS}"
else
case "${ARCH32}" in
i[3-6]86) SLKCFLAGS="-O2 -march=${ARCH32} -mtune=i686"
;;
esac
fi
LIBDIRSUFFIX=""
export CC="gcc -m32"
export CXX="g++ -m32"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:${PKG_CONFIG_PATH}"
if test ${UID} != 0 && test "$(type -t fakeroot)" != 'file'; then
echo -e "\e[1mPlease preferably install fakeroot or run as root.\e[0m"
exit 5
fi
if [ ! -d ${TMP} ]; then
mkdir -p ${TMP}
fi
if [ -d ${PKG} ]; then
# Clean up a previous build
rm -rf ${PKG}
fi
mkdir -p ${PKG}
cd ${TMP}
rm -rf ${SRCDIR}
tar -xvf ${CWD}/${SRCARCHIVE} || exit 1
cd ${SRCDIR} || exit 1
chmod -R u+w,go+r-w,a-s .
unset SB_AUTOGEN
if [ -r ${CWD}/apply-patches.sh ]; then
. ${CWD}/apply-patches.sh
fi
cp -f ${CWD}/vl_decoder.c src/gallium/auxiliary/vl/vl_decoder.c || exit 1
cp -f ${CWD}/vl_mpeg12_decoder.c src/gallium/auxiliary/vl/vl_mpeg12_decoder.c || exit 1
SB_GALLIUMDRV="r300,r600,nouveau,radeonsi,svga,swrast,virgl"
SB_VULKANDRV="intel,radeon"
sed -i.llvmconfig -e 's|llvm-config|llvm-config-32|g' configure.ac || exit 1
if [ "${SB_AUTOGEN}" = "YES" ] ;then
autoreconf -ivf || exit $?
fi
export LDFLAGS+=" -static-libstdc++"
CFLAGS="${SLKCFLAGS}" \
CXXFLAGS="${SLKCFLAGS} -frtti -fexceptions" \
./configure \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--sysconfdir=/etc \
--localstatedir=/var/lib \
--infodir=/usr/info \
--mandir=/usr/man \
--docdir=/usr/doc/${NAME}-${VERSION} \
--disable-silent-rules \
--with-dri-driverdir=/usr/lib${LIBDIRSUFFIX}/xorg/modules/dri \
--enable-dri \
--enable-dri3 \
--enable-glx-tls \
--enable-texture-float=yes \
--with-vulkan-drivers=${SB_VULKANDRV} \
--with-sha1=libnettle \
--enable-egl \
--with-egl-platforms=x11,drm,surfaceless,wayland \
--disable-gles1 \
--enable-gles2 \
--enable-shared-glapi \
--enable-gbm \
--with-gallium-drivers=${SB_GALLIUMDRV} \
--enable-gallium-llvm \
--enable-llvm-shared-libs \
--disable-gallium-egl \
--disable-asm \
--enable-opencl \
--enable-opencl-icd \
--with-clang-libdir=/usr/lib \
--enable-gallium-osmesa \
--enable-xa \
--enable-nine \
--enable-omx \
--enable-vdpau \
--disable-xvmc \
--build=${SLKTARGET32}-${SLKDTARGET}-linux || exit 1
# libtool refuses to pass through things you ask for in LDFLAGS that it doesn't
# know about, like -static-libstdc++, so...
sed -i 's/-fuse-linker-plugin|/-static-lib*|&/' libtool
sed -i 's/-nostdlib//g' libtool
sed -i 's/^predep_objects=.*$/#&/' libtool
sed -i 's/^postdep_objects=.*$/#&/' libtool
sed -i 's/^postdeps=.*$/#&/' libtool
# Build and install:
make clean
make -j${NJOBS} || make || exit 1
make install DESTDIR=${PKG} || exit $?
find ${PKG} -name '*.la' -delete
# just the DRI drivers that are sane
mkdir -p ${PKG}/usr/lib${LIBDIRSUFFIX}/xorg/modules/dri
# libvdpau opens the versioned name, don't bother including the unversioned
rm -f ${PKG}/usr/lib${LIBDIRSUFFIX}/vdpau/*.so
# Hack to not conflicting with nvidia-glx
mkdir -p ${PKG}/usr/lib${LIBDIRSUFFIX}/mesa
for libname in libEGL libGL libGLESv2 ;do
mv ${PKG}/usr/lib${LIBDIRSUFFIX}/${libname}.so.* \
${PKG}/usr/lib${LIBDIRSUFFIX}/mesa/ || exit 1
reldir=mesa
oldlink=$(readlink ${PKG}/usr/lib${LIBDIRSUFFIX}/${libname}.so)
ln -sf ${reldir}/$(basename ${oldlink}) ${PKG}/usr/lib${LIBDIRSUFFIX}/${libname}.so || exit 1
done
rm -rf ${PKG}/usr/{bin,doc,include,man,info,share} ${PKG}/{etc,var}
# ld.so.conf
mkdir -p ${PKG}/etc/ld.so.conf.d
echo "/usr/lib${LIBDIRSUFFIX}/mesa" \
> ${PKG}/etc/ld.so.conf.d/99-mesa-${ARCH32}.conf || exit 1
find ${PKG} | xargs file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
mkdir -p ${PKG}/install
cat ${CWD}/slack-desc-compat32 > ${PKG}/install/slack-desc
cat ${CWD}/slack-required > ${PKG}/install/slack-required
sed -i "s|_PACKAGER|${PACKAGER}|g; s|_BUILD_DATE|${DATE}|g" \
${PKG}/install/slack-desc
if [ "${SB_REP}" = "YES" ] ;then
# Replicate slackbuild and patches
mkdir -p ${SBDIR}
install -m0644 ${CWD}/slack-desc-compat32 ${SBDIR}/
install -m0755 ${CWD}/${NAME}.SlackBuild \
${SBDIR}/${NAME}.SlackBuild
fi
# Build package:
set +o xtrace # no longer print commands upon execution
set -e
ROOTCOMMANDS="set -o errexit -o xtrace ; cd ${PKG} ;
/bin/chown --recursive root:root . ;"
ROOTCOMMANDS="${ROOTCOMMANDS}
/sbin/makepkg --linkadd y --chown n ${PKGDEST}/${PKGNAME}.${PKGFORMAT} "
if test ${UID} = 0; then
eval ${ROOTCOMMANDS}
set +o xtrace
else
echo -e "\e[1mEntering fakeroot environment.\e[0m"
echo ${ROOTCOMMANDS} | fakeroot
fi
# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
echo "Cleaning..."
if [ -d ${TMP}/${SRCDIR} ]; then
rm -rf ${TMP}/${SRCDIR} && echo "${TMP}/${SRCDIR} cleanup completed"
fi
if [ -d ${PKG} ]; then
rm -rf ${PKG} && echo "${PKG} cleanup completed"
fi
rmdir ${TMP} && echo "${TMP} cleanup completed"
fi
exit 0