summaryrefslogtreecommitdiffstats
path: root/system/xtrs/xtrs.SlackBuild
blob: c0d9fb78d0f76d24ea5e90e091cb3e92e69031cc (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
#!/bin/bash

# Slackware build script for xtrs - the X Windows TRS-80 emulator

# Originally written by Niels Horn <email removed>.
# Highly modified and now maintained by B. Watson <urchlay@slackware.uk>.
# There was no license on the original version. Modified version is
# licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.

# 20230517 bkw: BUILD=4
# - include patch from Jens Guenther (sdltrs upstream maintainer) to
#   make the window close button work.

# 20230418 bkw: BUILD=3
# - new maintainer.
# - use ROMs from trs80-roms package by default.
# - binaries in /usr/games; man pages in section 6.
# - replace old 32x21 icon.
# - remove ROMs from package (they live in trs80-roms now).
# - include all the trs-80 native stuff in the doc dir, like
#   sdltrs does. basically it's the same stuff, too.
# - link with libaoss, to get audio working.

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

PRGNAM=xtrs
VERSION=${VERSION:-4.9d}
BUILD=${BUILD:-4}
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"
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
rm -rf $TMP/$PRGNAM-$VERSION
cd $TMP
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
# upstream permissions are wonky, do not revert to template.
find . -type f -a -exec chmod 644 {} + -o \
       -type d -a -exec chmod 755 {} +

# 20230418 bkw: patch does all this:
# - use system-wide ROMs from trs80-roms package.
# - install binaries to /usr/games and man pages to section 6.
# - strip binaries.
# - use correct app-defaults dir.
patch -p1 < $CWD/sbo.diff

# 20230517 bkw: Jens Guenther's "quick and dirty" patch to make the
# windowmanager's close button work. Many thanks!
patch -p1 < $CWD/window_close.diff

# 20230418 bkw: the -laoss here allows xtrs to make sound via ALSA
# or PulseAudio (via /etc/asound.conf).
make DEBUG="$SLKCFLAGS" EXTRALIBS="-laoss"
mkdir -p $PKG/usr/games $PKG/usr/man/man6
make BINDIR=$PKG/usr/games MANDIR=$PKG/usr/man install

gzip -9 $PKG/usr/man/man*/*

# 20230418 bkw: made this icon by combining the sdltrs icon
# and the X logo (tinted red). not beautiful, but distinctive.
for i in $CWD/icons/*.png; do
  px="$( basename $i .png )"
  size="${px}x${px}"
  dir=$PKG/usr/share/icons/hicolor/$size/apps
  mkdir -p $dir
  cat $i > $dir/$PRGNAM.png
done

mkdir -p $PKG/usr/share/pixmaps
ln -s ../icons/hicolor/48x48/apps/$PRGNAM.png $PKG/usr/share/pixmaps/$PRGNAM.png

mkdir -p $PKG/usr/share/applications
cat $CWD/xtrs.desktop > $PKG/usr/share/applications/xtrs.desktop

# 20230418 bkw: the .txt files are just rendered versions of the man
# pages (with ddoouubblleedd characters), do not package.
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC/utilities
cp -a ChangeLog README *.html $PKGDOC
cp -a *.ccc *.cmd *.tgz *.jcl *.bas *.z80 *.lst xtrsemt.h *.hex *.README \
      $PKGDOC/utilities
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$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