162 lines
4.3 KiB
Bash
162 lines
4.3 KiB
Bash
#!/bin/bash
|
|
|
|
# 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.
|
|
|
|
# 20180612 bkw: update for v0.9, script can no longer build 0.8
|
|
# 20170531 bkw: BUILD=2, fix build on x86
|
|
# 20170302 bkw: use long-format github URL
|
|
|
|
cd $(dirname $0) ; CWD=$(pwd)
|
|
|
|
PRGNAM=opendune
|
|
VERSION=${VERSION:-0.9}
|
|
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
|
|
|
|
# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
|
|
# the name of the created package would be, and then exit. This information
|
|
# could be useful to other scripts.
|
|
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"
|
|
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/data" >> $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
|