slackbuilds_ponce/games/opendune/opendune.SlackBuild
B. Watson 8421bc3700 games/opendune: Fix x86 build.
Signed-off-by: B. Watson <yalhcru@gmail.com>
2017-06-03 08:00:22 +07:00

150 lines
3.9 KiB
Bash

#!/bin/sh
# Slackware build script for opendune
# Written by B. Watson (yalhcru@gmail.com)
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
# 20170531 bkw: BUILD=2, fix build on x86
# 20170302 bkw: use long-format github URL
PRGNAM=opendune
VERSION=${VERSION:-0.8}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
MMX=${MMX:-maybe}
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
MMX=${MMX:-maybe}
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
SRCNAM=OpenDUNE
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-$VERSION
tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
cd $SRCNAM-$VERSION
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 {} \;
# 20170531 bkw: upstream uses #if defined(__i386__) to test for MMX,
# which is wrong (should be checking __MMX__ instead). This only affects
# x86 builds (not x86_64), and only if SDL 1 is used.
patch -p1 < $CWD/mmx_bodge.diff
if [ "$MMX" = "maybe" ]; then
if grep -q '\<mmx\>' /proc/cpuinfo; then
MMX="yes"
else
MMX="no"
fi
echo "=== autodected MMX: $MMX"
fi
if [ "$MMX" = "yes" ]; then
SLKCFLAGS="$SLKCFLAGS -mmmx"
echo "=== added -mmmx to SLKCFLAGS"
fi
# Fix compile issue with /usr/include/alsa/pcm.h (uses inline)
sed -i 's,-ansi,,' config.lib
# Install docs to Slack standard location
sed -i "s,share/doc/$PRGNAM,doc/$PRGNAM-$VERSION," config.lib
# Look in game dir for .ini file.
sed -i "/\"data\//s,data,/usr/share/games/$PRGNAM," src/inifile.c
# Allow building with ALSA instead of pulseaudio. There's no way to switch
# between ALSA and Pulse at runtime, and many users prefer to avoid Pulse.
if [ "${PULSE:-yes}" = "no" -o ! -x /usr/bin/pulseaudio ]; then
PULSEOPT="--without-pulse"
fi
# The configure script autodetects SDL 2, but it doesn't check for
# SDL2_image (assumes it's there if SDL2 is). So if someone's installed
# SDL2 but not SDL2_image, the build will fail. Fix:
if [ "${SDL2:-yes}" = "no" ]; then
SDLOPT="--without-sdl2"
SDLVER=1
elif pkg-config --exists sdl2 && pkg-config --exists SDL2_image; then
SDLOPT="--with-sdl2"
SDLVER=2
else
SDLOPT="--without-sdl2"
SDLVER=1
fi
# N.B. non-standard (non-autoconf) configure options here!
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
$PULSEOPT \
$SDLOPT \
--prefix-dir=/usr \
--install-dir=$PKG \
make
strip bin/$PRGNAM
make install
# Include shell script wrapper to start timidity if installed.
mkdir -p $PKG/usr/libexec/$PRGNAM
mv $PKG/usr/games/$PRGNAM $PKG/usr/libexec/$PRGNAM
install -m0755 -oroot -groot $CWD/$PRGNAM.sh $PKG/usr/games/$PRGNAM
# Include default .ini file with location of data files. data/
# is always appended to whatever datadir is set to.
INI=$PKG/usr/share/games/$PRGNAM/$PRGNAM.ini
cat bin/$PRGNAM.ini.sample > $INI
echo "datadir=/usr/share/games/$PRGNAM" >> $INI
# This dir is where the .PAK files should go.
mkdir -p $PKG/usr/share/games/$PRGNAM/data
# .desktop written for this build
mkdir -p $PKG/usr/share/applications
cat $CWD/$PRGNAM.desktop > $PKG/usr/share/applications/$PRGNAM.desktop
# docs already installed, but include this:
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
sed "s,@S@,$SDLVER," $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:-tgz}