summaryrefslogtreecommitdiffstats
path: root/development/minimal-basic/minimal-basic.SlackBuild
blob: b72ea11cd6fcff0d9412da0b02995318e91e271d (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
#!/bin/bash

# Slackware build script for minimal-basic

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

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

# Notes:

# Abandon all hope, ye who attempt to build this on non-x86_64
# platforms. The ecma55 binary gets linked with a bunch of x86_64
# object files in a directory named AMD64 (which ought to be a clue),
# which are built from x86_64 assembly source (not C). Nothing you do
# (hacking up the Makefile, etc) will let you link x86_64 objects with
# non-x86_64 ones. Seriously. Do not email me asking for help with it.

# Building on multilib should be possible, but I haven't tested it.
# If you do, you can only build an x86_64 binary. See above.

# There's a Makefile.clang, but it won't work on Slackware 15.0's
# clang 13.x because it's too *new*. That's a rare situation in
# Slackware...

# There's also a Makefile.tcc, which actually does work with the
# tcc in our repo (20220221_308d8d1), but I see no advantage to
# building with tcc. And no, using tcc won't get around the "only
# builds on x86_64" rule, either.

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

PRGNAM=minimal-basic
SRCNAM=MinimalBASIC
VERSION=${VERSION:-2.40}
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" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
else
  cat <<EOF

**************************************************
* Unsupported ARCH: $ARCH
* MinimalBASIC only builds on x86_64, by design.
**************************************************

EOF
  exit 1
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-$VERSION
tar xvf $CWD/$SRCNAM-$VERSION.tar.xz
cd $SRCNAM-$VERSION
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 {} \+

runmake() {
  make -f Makefile.gcc \
    OPT="$SLKCFLAGS" \
    PIE=1 \
    LTO=1 \
    DESTDIR=$PKG \
    BINDIR=/usr/bin \
    MANDIR=/usr/man/man1 \
    "$@"
}

runmake
strip ecma55
runmake install

# Sample code, including my own ports of Hamurabi and Bagels. They
# came from http://vintage-basic.net/games.html (and before that, from
# the book "101 BASIC Computer Games" by David Ahl, and before Ahl
# collected them in his book, other people wrote them, but the mists
# of time have obscured the details).

# I modified them slightly to make them ECMA-55 compatible. They also
# work in bas55, and may show up in a future release of it.

# PI.BAS is my own BASIC port of pi.py from https://github.com/MrBlaise/learnpython/

EXTRA=$PKG/usr/share/$PRGNAM/examples
mkdir -p $EXTRA
cp -a CSCLASSICS $PKG/usr/share/$PRGNAM
install -m0644 -o root -g root $CWD/examples/*.BAS $EXTRA

# *Lots* of documentation.
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a COPYING ChangeLog CC0-1.0-Universal NEWS \
      README TESTING THANKS TODO GNU_FDL \
      *.pdf *.txt *.TXT *.dot BOOK/*.pdf \
      $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