summaryrefslogtreecommitdiffstats
path: root/games/uqm-megamod/uqm-megamod.SlackBuild
blob: faf64aa14a3b765f781a61e7b9a63a91cb37bbd5 (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
#!/bin/bash

# Slackware build script for uqm-megamod

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

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

# Unlike the original uqm SlackBuild, I'm including all the optional
# content in this one build. It's the "MegaMod", so it should have
# everything. If you think this is too much, you should be using the
# original uqm instead.

# Also, OpenAL is enabled by default (unlike in uqm). Although it's
# still 'experimental', upstream's release binaries are built with
# it enabled. And even so, the user has to enable it in the in-game
# settings (default is 'mixsdl').

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

PRGNAM=uqm-megamod
VERSION=${VERSION:-0.8.1_3}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

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"
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
else
  SLKCFLAGS="-O2"
fi

set -e

SRCVER="${VERSION/_/-}"
SRCNAM="UQM-MegaMod"

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-$SRCVER
tar xvf $CWD/$SRCNAM-$SRCVER.tar.gz
cd $SRCNAM-$SRCVER
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 {} \+

# why do people even think it's a good idea to hide the compile
# commands behind something like this?
export MAKE_VERBOSE=1

# rather than interactive config:
cat $CWD/config.state > config.state

# hidden env var, let me test builds without OpenAL:
[ "${OPENAL:-yes}" = "no" ] && sed -i 's,openal,mixsdl,' config.state

# this generates build.vars:
sh build.sh uqm reprocess_config

# use our flags:
sed -i "s/-O3/$SLKCFLAGS/g" build.vars

# extract only -jNUM from MAKEFLAGS, any other flags, like -lNUM will break the build.
sh build.sh uqm $(printf '%s\n' "$MAKEFLAGS" | grep -o -e '-j[0-9]\+' | head -n 1)

mkdir -p $PKG/usr/games
install -s -m0755 UrQuanMasters $PKG/usr/games/$PRGNAM

# icon and desktop need a bit of love.
for px in 16 32 48 64 128; do
  size=${px}x${px}
  dir=$PKG/usr/share/icons/hicolor/$size/apps
  mkdir -p $dir
  convert -resize $size src/res/megamod.png $dir/$PRGNAM.png
done

mkdir -p $PKG/usr/share/pixmaps
ln -s ../icons/hicolor/48x48/apps/$PRGNAM.png $PKG/usr/share/pixmaps/$PRGNAM.png

# modified copy of upstream's .desktop. ours validates...
mkdir -p $PKG/usr/share/applications
cat $CWD/$PRGNAM.desktop > $PKG/usr/share/applications/$PRGNAM.desktop

# upstream ships a uqm.6 man page, but it's for the original uqm, not
# the megamod (which adds many new options). don't install it. maybe
# make a proper man page someday.

CONTENT_DIR=$PKG/usr/share/games/$PRGNAM/content
mkdir -p $CONTENT_DIR/{packages,addons}
install -oroot -groot -m0644 content/version $CONTENT_DIR/version
install -oroot -groot -m0644 $CWD/mm-0.8.1-content.uqm $CONTENT_DIR/packages

for i in \
  mm-0.8.1-hd.uqm \
  mm-0.8.1-3dovoice.uqm \
  uqm-0.7.0-3DOMusicRemastered.uqm \
  uqm-0.7.0-3dovideo.uqm
do
  install -oroot -groot -m0644 $CWD/$i $CONTENT_DIR/addons
done

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a AUTHORS BUGS *Change* Contrib* README* licenses doc/release WhatsNew \
      $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$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:-tgz}