summaryrefslogtreecommitdiffstats
path: root/development/focal/focal.SlackBuild
blob: 4a9fc6be114fe35996a4859ae691dc1f49cf2496 (about) (plain) (blame)
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
#!/bin/bash

# Slackware build script for focal

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

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

# VERSION is the date on the files inside the tarball.

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

PRGNAM=focal
VERSION=${VERSION:-19950417}
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"
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
tar xvf $CWD/$PRGNAM.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 {} \+

# Use our flags.
sed -i "/^CFLAGS/s,-O -g,$SLKCFLAGS," Makefile

# Fix compile issues on modern gcc. Yes, it uses the hated and
# deprecated gets(). There are still some compiler warnings (implicit
# int for e.g. "register c;") but they don't seem to do harm.
sed -i '1iextern char *gets(char *s);' focal.h
sed -i '67s,|,||,' focal3.c   # wrong: if (ln<1 | ln>99)
sed -i 's,\<getline\>,Getline,g' *.c *.h

make

# Test the thing now that it's built.
cat <<EOF | ./focal > test.out
lib call queens.foc
g
quit
EOF
if grep -q 'Total 92 answers' test.out; then
  echo "=== Self-test passed."
else
  echo "=== Self-test FAILED, bailing."
  exit 1
fi

# beer.foc comes from https://www.99-bottles-of-beer.net/language-focal-2514.html
# hello.foc comes from https://github.com/leachim6/hello-world but it had to
# be modified (this FOCAL hates the line number with 4 parts).
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKG/usr/bin $PKGDOC $PKG/usr/share/$PRGNAM
install -s -m0755 $PRGNAM $PKG/usr/bin/$PRGNAM
install -oroot -groot -m0644 *.foc $CWD/*.foc $PKG/usr/share/$PRGNAM

# Rename, in case KDE or XFCE thinks it should open this with Calligra
# or MS-Word in Wine, based on the filename extension.
mv focal.doc focal_doc.txt

cp -a README focal_doc.txt $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

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