aboutsummaryrefslogtreecommitdiff
path: root/games/doomretro/doomretro.SlackBuild
blob: a2c86648f73fe4458827edae6748dbce777a614d (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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash

# Slackware build script for doomretro

# Copyright 2017 Dugan Chen Canada
# Copyright 2020-2024 B. Watson
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# 20230715 bkw: update for v4.9.2.
# - finally fix the segfaults when the music changes.
# - remove music note from README, since music works now.
# - remove -nomusic from the .desktop file.

# 20230114 bkw: update for v4.7.2, add note about music to README.
# 20220611 bkw: update for v4.5.1, fix 16x16 icon path.
# 20211006 bkw:
# - update for v4.2.3.
# - get rid of wrapper script; game now picks an IWAD itself.
# 20210224 bkw: update for v4.0.3
# 20200927 bkw: update for v3.6.1, reformat README to 72 chars
# 20200804 bkw: update for v3.5.10
# 20200413 bkw:
# - take over maintenance
# - update for v3.5.4
# - move binary to /usr/games
# - include wrapper script

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

PRGNAM=doomretro
VERSION=${VERSION:-5.5.1}
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 [ ! -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

LIBNAM=SDL2_mixer
LIBVER=${LIBVER:-2.0.4}

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
TOPDIR=$TMP/$PRGNAM-build
rm -rf $TOPDIR
mkdir -p $TOPDIR
cd $TOPDIR

tar xvf $CWD/$LIBNAM-$LIBVER.tar.lz

# All these --excludes save ~30MB in /tmp, and avoid the recursive chmod
# tripping over broken symlinks.
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz \
  --exclude=xcode \
  --exclude=codeblocks \
  --exclude=msvc \
  --exclude=SDL2\*

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 {} \+

# 20230715 bkw: This is an ugly way to fix an issue caused by Slackware's
# SDL2_mixer package. doomretro uses SDL2_mixer's FluidSynth support for
# its music. And SDL2_mixer-2.0.4 (what's in Slackware 15.0) has a crashing
# bug: any time Mix_FreeMusic(handle) is called when the handle is using
# fluidsynth, we get a use-after-free that causes the app to segfault.
# More details, including a link to the patch I use, here:
# https://github.com/FluidSynth/fluidsynth/issues/748
# The fix, here, is to build a *static* patched SDL2_mixer for
# doomretro to link with. Lot of work, but it does fix the issue. When
# Slackware 15.1 releases, we should be able to get rid of this.

mkdir -p $LIBNAM-install
cd $LIBNAM-$LIBVER

patch -p0 < $CWD/fix-sdl-mixer-fluidsynth.diff

# N.B. --disable-music-mp3-mad-gpl because enabling it breaks the build,
# as we have no static libmad.a. doesn't matter, because doomretro doesn't
# use mp3 audio anyway.
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=$TOPDIR/$LIBNAM-install \
  --sysconfdir=/etc \
  --disable-shared \
  --enable-static \
  --disable-dependency-tracking \
  --disable-music-mp3-mad-gpl \
  --build=$ARCH-slackware-linux

make
make install

# this actually works fine, amazingly enough:
export PKG_CONFIG_PATH=$TOPDIR/$LIBNAM-install/lib/pkgconfig:$PKG_CONFIG_PATH

cd $TOPDIR/$PRGNAM-$VERSION
mkdir -p build
cd build
  cmake \
    -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release ..
  make
  make install/strip DESTDIR=$PKG
cd ..

mv $PKG/usr/bin $PKG/usr/games

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

hicolor=$PKG/usr/share/icons/hicolor
mkdir -p $hicolor/{16x16,32x32,48x48,256x256}/apps
convert res/$PRGNAM.ico[0] $hicolor/256x256/apps/$PRGNAM.png
convert res/$PRGNAM.ico[1] $hicolor/48x48/apps/$PRGNAM.png
convert res/$PRGNAM.ico[2] $hicolor/32x32/apps/$PRGNAM.png
convert res/$PRGNAM.ico[3] $hicolor/16x16/apps/$PRGNAM.png
mkdir -p $PKG/usr/share/pixmaps
ln -s ../icons/hicolor/48x48/apps/$PRGNAM.png $PKG/usr/share/pixmaps

# 20230715 bkw: include COPYING.txt from SDL2_mixer, since we statically
# link it to the binary.
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a CODEOWNERS *.md $PKGDOC
cp -a $TOPDIR/$LIBNAM-$LIBVER/COPYING.txt $PKGDOC/COPYING-SDL2_mixer.txt
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$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