aboutsummaryrefslogtreecommitdiff
path: root/games/opendune/opendune.SlackBuild
blob: 6f11010a4881cd7ddd7ca4e80d83094a29a36a4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/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}