slackbuilds_ponce/games/citra/citra.SlackBuild
Nathaniel Russell 9b34340d2b games/citra: Updated for version 0.1785.
Signed-off-by: bedlam <dave@slackbuilds.org>
2022-09-12 21:10:03 +01:00

209 lines
8 KiB
Bash

#!/bin/bash
# Slackware build script for citra
# Copyright 2022 Nathaniel Russell <Texas, 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.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=citra
SRCNAM=$PRGNAM-nightly-nightly
PRGVER=${PRGVER:-"1785"}
VERSION=${VERSION:-0.1785}
BOOST=${BOOST:-36603a1e665e849d29b1735a12c0a51284a10dd0}
CATCH=${CATCH:-c4e3767e265808590986d5db6ca1b5532a7f3d13}
CPPJWT=${CPPJWT:-e12ef06218596b52d9b5d6e1639484866a8e7067}
CRYPTOPP=${CRYPTOPP:-f2102243e6fdd48c0b2a393a0993cca228f20573}
CUBEB=${CUBEB:-1d66483ad2b93f0e00e175f9480c771af90003a7}
DISCORDRPC=${DISCORDRPC:-963aa9f3e5ce81a4682c6ca3d136cddda614db33}
DYNARMIC=${DYNARMIC:-9f88f234a180a5e8d5620b4803c971fb6dc2d9f2}
ENET=${ENET:-498b9e3571c2e096d7143c3c76852c5ec28d7885}
EXTSOUNDTOUCH=${EXTSOUNDTOUCH:-060181eaf273180d3a7e87349895bd0cb6ccbf4a}
FMTLIB=${FMTLIB:-cc09f1a6798c085c325569ef466bcdcffdc266d4}
GOOGLETEST=${GOOGLETEST:-800f5422ac9d9e0ad59cd860a2ef3a679588acb4}
INIH=${INIH:-1e80a47dffbda813604f0913e2ad68c7054c14e4}
LIBRESSL=${LIBRESSL:-8929f818fd748fd31a34fec7c04558399e13014a}
LIBUSB=${LIBUSB:-c6a35c56016ea2ab2f19115d2ea1e85e0edae155}
LIBYUV=${LIBYUV:-19d71f6b351fe992ae34b114eebd872c383a6bdb}
LODEPNG=${LODEPNG:-31d9704fdcca0b68fb9656d4764fa0fb60e460c2}
NIHSTRO=${NIHSTRO:-fd69de1a1b960ec296cc67d32257b0f9e2d89ac6}
SANITIZERSCMAKE=${SANITIZERSCMAKE:-aab6948fa863bc1cbe5d0850bc46b9ef02ed4c1a}
TEAKRA=${TEAKRA:-01db7cdd00aabcce559a8dddce8798dabb71949b}
XBYAK=${XBYAK:-c306b8e5786eeeb87b8925a8af5c3bf057ff5a90}
ZSTD=${ZSTD:-97a3da1df009d4dc67251de0c4b1c9d7fe286fc1}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
DEPS=$TMP/$SRCNAM-$PRGVER/externals
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-$PRGVER
tar xvf $CWD/$SRCNAM-$PRGVER.tar.?z
# citra has quite a few external dependencies, we need to extract them to the correct location.
tar xvf $CWD/boost-$BOOST.tar.gz -C \
$DEPS/boost --strip-components 1
tar xvf $CWD/catch-$CATCH.tar.gz -C \
$DEPS/catch --strip-components 1
tar xvf $CWD/cpp-jwt-$CPPJWT.tar.gz -C \
$DEPS/cpp-jwt --strip-components 1
tar xvf $CWD/cryptopp-$CRYPTOPP.tar.gz -C \
$DEPS/cryptopp/cryptopp --strip-components 1
tar xvf $CWD/cubeb-$CUBEB.tar.gz -C \
$DEPS/cubeb --strip-components 1
tar xvf $CWD/googletest-$GOOGLETEST.tar.gz -C \
$DEPS/cubeb/googletest --strip-components 1
tar xvf $CWD/discord-rpc-$DISCORDRPC.tar.gz -C \
$DEPS/discord-rpc --strip-components 1
tar xvf $CWD/dynarmic-$DYNARMIC.tar.gz -C \
$DEPS/dynarmic --strip-components 1
tar xvf $CWD/enet-$ENET.tar.gz -C \
$DEPS/enet --strip-components 1
tar xvf $CWD/ext-soundtouch-$EXTSOUNDTOUCH.tar.gz -C \
$DEPS/soundtouch --strip-components 1
tar xvf $CWD/fmtlib-$FMTLIB.tar.gz -C \
$DEPS/fmt --strip-components 1
tar xvf $CWD/inih-$INIH.tar.gz -C \
$DEPS/inih/inih --strip-components 1
tar xvf $CWD/libressl-portable-$LIBRESSL.tar.gz -C \
$DEPS/libressl --strip-components 1
tar xvf $CWD/libusb-$LIBUSB.tar.gz -C \
$DEPS/libusb/libusb --strip-components 1
tar xvf $CWD/libyuv-$LIBYUV.tar.gz -C \
$DEPS/libyuv --strip-components 1
tar xvf $CWD/lodepng-$LODEPNG.tar.gz -C \
$DEPS/lodepng/lodepng --strip-components 1
tar xvf $CWD/nihstro-$NIHSTRO.tar.gz -C \
$DEPS/nihstro --strip-components 1
tar xvf $CWD/sanitizers-cmake-$SANITIZERSCMAKE.tar.gz -C \
$DEPS/cubeb/cmake/sanitizers-cmake --strip-components 1
tar xvf $CWD/teakra-$TEAKRA.tar.gz -C \
$DEPS/teakra --strip-components 1
tar xvf $CWD/xbyak-$XBYAK.tar.gz -C \
$DEPS/xbyak --strip-components 1
tar xvf $CWD/zstd-$ZSTD.tar.gz -C \
$DEPS/zstd --strip-components 1
# citra checks for external components by checking for their .git files.
# Since these are not included when we downloaded the commit tarballs, we'll create them.
echo "gitdir: ../../.git/modules/boost" > $DEPS/boost/.git
echo "gitdir: ../../.git/modules/catch" > $DEPS/catch/.git
echo "gitdir: ../../.git/modules/cpp-jwt" > $DEPS/cpp-jwt/.git
echo "gitdir: ../../.git/modules/cryptopp" > $DEPS/cryptopp/cryptopp/.git
echo "gitdir: ../../.git/modules/cubeb" > $DEPS/cubeb/.git
echo "gitdir: ../../.git/modules/discord-rpc" > $DEPS/discord-rpc/.git
echo "gitdir: ../../.git/modules/dynarmic" > $DEPS/dynarmic/.git
echo "gitdir: ../../.git/modules/enet" > $DEPS/enet/.git
echo "gitdir: ../../.git/modules/soundtouch" > $DEPS/soundtouch/.git
echo "gitdir: ../../.git/modules/fmt" > $DEPS/fmt/.git
echo "gitdir: ../../../.git/modules/inih" > $DEPS/inih/inih/.git
echo "gitdir: ../../.git/modules/libressl" > $DEPS/libressl/.git
echo "gitdir: ../../../.git/modules/libusb" > $DEPS/libusb/libusb/.git
echo "gitdir: ../../.git/modules/libyuv" > $DEPS/libyuv/.git
echo "gitdir: ../../../.git/modules/lodepng" > $DEPS/lodepng/lodepng/.git
echo "gitdir: ../../.git/modules/nihstro" > $DEPS/nihstro/.git
echo "gitdir: ../../.git/modules/teakra" > $DEPS/teakra/.git
echo "gitdir: ../../.git/modules/xbyak" > $DEPS/xbyak/.git
echo "gitdir: ../../.git/modules/zstd" > $DEPS/zstd/.git
cd $PRGNAM-nightly-nightly-$PRGVER
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
mkdir -p build
cd build
cmake \
-DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
-DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLIB_SUFFIX=${LIBDIRSUFFIX} \
-DMAN_INSTALL_DIR=/usr/man \
-DCMAKE_BUILD_TYPE=Release ..
make
make install/strip DESTDIR=$PKG
cd ..
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
mv $PKG/usr/share/man $PKG/usr
find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
# Install hicolor
for size in $(find /usr/share/icons/hicolor -type d -mindepth 1 -maxdepth 1 -exec basename {} \;); do
if [ -d assets/unix-icons/hicolor/${size} ]; then
cp -a assets/unix-icons/hicolor/${size} $PKG/usr/share/icons/hicolor/${size}
fi
done
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
CONTRIBUTING* README* license.txt \
$PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/qt-config.ini > $PKG/usr/doc/$PRGNAM-$VERSION/qt-config.ini.sample
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE