summaryrefslogtreecommitdiffstats
path: root/games/pinball/pinball.SlackBuild
blob: 46f9710036cd2cf928a574bd95820e608ee16e3c (plain)
#!/bin/bash

# Slackware build script for pinball

# Original author: Hunter Sezen.
# Modified and now maintained by B. Watson <urchlay@slackware.uk>.

# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.

# 20240902 bkw: BUILD=3
# - new maintainer.
# - relicense as WTFPL.
# - add .desktop and icon to package.
# - add doinst.sh.
# - clean up README and slack-desc.
# - add Debian's man page for pinball-config.

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=pinball
VERSION=${VERSION:-0.3.4}
BUILD=${BUILD:-2}
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

if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  exit 0
fi

TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

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 -eu

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L .  -perm /111 -a \! -perm 755 -a -exec chmod 755 {} + -o \
        \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} +

# Use a sys version of ltdl
# https://github.com/sergiomb2/pinball/pull/23
# https://github.com/sergiomb2/pinball/commit/e3ac2b6addf31cb350f572e24794ef9f9535d566
patch -p1 < $CWD/pinball-0.3.4-sys-ltdl.patch

# Fix build issue with gettext-0.20.
# https://github.com/sergiomb2/pinball/pull/30
patch -p1 < $CWD/gettext-version.patch

autoreconf -fi

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --bindir=/usr/games \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --datadir=/usr/share/games \
  --disable-sdltest \
  --with-x \
  --enable-static=no \
  --build=$ARCH-slackware-linux

make
make install-strip DESTDIR=$PKG

mkdir -p $PKG/usr/share/{applications,pixmaps,icons/hicolor/48x48/apps}
cp -a pinball.desktop $PKG/usr/share/applications
cp -a pinball.png $PKG/usr/share/icons/hicolor/48x48/apps
ln -s ../icons/hicolor/48x48/apps/pinball.png $PKG/usr/share/pixmaps/pinball.png

mkdir -p $PKG/usr/man/man6
gzip -9c < $CWD/pinball-config.6 > $PKG/usr/man/man6/pinball-config.6.gz

PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a AUTHORS COPYING ChangeLog License.txt README $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$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