aboutsummaryrefslogtreecommitdiff
path: root/accessibility/espeak/espeak.SlackBuild
blob: 1a6402a5d3e843cc400db1dcda4ce430e5f0e21c (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
#!/bin/sh

# Slackware build script for espeak

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

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

# 20191218 bkw:
# - BUILD=2
# - Update man page (still using the one from Debian).
# - It turns out espeak supports PulseAudio, so that's now the default.
# - Remove portaudio from REQUIRES.
# - Add PULSE and PORTAUDIO environment variables, update README.
# - Simplify the script (unfortunately it had to get more complex
#   again to support the new variables).

PRGNAM=espeak
VERSION=${VERSION:-1.48.04}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

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=""
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

# Support old WAVONLY variable, but don't mention it in README.
if [ "${WAVONLY:-no}" = "yes" ]; then
  PULSE=no
  PORTAUDIO=no
fi

# Preemptively support -current's pure-alsa-system: if pulseaudio's
# not installed (it normally is on 14.2), just build without it.
PULSE="${PULSE:-yes}"
pkg-config --exists libpulse || PULSE=no

case "${PORTAUDIO:-auto}" in
  yes) if ! pkg-config --exists portaudio-2.0; then
         cat <<EOF
You've requested portaudio support via PORTAUDIO=yes, but portaudio
is not installed. Sorry.
EOF
         exit 1
       fi ;;
  no)  ;;
  *)   pkg-config --exists portaudio-2.0 && PORTAUDIO=yes || PORTAUDIO=no ;;
esac

if [ "$PORTAUDIO" = "yes" ] && [ "$PULSE" = "yes" ]; then
  AUDIO=runtime
  DRIVERS="portaudio and pulseaudio"
elif [ "$PORTAUDIO" = "yes" ]; then
  AUDIO=portaudio
  DRIVERS="$AUDIO"
elif [ "$PULSE" = "yes" ]; then
  AUDIO=pulseaudio
  DRIVERS="$AUDIO"
else
  AUDIO=none
  DRIVERS="none (.wav file output only)"
fi

echo "=== PULSE=$PULSE PORTAUDIO=$PORTAUDIO AUDIO=$AUDIO"

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION-source
unzip $CWD/$PRGNAM-$VERSION-source.zip -x '*/linux_32bit/*' '*/platforms/*'
cd $PRGNAM-$VERSION-source
chown -R root:root .
# Permissions are bletcherous, reset them all.
find -L . \( -type d -a -exec chmod 755 {} + \) -o \
          \( -type f -a -exec chmod 644 {} + \)

# Note: there are two executables (speak and espeak). They seem to do the same
# thing, except "speak" doesn't use libespeak.so at runtime. This package only
# installs "espeak" (which is how other distros do it, too).
# The LDFLAGS="-Wl,-s" makes gcc strip the binaries for us.

cd src
  rm -f portaudio.h # use system-wide header!
  LIBDIR=/usr/lib$LIBDIRSUFFIX
  SLKCFLAGS="$SLKCFLAGS -Wno-narrowing"
  make LDFLAGS="-Wl,-s" LIBDIR=$LIBDIR CXXFLAGS="$SLKCFLAGS" AUDIO="$AUDIO"
  make install LIBDIR=$LIBDIR DESTDIR=$PKG
  rm -f $PKG/$LIBDIR/*.a # guidelines say no static libs
cd ..

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -r ReadMe *.txt docs/* $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

# Man page from Debian
mkdir -p $PKG/usr/man/man1
gzip -9c $CWD/$PRGNAM.1 > $PKG/usr/man/man1/$PRGNAM.1.gz

mkdir -p $PKG/install
sed "s,@DRIVERS@,$DRIVERS," \
  $CWD/slack-desc \
  > $PKG/install/slack-desc

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