summaryrefslogtreecommitdiff
path: root/games/koules/koules.SlackBuild
blob: eb654a596071f8f30dad5e0dac842cb11f773b47 (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
#!/bin/sh

# Slackware build script for koules

# Written by B. Watson (yalhcru@gmail.com)

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

# This game used to be distributed on disk Y1 of Slackware 3.3.
# This script doesn't share any code with whatever build script
# existed back then (partly because I couldn't find a copy)

PRGNAM=koules
VERSION=${VERSION:-1.4}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i486 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

# Use MIT shared memory?

# On some systems, MITSHM speeds things up. On others, it slows them
# down or (on 64-bit systems) causes the game to crash on startup.
# If you set MITSHM=yes and have problems, try running koules with
# the -M flag. If the problems go away, rebuild with MITSHM=no to avoid
# having to give the -M flag all the time...
# I'm defaulting this to no, because modern systems should be fast enough
# to play this simple game without it.

MITSHM=${MITSHM:-no}

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM$VERSION
tar xvf $CWD/$PRGNAM$VERSION-src.tar.gz
cd $PRGNAM$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 {} \;

# 20140502 bkw: modern Slackware has OSS modules disabled by default,
# so wrap the sound server in aoss.
[ "${ALSA:-yes}" = "yes" ] && patch -p1 < $CWD/patches/aoss.diff

# sound server in /usr/libexec, game data in /usr/share/koules
# also, enable sound and joystick support.
patch -p1 < $CWD/patches/slackware.diff

# Grrr. Need this to compile with MITSHM disabled.
patch -p1 < $CWD/patches/compile_fix.diff

# Modern gcc seems to hate the inline assembly. Anyway I bet gcc's code
# with -O2 is the same or faster...
patch -p1 < $CWD/patches/no_inline_asm.diff

# The author forgot to mention the -E option in the help and man page
patch -p1 < $CWD/patches/document_E_option.diff

# Some people might like the launcher...
patch -p1 < $CWD/patches/tcl_launcher_paths.diff

# I hate Imake even worse than autoconf...
if [ "$MITSHM" = "no" ]; then
	sed -i -e '/#define MITSHM/d' Iconfig
fi

xmkmf -a

# Did I mention I hate Imake?
find . -name Makefile | \
		  xargs sed -i -e "s/-O2.*/$SLKCFLAGS/"
touch xkoules.man

# 20140502 bkw:
# parallel builds sometimes (usually) work, but not always. This is
# small enough that nobody should get too impatient even with -j1.
make -j1

# Don't trust 'make install', it doesn't fully support DESTDIR, and
# installs things with weird permissions. Again, Imake sucks.
# Also, we want to call the binary and manpage "koules", not "xkoules",
# so there'd be some manual stuff going on anyway.

mkdir -p $PKG/usr/games
strip --strip-unneeded x$PRGNAM
install -m0755 x$PRGNAM -o root -g root $PKG/usr/games/$PRGNAM
install -m0755 $PRGNAM.tcl -o root -g root $PKG/usr/games/$PRGNAM-launcher

mkdir -p $PKG/usr/libexec
strip $PRGNAM.sndsrv.linux
install -m0755 $PRGNAM.sndsrv.linux -o root -g root $PKG/usr/libexec/
install -m0755 $CWD/koules.kde -o root -g root $PKG/usr/libexec/

mkdir -p $PKG/usr/share/$PRGNAM
cp sounds/*.raw $PKG/usr/share/$PRGNAM

mkdir -p $PKG/usr/man/man6
gzip -9c x$PRGNAM.6 > $PKG/usr/man/man6/$PRGNAM.6.gz

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a README TODO ANNOUNCE BUGS COPYING Card Koules.FAQ \
	$PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
cat $CWD/README > $PKG/usr/doc/$PRGNAM-$VERSION/README.SBo

mkdir -p $PKG/usr/share/pixmaps
cp Koules.xpm $PKG/usr/share/pixmaps/$PRGNAM.xpm

mkdir -p $PKG/usr/share/applications
cat $CWD/$PRGNAM.desktop > $PKG/usr/share/applications/$PRGNAM.desktop

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:-tgz}