summaryrefslogtreecommitdiffstats
path: root/games/vbam/vbam.SlackBuild
blob: 910f8a78c4077e9340dadc5bd9842bef9d2bfa42 (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
#!/bin/bash

# Slackbuild for vbam

# Currently maintained by B. Watson <yalhcru@gmail.com>.
# Previously maintained by Dugan Chen <email removed>.
# Written by JK Wood <email removed>.

# Slackbuild is released under the Dog-on-Fire License:
# If use of this script causes your dog to catch on fire,
# you agree to send me five dollars.  Or a picture
# of the dog on fire.
# Otherwise, you're on your own.  I've tested the script
# on my own computer, and it hasn't broken anything.
# So if it does it on your computer, that falls in
# the realm of "Not my problem."
#
# Of course, if you'll send a bug report to the above
# email address, I may be able to see what you did
# wrong and prevent it from happening in the future.
# In which case, I may just send YOU five dollars.

# Modified by the SlackBuilds.org project.

# 20191129 bkw: updated for 2.1.4.
# 20180702 bkw: updated for 2.1.0.
# 20180612 bkw: updated for 2.0.2.
# 20171219 bkw: updated for 2.0.1.
# 20170302 bkw: use long-format github URL

# 20170126 bkw:
# - New maintainer, remove old maintainers' email addresses.
# - Update for 2.0.0beta3. This adds SDL2 and SFML as deps.
#   Actually I could make SFML optional, it's only used for emulating
#   the GBA link cable. If anyone *really* wants to do this, add
#   -DENABLE_LINK=OFF to the cmake command. Not going to add it as
#   an option unless someone requests it.
# - Install binary in /usr/games, not /usr/bin.
# - Use correct wx-config, even if /usr/bin/wx-config symlink points
#   to 2.8 instead of 3.0.
# - Get rid of Windows-only doc.
# - Binary & source name has changed to visualboyadvance-m, keep the
#   old vbam name as symlinks.
# - Correct README, plus cosmetic reformatting.

PRGNAM=vbam
VERSION=${VERSION:-2.1.4}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

SRCVER="$VERSION"
SRCNAM="visualboyadvance-m"

# Set to ON to enable FFMPEG A/V recording.
FFMPEG=${FFMPEG:-OFF}

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=""
  ASM=ON # x86 ASM optimizations are available.
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
  ASM=ON
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
  ASM=OFF
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
  ASM=OFF
fi

set -e

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

# if both wx(Python|GTK) 2 and 3 are installed, /usr/bin/wx-config
# is a symlink to the config for whichever was installed last. Avoid
# confusion, force the correct version.
WXCONF=${WXCONF:-/usr/lib$LIBDIRSUFFIX/wx/config/gtk2-unicode-3.0}

# upstream cleverly parses their own ChangeLog to get the version number
# that gets compiled into the binary. They un-cleverly failed to follow
# their own formatting rules for v2.0.2, meaning the 2.0.2 executable
# says 2.0.1 in its window title. So:
sed -i '/\[2\.0\.2\]/s,Bug fix release,-,' CHANGELOG.md

mkdir -p build
cd build
  cmake \
    -DwxWidgets_CONFIG_EXECUTABLE=$WXCONF \
    -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DENABLE_ASM_CORE=${ASM} \
    -DENABLE_ASM_SCALERS=${ASM} \
    -DENABLE_FFMPEG=${FFMPEG} \
    -DCMAKE_BUILD_TYPE=Release ..
  make
  sed -i \
      -e 's,/usr/share/man,/usr/man,g' \
      -e 's,/usr/bin,/usr/games,g' \
      cmake_install.cmake
  make install DESTDIR=$PKG
cd ..

strip $PKG/usr/games/$SRCNAM
ln -s $SRCNAM $PKG/usr/games/$PRGNAM

gzip $PKG/usr/man/man6/$SRCNAM.6
ln -s $SRCNAM.6.gz $PKG/usr/man/man6/$PRGNAM.6.gz

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
rm -f doc/ReadMe.MFC.txt # this is for Windows only
cp -a doc/* $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}