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

# Slackware build script for snes9x

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

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

# 20180730 bkw:
# - BUILD=2.
# - add libretro/RetroArch, thanks to orbea.
# - add --without-portaudio to configure args. snes9x runs about
#   1 frame/sec if I start it up with the sound driver set to portaudio,
#   and I've gotten a report of it blasting high-volume white noise
#   thru the speakers if you switch to portaudio while a ROM is already
#   running. I can't see any reason to use it in favor of pulse, alsa,
#   oss, or sdl audio.
# - don't extract windows, mac, old-school unix stuff from tarball.
#   uses 50% less $TMP space.

# 20180623 bkw: update for 1.56.2.
# 20180611 bkw:
# - update for 1.56.1.
# - switch the UI from gtk3 to gtk2, as 14.2's gtk3 is too old.
# - add undocumented PULSE=no build option (in anticipation of 15.0's
#   pure-alsa-system).
# - add SDL2 to REQUIRES. technically, it's not truly required: snes9x
#   only uses SDL2 to support joysticks. playing with the keyboard/mouse
#   would still work without it. 15.0 is coming soon, and will have SDL2
#   in the core OS, so don't bother me about this decision.
# - update README, the snes9x_gtk build went away in 2010, no need to
#   mention it now. also add notes about upgrading from 1.55.
# 20171221 bkw: use --without-system-zip to build bundled unzip, instead
#               of adding minizip as a dependency.
# 20171213 bkw: update for 1.55.
# 20170302 bkw: use long-format github URL
# 20161015 bkw: update for 1.54.1. script has changed enough that it
# can't build 1.53 any more.

PRGNAM=snes9x
VERSION=${VERSION:-1.56.2}
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

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
# Don't extract the stuff we don't need, this saves 7.9MB in $TMP.
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz \
        --wildcards --exclude '*/win32/*' \
        --exclude '*/macosx/*' --exclude '*/unix/*'
cd $PRGNAM-$VERSION
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 {} \+

# Fix the libretro build for 14.2.
# From upstream git: https://github.com/snes9xgit/snes9x.git
# commits abb4b4c39 and a77b3b379b
patch -p1 < $CWD/libretro.diff

cd gtk
./autogen.sh

if [ "$PULSE" = "no" ] || ! pkg-config --exists libpulse; then
  PULSEOPT="--without-pulseaudio"
fi

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --bindir=/usr/games \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --with-netplay \
  --without-system-zip \
  --with-gtk2 \
  --without-gtk3 \
  --without-portaudio \
  $PULSEOPT \
  --build=$ARCH-slackware-linux

make
make install-strip DESTDIR=$PKG

# RetroArch support, contributed by orbea (Hunter Sezen).
# Note that the source here is self-contained, there's no build-time
# dependency on RetroArch or libretro or such.
# snes9x_libretro-info originally came from:
# https://raw.githubusercontent.com/libretro/libretro-super/383f18fd7c36ffd5fe76ebac58e9e596dde67e66/dist/info/snes9x_libretro.info
# Renamed .info => -info to avoid confusing SBo tools that deal with
# SBo's .info files.
( LIBNAM=${PRGNAM}_libretro
  cd ../libretro
  make
  install -sDm0755 $LIBNAM.so $PKG/usr/lib${LIBDIRSUFFIX}/libretro/$LIBNAM.so
  install -Dm0644 $CWD/$LIBNAM-info \
    $PKG/usr/lib${LIBDIRSUFFIX}/libretro/info/$LIBNAM.info
)

mkdir -p $PKG/usr/man/man6
gzip -9c $CWD/snes9x-gtk.6 > $PKG/usr/man/man6/snes9x-gtk.6.gz
ln -s $PRGNAM-gtk.6.gz $PKG/usr/man/man6/$PRGNAM.6.gz
ln -s $PRGNAM-gtk $PKG/usr/games/$PRGNAM

PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
OLDDOC=$PKGDOC/${PRGNAM}_original_docs
mkdir -p $OLDDOC
cp -a doc/* $PKGDOC
cp -a ../docs/* $OLDDOC
cat $CWD/README_docs.txt > $PKGDOC/README_docs.txt
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

# We don't need 3 copies of the LGPL v2.1 (we already have the GPL
# and proprietary snes9x licenses...)
cd $PKGDOC
  rm -f snes_ntsc_license.txt ${PRGNAM}_original_docs/lgpl-2.1.txt
  ln -s lgpl.txt snes_ntsc_license.txt
  ln -s ../lgpl.txt ${PRGNAM}_original_docs/lgpl-2.1.txt
cd -

cat data/$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}