aboutsummaryrefslogtreecommitdiff
path: root/system/86box/86box.SlackBuild
blob: 07125b84af3b6dbc377512e4532d02e2fbbc8417 (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
#!/bin/bash

# Slackware build script for 86box

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

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

# Notes:

# This thing uses the current directory for its config file. I thought
# about patching it to use ~/.86box.cfg or ~/.config/86Box/86box.cfg,
# but it might be considered a feature (create each VM in it own
# directory, with its own 86box.cfg).

# We now have rtmidi in the repo. The build doesn't autodetect it and
# disable it if it's missing, we have to help it out with -DRTMIDI=OFF
# if needed. It's OK, it'll use FluidSynth for MIDI playback if there's
# no rtmidi.

# The linbox-qt5 frontend, despite its name, seems to require qt6 (pyside6).
# The sl86 fronend looks too simple to be useful.
# The other frontends are mac/windows only.
# Anyway, it has a nice Qt GUI, I don't see why it needs a frontend.

# 20240812 bkw: update for v4.2.

# 20240311 bkw: update for v4.1.
# - submitted a build for rtmidi, so it's now supported here as an
#   optional dep.

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

PRGNAM=86box
SRCNAM=86Box
VERSION=${VERSION:-4.2}
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"
  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 $SRCNAM-$VERSION
tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
cd $SRCNAM-$VERSION
tar xvf $CWD/roms-$VERSION.tar.gz
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 {} +

# 20240311 bkw: rtmidi still not autodetected in 4.1.
if [ "${RTMIDI:-yes}" != "yes" ] || ! pkg-config --exists rtmidi; then
  RTMIDI="-DRTMIDI=OFF"
fi

mkdir -p build
cd build
  cmake \
    $RTMIDI \
    -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DLIB_SUFFIX=${LIBDIRSUFFIX} \
    -DMAN_INSTALL_DIR=/usr/man \
    -DCMAKE_BUILD_TYPE=Release ..
  make
  make install/strip DESTDIR=$PKG
cd ..

# Allow running "86box", lowercase B, to match the package name.
ln -s $SRCNAM $PKG/usr/bin/$PRGNAM

# This mv will be fast, src and dest are always on the same FS.
mkdir -p $PKG/usr/share/$SRCNAM
mv roms-$VERSION $PKG/usr/share/$SRCNAM/roms

# Upstream ships desktop/icons, but 'make install' doesn't install them.
mkdir -p $PKG/usr/share/applications
cp -a src/unix/assets/net.86box.86Box.desktop $PKG/usr/share/applications

mkdir -p $PKG/usr/share/metainfo
cp -a src/unix/assets/net.86box.86Box.metainfo.xml $PKG/usr/share/metainfo

for i in src/unix/assets/[0-9]*x*/; do
  dir=$PKG/usr/share/icons/hicolor/$( basename $i )/apps
  mkdir -p $dir
  cp -a $i/*.png $dir
done

mkdir -p $PKG/usr/share/pixmaps
ln -s ../icons/hicolor/48x48/apps/net.86box.86Box.png \
      $PKG/usr/share/pixmaps/$PRGNAM.png

# Make the slack-desc show whether optional rtmidi support is built in.
WITH=WITHOUT
objdump -p $PKG/usr/bin/$PRGNAM | grep -q 'NEEDED.*librtmidi' && WITH="WITH"

PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a AUTHORS COPYING *.md $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

mkdir -p $PKG/install
sed "s,@WITH@,$WITH," < $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