summaryrefslogtreecommitdiffstats
path: root/games/frotz/frotz.SlackBuild
blob: 082687e67937634430ce719580a9a261018ca098 (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
#!/bin/bash
#
# Slackware build script for frotz

# Originally written for Slackware 12.2 by Beej Jorgensen <email
# removed>, heavily modified by B. Watson <urchlay@slackware.uk> since
# then.

# Original had no license. This modified version is released under the
# WTFPL. See http://www.wtfpl.net/txt/copying/ for details.

# 20211007 bkw:
# - updated for v2.53.
# - add optional xfrotz.
# - expand README.
# - make slack-desc reflect build options (libmodplug and xfrotz).

# 20210215 bkw: fix building without libmodplug. BUILD=2.

# 20201212 bkw: too many changes, can't build older versions.
# - updated for v2.52.
# - new homepage.
# - include sfrotz if sdl2 and SDL2_mixer are installed.
# - fix man page typos.
# - patch to prevent sfrotz crashes with long pathnames.
# - add desktop stuff.

# 20150904 bkw: updated for frotz 2.44.

# 20121216 bkw:
# - updated for Slackware 14 and frotz 2.43d.
# - include dumb terminal frotz in build.

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

PRGNAM=frotz
VERSION=${VERSION:-2.53}
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}

# no need for LIBDIRSUFFIX, frotz doesn't use /usr/lib
if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
else
  SLKCFLAGS="-O2"
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.?z*
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 typos:
sed -i "s/\\(Unlike it\\)'s/\1s/" doc/dfrotz.6
sed -i 's,forground,foreground,'  doc/frotz.6
sed -i -e 's,invocatio$,&n.,' \
       -e 's,intead,instead,' \
       -e 's,chunck,chunk,' \
          doc/sfrotz.6

# Document location of config file:
sed -i 's,frotz\.conf,/etc/&,' doc/$PRGNAM.6

run_make() {
  make \
    PREFIX=/usr \
    SYSCONFDIR=/etc \
    MANDIR=/usr/man \
    MAN_PREFIX=/usr \
    BINDIR=/usr/games \
    MKFONTDIR=/bin/true \
    X11_FONTDIR=$PKG/usr/share/fonts/misc \
    DESTDIR=$PKG \
    $1
}

# No autodetection for libmodplug or SDL2_mixer, help it out.
maintarg="nosound"; MP=no
if pkg-config --exists libmodplug; then
  maintarg="$PRGNAM"
  MP=yes
fi
# on post-14.2 -current and 15.0, sdl2 is part of a full install:
pkg-config --exists sdl2 SDL2_mixer && extra="clean sdl install_sdl"

sed -i "s,-O3.*,$SLKCFLAGS," Makefile
for target in $maintarg install clean dumb install_dumb $extra; do
  run_make $target
done

# I have no idea why anyone would want this, but in case they do:
XF=no
if [ "${XFROTZ:-no}" = "yes" ]; then
  XF=yes
  run_make clean
  run_make x11
  run_make install_x11
  mv $PKG/usr/bin/xfrotz $PKG/usr/games
  rmdir $PKG/usr/bin
fi

strip $PKG/usr/games/*
gzip -9 $PKG/usr/man/man?/*.*

# desktop files by SlackBuild author. The icons came from WinFrotz. They're
# only available in 32x32 size, sorry.
mkdir -p $PKG/usr/share/applications \
         $PKG/usr/share/pixmaps \
         $PKG/usr/share/icons/hicolor/32x32/apps

for i in $PKG/usr/games/*; do
  bin="$( basename $i )"
  if [ -e $CWD/$bin.desktop ]; then
    install -m0644 -oroot -groot $CWD/$bin.desktop $PKG/usr/share/applications
  fi
done

cat $CWD/$PRGNAM.png > $PKG/usr/share/pixmaps/$PRGNAM.png
ln -s ../../../../pixmaps/$PRGNAM.png \
      $PKG/usr/share/icons/hicolor/32x32/apps/$PRGNAM.png
mkdir -p $PKG/usr/share/icons/hicolor/32x32/mimetypes
cat $CWD/frotz-infocom.png > \
    $PKG/usr/share/icons/hicolor/32x32/mimetypes/frotz-infocom.png

# MIME stuff for desktops. Causes KDE and XFCE to display story
# files with an Infocom icon, and they double-click open with either
# terminal or SDL frotz.
mkdir -p $PKG/usr/share/mime/packages
cat $CWD/$PRGNAM.xml > $PKG/usr/share/mime/packages/$PRGNAM.xml

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
rm -f README.1st # don't need this in the package.
cp -a AUTHORS CO* ChangeLog DUMB HOW_TO_PLAY README* TODO *.lsm \
      doc/$PRGNAM.conf* doc/$PRGNAM.txt \
      $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
sed -e "s,@MP@,$MP," \
    -e "s,@XF@,$XF," \
  $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