aboutsummaryrefslogtreecommitdiff
path: root/games/glulxe/glulxe.SlackBuild
blob: b698ebef2b2f62e2648652995e2a13fadfb8ba76 (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 glulxe

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

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

# Man page comes from debian. glulxe.6.md originally came from:
# http://deb.debian.org/debian/pool/main/g/glulxe/glulxe_0.5.4-1.1.debian.tar.xz
# ...and I added the new options in v0.6.1.
# convert to a man page via:
# pandoc --standalone --to man glulxe-glktermw.6.md -o glulxe-glktermw.6

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

PRGNAM=glulxe
VERSION=${VERSION:-0.6.1}
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

# 0.6.1 => 061
TARVER=${VERSION//./}

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

# Include glulxdump in package. Have to apply our flags.
sed -i "/-o glulxdump/s,-o,$SLKCFLAGS -o," Makefile

# glulxe requires a glk library, but there are at least 3 to choose
# from. The most-commonly used one (by people who just play games) is
# going to be glktermw, so I made it a required dep. cheapglk and
# remglk are more niche-market, so they're optional.

# glktermw first.
# Unfortunately we can't define VM_DEBUGGER with glktermw, it lacks
# support for it.
OPTS="-DOS_UNIX -DUNIX_RAND_GETRANDOM -DVM_PROFILING"
make all glulxdump \
     OPTIONS="-Wall $SLKCFLAGS $OPTS" \
     GLKINCLUDEDIR=/usr/include/glktermw \
     GLKLIBDIR=/usr/lib$LIBDIRSUFFIX \
     GLKMAKEFILE=Make.glktermw

# no 'make install' target.
mkdir -p $PKG/usr/games
install -s glulxdump $PKG/usr/games/
install -s $PRGNAM $PKG/usr/games/$PRGNAM-glktermw
ln -s $PRGNAM-glktermw $PKG/usr/games/$PRGNAM
install profile-analyze.py $PKG/usr/games/$PRGNAM-profile-analyze

# only have a man page for glulxe-glktermw
MAN6=$PKG/usr/man/man6
mkdir -p $MAN6
gzip -9c < $CWD/glulxe-glktermw.6 > $MAN6/glulxe-glktermw.6.gz
ln -s glulxe-glktermw.6.gz $MAN6/$PRGNAM.6.gz

# cheapglk, if available.
INCCG="does NOT include"
if [ "${CHEAPGLK:-yes}" = "yes" -a -e /usr/include/cheapglk/glk.h ]; then
  INCCG="INCLUDES"
  rm -f *.o $PRGNAM glulxdump profile-raw
  # We *can* define VM_DEBUGGER with cheapglk, so do it.
  make OPTIONS="-Wall $SLKCFLAGS $OPTS -DVM_DEBUGGER" \
       GLKINCLUDEDIR=/usr/include/cheapglk \
       GLKLIBDIR=/usr/lib$LIBDIRSUFFIX \
       GLKMAKEFILE=Make.cheapglk \
       XMLLIBINCLUDEDIR=-I/usr/include/libxml2 \
       XMLLIB=-lxml2
  install -s $PRGNAM $PKG/usr/games/$PRGNAM-cheapglk
fi

# remglk, if available.
INCREM="does NOT include"
if [ "${REMGLK:-yes}" = "yes" -a -e /usr/include/remglk/glk.h ]; then
  INCREM="INCLUDES"
  rm -f *.o $PRGNAM glulxdump profile-raw
  # We *can* define VM_DEBUGGER with remglk, so do it.
  make OPTIONS="-Wall $SLKCFLAGS $OPTS -DVM_DEBUGGER" \
       GLKINCLUDEDIR=/usr/include/remglk \
       GLKLIBDIR=/usr/lib$LIBDIRSUFFIX \
       GLKMAKEFILE=Make.remglk \
       XMLLIBINCLUDEDIR=-I/usr/include/libxml2 \
       XMLLIB=-lxml2
  install -s $PRGNAM $PKG/usr/games/$PRGNAM-remglk
fi

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

mkdir -p $PKG/install
sed -e "s,@INCREM@,$INCREM," \
    -e "s,@INCCG@,$INCCG," \
    < $CWD/slack-desc \
    > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE