summaryrefslogtreecommitdiff
path: root/games/eduke32/eduke32.SlackBuild
blob: 9bae23a3e927800c51f018e79e3d636466219608 (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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/bash

# Slackware build script for eduke32

# Written by B. Watson (yalhcru@gmail.com)

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

# Note to self: in 20211102_9751_8970754aa, ekenbuild won't compile.

# TODO: man page(s). eduke32.6 is ancient.

# 20211108 bkw:
# - update for 20211102_9751_8970754aa.
# - include voidsw (shadow warrior), wangulator (sw map editor), and
#   fury (ion fury) executables.
# - fix the tools compilation (again).
# - get rid of wrapper script, upstream now supports looking for
#   data in /usr/share/games/eduke32, and creates its own ~/.config/eduke32
#   to save settings/etc in.
# - stop the game from creating a log file in the current dir.
# - rewrite README_game_data.txt, it's now complete for all the games
#   except Ion Fury.
# - fix the @!%!#$% mouse sensitivity in voidsw.
# - get rid of SDL1 build.

# 20170128 bkw:
# - update for 20170123_6052
# - add new utilities
# - compilefix.diff no longer needed

# 20160808 bkw:
# - update for 20160704_5811
# - install samples/ to the doc dir, not the game data dir
# - rework wrapper script to let mods like bloodcm be installed
#   system-wide in /usr/share/games/eduke32
# - add compilefix.diff to get the tools to build
# - support SDL2 build, add SDL2=no to force SDL1
# - use OPTIMIZATIONS instead of ARCH for $SLKCFLAGS, upstream
#   changed the build a bit
# - undocumented VPX flag now defaults to "yes", since libvpx is a
#   core Slackware 14.2 package
# - slack-desc shows SDL version and whether or not libvpx was used.

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

PRGNAM=eduke32
VERSION=${VERSION:-20211102_9751_8970754aa}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}

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 [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

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

SRCVER="$( echo $VERSION | tr _ - )"

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf ${PRGNAM}_${SRCVER}
tar xvf $CWD/${PRGNAM}_src_${SRCVER}.tar.xz --exclude=platform
cd ${PRGNAM}_${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 {} \+

# Notes to self:
# - adding LDFLAGS="-fuse-ld=gold" doesn't seem to affect the link times.
# - SLKCFLAGS get applied, but also a bunch of other optimizations.
runmake() {
  echo "===> runmake args: '$@'"
  make RELEASE=1 \
       PRETTY_OUTPUT=0 \
       CFLAGS="$SLKCFLAGS" \
       CXXFLAGS="$SLKCFLAGS" \
       "$@"
}

installbins() {
  echo "===> installbins args: '$@'"
  install -s -m0755 $@ $PKG/usr/games/
}

# 20211108 bkw: recent eduke32 no longer needs a wrapper script,
# except that it wants to write a logfile to the current dir where
# it was run. Since the log is just a copy of the game's stdout,
# we don't actually need it, so:
sed -i '/OSD_SetLogFile/d' \
  source/duke3d/src/game.cpp \
  source/duke3d/src/astub.cpp \
  source/kenbuild/src/game.cpp \
  source/kenbuild/src/bstub.cpp \
  source/sw/src/game.cpp \
  source/sw/src/jnstub.cpp

# On some systems, the game spits out tons of warnings:
# Error: glGetTexLevelParameteriv returned GL_FALSE!
# These don't seem to actually hurt anything (the game looks
# and plays fine), so let's get rid of them to clean up
# the log output.
sed -i '/"Error: glGetTexLevelParameteriv/d' source/build/src/texcache.cpp

# voidsw's in-game menus don't let you crank the mouse sensitivity up high
# enough. the mouse barely does anything at the default setting, and it's
# still too slow-moving to be usable at the max.
sed -i 's,8192,660,g' source/sw/src/config.cpp source/sw/src/menus.cpp
sed -i '/MouseAnalogScale/s,65536,131071,' source/sw/src/config.cpp

# Our twin dragon is a different repack from the ones voidsw knows
# about. Also, upstream incorrectly says the Wanton Destruction
# wd.grp requires sw.grp as a dependency. Actually, it's a
# complete/standalone game, add-on or not, so this patch fixes that.
patch -p1 < $CWD/twin_dragon.diff

# Make eduke32 load autoload content from the system dir. voidsw
# already does this.
patch -p1 < $CWD/system_autoload.diff

# eduke32 and mapster:
runmake

# voidsw and wangulator:
runmake sw

mkdir -p $PKG/usr/games
installbins $PRGNAM mapster32 voidsw wangulator

# the tools:
# patch does 2 things: fix linking (add mimalloc as a dep) and
# get rid of the generateicon tool (which still fails to build).
patch -p1 < $CWD/tools.diff
runmake tools
installbins arttool bsuite cacheinfo givedepth ivfrate kextract kgroup \
            kmd2tool makesdlkeytrans map2stl md2tool mkpalette transpal \
            unpackssi wad2art wad2map

# fury (which would fail without the 'make clean' first):
make clean
runmake fury FURY=1
installbins fury

mkdir -p $PKG/usr/man/man6
gzip -9c $CWD/$PRGNAM.6 > $PKG/usr/man/man6/$PRGNAM.6.gz

# Mapster help files
mkdir -p $PKG/usr/share/games/$PRGNAM
cd package/sdk
cp *.hlp *.HLP names.h tiles.cfg $PKG/usr/share/games/$PRGNAM
cd -

mkdir -p $PKG/usr/share/applications
for i in $CWD/desktop/*.desktop; do
  cat $i > $PKG/usr/share/applications/$( basename $i )
done

mkdir -p $PKG/usr/share/pixmaps
for subdir in $CWD/icons/*; do
  name=$( basename $subdir )
  for i in $subdir/*.png; do
    px=$( basename $i | cut -d. -f1 )
    size=${px}x${px}
    dir=$PKG/usr/share/icons/hicolor/$size/apps
    mkdir -p $dir
    cat $i > $dir/$name.png
  done
  ln -s ../icons/hicolor/48x48/apps/$name.png $PKG/usr/share/pixmaps/$name.png
done

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp source/build/doc/* $PKG/usr/doc/$PRGNAM-$VERSION
cp source/build/buildlic.txt source/duke3d/gpl-2.0.txt $CWD/README_game_data.txt \
  $PKG/usr/doc/$PRGNAM-$VERSION
cp -r package/sdk/samples $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

( cd $PKG/usr/share/games/$PRGNAM
  ln -s ../../../doc/$PRGNAM-$VERSION/README_game_data.txt . )

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