summaryrefslogtreecommitdiffstats
path: root/games/snes9x/snes9x.SlackBuild
blob: ad2655180684a425a880b64100828591b138dfa8 (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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash

# Slackware build script for snes9x

# Written by B. Watson (urchlay@slackware.uk)

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

# 20230418 bkw: BUILD=2, make portaudio optional + autodetected.
# 20230410 bkw: update for 1.62.3.
# Most of the work needed for this update was done by M.Dinslage,
# to whom I owe thanks. I updated the man page, and added the
# non-GUI binary plus a man page for it.

# For older change-comments, see ChangeLog.old (it was getting too long
# to keep in the script).

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

PRGNAM=snes9x
VERSION=${VERSION:-1.62.3}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}

SPIRVVER="2021-01-15"
VULKVER="1.3.246"
GLSLANGVER="12.1.0"

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}

# Note: the flags we set here are followed by -O3, meaning the
# -O2 does nothing. *shrug*
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 a few MB in $TMP.
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz \
        --wildcards \
        --exclude '*/win32/*' \
        --exclude '*/macosx/*'
cd $PRGNAM-$VERSION

tar xvf $CWD/glslang-$GLSLANGVER.tar.gz \
  -C external/glslang --strip-components=1
tar xvf $CWD/SPIRV-Cross-$SPIRVVER.tar.gz \
  -C external/SPIRV-Cross --strip-components=1
tar xvf $CWD/Vulkan-Headers-$VULKVER.tar.gz \
  -C external/vulkan-headers --strip-components=1

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

WITHPULSE=yes
if [ "$PULSE" = "no" ] || ! pkg-config --exists libpulse; then
  PULSEOPT="-DUSE_PULSEAUDIO=OFF"
  WITHPULSE=no
fi

WITHOSS=yes
if [ "${OSS:-no}" = "no" ]; then
  OSSOPT="-DUSE_OSS=OFF"
  WITHOSS=no
fi

WITH_PA=no
PA_OPT="-DUSE_PORTAUDIO=OFF"
if pkg-config --exists portaudio-2.0 && [ "${PORTAUDIO:-yes}" = "yes" ]; then
  WITH_PA=yes
  PA_OPT="-DUSE_PORTAUDIO=ON"
fi

SLKCFLAGS+=" -DNDEBUG"
mkdir -p gtk/build
cd gtk/build
  cmake \
    -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_BINDIR=games \
    $PULSEOPT $OSSOPT $PA_OPT \
    -DCMAKE_INSTALL_DATAROOTDIR=share \
    -DUSE_SYSTEMZIP=OFF \
    -DCMAKE_BUILD_TYPE=Release ..
  make VERBOSE=1
  make install/strip DESTDIR=$PKG
cd -

# 20230410 bkw: Insidious weirdness: The bitmap icons all look the
# same, but the .svg icon looks completely different. Just get rid
# of it; we have the bitmap icons at every size we could want.
rm -rf $PKG/usr/share/icons/hicolor/scalable

# 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.txt to avoid confusing SBo tools that deal with
# SBo's .info files.
# 20181201 bkw: made this optional, auto-detected, and controllable
# via environment. It makes the build take 7x as long, no point wasting
# time building it if it's not wanted/needed.

case "$RETROARCH" in
  yes) build_ra=yes ;;
  no)  build_ra=no ;;
  *)   if [ -x /usr/share/games/retroarch ]; then
         build_ra=yes
       else
         build_ra=no
       fi ;;
esac

if [ "$build_ra" = "yes" ]; then
  echo "=== Building libretro core"
  ( LIBNAM=${PRGNAM}_libretro
    PKGLIB=$PKG/usr/lib$LIBDIRSUFFIX
    cd libretro
    make LTO="-flto=jobserver"
    install -sDm0755 $LIBNAM.so $PKGLIB/libretro/$LIBNAM.so
    install -Dm0644 -o root -g root $CWD/$LIBNAM.info.txt \
      $PKGLIB/libretro/info/$LIBNAM.info
  )
else
  echo "=== NOT building libretro core"
fi

# Go ahead and include the non-gui binary. Note that it doesn't
# support OSS or Pulse (only ALSA), so the OSS and PULSE environment
# vars don't affect it.
cd unix
  CFLAGS="$SLKCFLAGS" \
  CXXFLAGS="$SLKCFLAGS" \
  ./configure \
    --prefix=/usr \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --mandir=/usr/man \
    --docdir=/usr/doc/$PRGNAM-$VERSION \
    --enable-gamepad \
    --enable-gzip \
    --enable-screenshot \
    --enable-zip \
    --without-system-zip \
    --build=$ARCH-slackware-linux
  make
cd -

# No 'make install' target.
install -s -m0755 unix/snes9x $PKG/usr/games/snes9x

# Man pages written by SlackBuild author.
mkdir -p $PKG/usr/man/man6
gzip -9c $CWD/snes9x-gtk.6 > $PKG/usr/man/man6/snes9x-gtk.6.gz
gzip -9c $CWD/snes9x.6 > $PKG/usr/man/man6/snes9x.6.gz

PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a LICENSE README* docs/* unix/docs/* unix/snes9x.conf.default $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

mkdir -p $PKG/install
sed -e "s,@PU@,$WITHPULSE," \
    -e "s,@OSS@,$WITHOSS," \
    -e "s,@PA@,$WITH_PA," \
    -e "s,@RA@,$build_ra," \
    < $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