summaryrefslogtreecommitdiff
path: root/games/qzdoom/qzdoom.SlackBuild
blob: 8239a75c5ec1cfc125c182927b5c8a08d7ae8b8a (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
#!/bin/bash

# Slackware build script for qzdoom

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

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

# Heavily based on gzdoom.SlackBuild, since gzdoom and qzdoom are synced
# up regularly.

# 20201027 bkw: BUILD=2
# - Updated download URL.
# - Install .pk3 files somewhere else, so they don't conflict with gzdoom.
# - Use upstream icon (also scaled versions in /usr/share/icons).
# - Make fluidsynth MIDI work again.
# - Fix <unknown version> in the window title.
# - Remove extraneous article from README & slack-desc ("a most" => "most").

# Note about "new" releases:

# qzdoom now belongs to a different github user, so the URL is
# updated... but there's still no new release of it. If you check the
# repo, you'll see the same releases as gzdoom (e.g. g4.4.2). These
# are *not* qzdoom, they're gzdoom (try downloading the tarballs from
# the qzdoom and gzdoom repos with the same version number and diffing
# them). So only releases (tags) that begin with "q" are really
# qzdoom, and 2.1.0 is still the latest.

# TL;DR: Please don't email me saying there's a new release unless the
# version number starts with "q".

PRGNAM=qzdoom
VERSION=${VERSION:-2.1.0}
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"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

set -e

SRCVER=q$VERSION

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

# 20201027 bkw: dirty hack to get fluidsynth 2.x to work. qzdoom's
# fluidsynth support stopped working when fluidsynth got updated
# to 2.x.
sed -i '/libfluidsynth\.so/s,\.1,.2,' \
       src/sound/mididevices/music_fluidsynth_mididevice.cpp

# 20201027 bkw: fix the '<unknown version>' in the window title.
( echo "#define GIT_DESCRIPTION \"$VERSION\""
  echo "#define GIT_HASH \"release\""
  echo "#define GIT_TIME __DATE__" ) > src/gitinfo.h

# 20201027 bkw: change SHARE_DIR to qzdoom, to avoid stepping on or
# accidentally loading the *.pk3 stuff from gzdoom. This won't stop
# qzdoom from finding the IWADs in /usr/share/games/doom since this
# path is also searched.

SLKCFLAGS="$SLKCFLAGS -DNDEBUG -fuse-ld=gold"
SD=/usr/share/games/$PRGNAM
mkdir -p build
cd build
  cmake \
    -DCMAKE_C_FLAGS_RELEASE="$SLKCFLAGS -DSHARE_DIR=\\\"$SD\\\"" \
    -DCMAKE_CXX_FLAGS_RELEASE="$SLKCFLAGS -DSHARE_DIR=\\\"$SD\\\"" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DINSTALL_PATH=games \
    -DINSTALL_DOCS_PATH=doc/$PRGNAM-$VERSION \
    -DLIB_SUFFIX=${LIBDIRSUFFIX} \
    -DINSTALL_PK3_PATH=$SD \
    -DCMAKE_BUILD_TYPE=Release ..
  make VERBOSE=1
  make install/strip DESTDIR=$PKG VERBOSE=1
cd ..

# .desktop written by SlackBuild author.
mkdir -p $PKG/usr/share/applications
cat $CWD/$PRGNAM.desktop > $PKG/usr/share/applications/$PRGNAM.desktop

# New-school desktop-ey icons.
for i in 16 22 32 48 64 128 256; do
  SIZE=${i}x${i}
  DIR=$PKG/usr/share/icons/hicolor/$SIZE/apps
  mkdir -p $DIR
  convert src/posix/zdoom.xpm -resize $SIZE $DIR/$PRGNAM.png
done

# Old-school windowmanagerish icon.
mkdir -p $PKG/usr/share/pixmaps
ln -s ../icons/hicolor/64x64/apps/$PRGNAM.png $PKG/usr/share/pixmaps/$PRGNAM.png

# docs already installed.
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}