aboutsummaryrefslogtreecommitdiff
path: root/games/higan/higan.SlackBuild
blob: 97169db74c11932a3652740999aa7a979666de02 (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
#!/bin/sh

# Slackware build script for higan

# Based on bsnes SlackBuild by Erik Hanson <email removed>
# Maintained by Gabriel Magno <email removed>
# Modified by Johannes Schoepfer <email removed>
# Modified again & now maintained by B. Watson <yalhcru@gmail.com>

# Copyright 2013 Gabriel Magno, Belo Horizonte, MG, Brazil
# 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.

# 20200907 bkw: upstream source moved and changed to .tar.gz, get
#               rid of p7zip dependency. BUILD=2.
# 20200529 bkw: add "can't update version" note to README.
# 20181211 bkw:
# This update would not have happened without assistance and moral support
# from Yossi Ne'eman. Thanks!
# - Take over maintenance.
# - Update for v110.
# - Use the gtk frontend, not the *broken* qt one.
# - Make OpenAL dep optional & autodetected (and OPENAL=no to force-disable).
# - Add OSS (default no) and PULSE (default yes) env vars.
# - Fix permissions of the stuff installed to /usr/share/higan: everything
#   was executable, ugh.
# - Install binary in /usr/games (it's a game system emulator, people).
# - Update the README, include link to the semi-official doc site.
# - Update slack-desc with current list of supported systems.
# - Add man pages. Note to SBo admins: please don't remove my *.rst man
#   page sources!

PRGNAM=higan
VERSION=${VERSION:-110}
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

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

SRCNAM=${PRGNAM}_v${VERSION}-source

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION

# Bletcherous permissions, please don't replace with template code.
find . -type d -exec chmod 0755 {} \+
find . -type f -exec chmod 0644 {} \+
chown -R root:root .

# Thanks to the Arch folks for these patches. -flags allows us to pass
# custom CFLAGS, and -paths makes the emulator look in /usr/share/higan
# for its support files if they're not found in ~/.local/share/higan.
patch -p1 -i $CWD/higan-flags.diff
patch -p1 -i $CWD/higan-paths.diff

# 20181212 bkw: audio system stuff. Upstream doesn't give us a way to
# disable these on the make command line, but hacking this file works:
HACKFILE=higan/target-higan/GNUmakefile

sed 's|/usr/local/lib/qt5/bin/moc|moc-qt5|' -i hiro/GNUmakefile

# Who actually uses OSS?
if [ "${OSS:-no}" = "no" ]; then
  sed -i '/^ *ruby /s,audio\.oss,,' $HACKFILE
fi

# Prepare for 15.0's pure-alsa-system option.
if [ "${PULSE:-yes}" = "no" ] || ! [ -e /usr/bin/pulseaudio ]; then
  sed -i '/^ *ruby /s,audio\.pulse[^ ]*,,g' $HACKFILE
fi

# Upstream *should* autodetect this, but doesn't.
if [ "${OPENAL:-yes}" = "no" ] || ! pkg-config --exists openal; then
  sed -i '/^ *ruby /s,audio\.openal,,' $HACKFILE
fi

# 20181212 bkw: switch from hiro=qt to hiro=gtk. I have no idea why the
# original author chose qt... the qt frontend is known to be buggy in v106
# (per upstream's git log). Issues I ran into were segfaulting on exit,
# and sometimes the Settings tabs wouldn't get painted... which are both
# mentioned as known issues in the git log. There are some post-106
# commits that may fix the qt issues; we'll see, when 107 is released.

CXXFLAGS="$SLKCFLAGS" \
make -C icarus \
  prefix=/usr \
  platform=linux \
  hiro=qt5

CXXFLAGS="$SLKCFLAGS" \
make -C $PRGNAM \
  prefix=/usr \
  platform=linux \
  hiro=qt5

mkdir -p $PKG/usr/games \
  $PKG/usr/share/applications \
  $PKG/usr/share/$PRGNAM \
  $PKG/usr/share/pixmaps

install -s -m 755 $PRGNAM/out/$PRGNAM icarus/out/icarus $PKG/usr/games/
install -m 644 $PRGNAM/target-higan/resource/$PRGNAM.desktop $PKG/usr/share/applications/
install -m 644 $PRGNAM/target-higan/resource/$PRGNAM.png $PKG/usr/share/pixmaps/
cp -dr $PRGNAM/System/* $PKG/usr/share/$PRGNAM/

# Man pages by B. Watson. higan.6 is basically the higan-cli.md from the
# git repo, reformatted as RST & converted to a man page. icarus.6 was
# written from scratch (and doesn't have much to say, you'll notice).
mkdir -p $PKG/usr/man/man6
for i in $PRGNAM icarus; do
  gzip -9c < $CWD/$i.6 > $PKG/usr/man/man6/$i.6.gz
done

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp *.md $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}