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

# Slackware build script for cproc

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

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

# Note: thought about including mcpp (either in this build
# or a separate one) so cproc wouldn't have to use gcc's
# preprocessor. There even used to be a development/mcpp
# SlackBuild... for Slackware 12.1 (in 2010).
# However, mcpp looks to be old and unmaintained upstream, and cproc
# doesn't seem to support using it (would require patching, not gonna
# do).

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

PRGNAM=cproc
VERSION=${VERSION:-20230502_0985a78}
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}

# No need for LIBDIRSUFFIX (nothing gets installed there), can't
# use regular SLKCFLAGS because they get passed to cproc itself, and
# it doesn't support -fPIC, -march=, etc. -O2 is allowed, but ignored.

set -e

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

# cproc needs to know the location of the ELF "interpreter" (the
# runtime linker). The defaults in the configure script are OK for
# x86_64 but wrong for aarch64. Rather than hardcode anything here,
# look and see what's in use.
ELFTERP="$( readelf -p .interp /bin/ls | sed -n '/\.so\./s,.* ,,p' )"

# Non-standard configure (not autoconf). We have to set host and
# target because otherwise it detects x86_64-slackware-linux, which
# cproc doesn't support. In theory they could be different, which
# would give us a cross compiler... but it would require the crt*.o
# and a binutils for the target platform. Not gonna spend time on
# that.
./configure \
  --host=$ARCH-linux-gnu \
  --target=$ARCH-linux-gnu \
  --with-ldso="$ELFTERP" \
  --prefix=/usr

make bootstrap

# Manual install. It's only 2 binaries and 1 man page.
# Use the binaries compiled by cproc, not gcc. stage2/ and stage3/ binaries
# are identical (or else 'make bootstrap' would have failed, above). These
# are already stripped.
mkdir -p $PKG/usr/bin $PKG/usr/man/man1
cp -a stage2/cproc{,-qbe} $PKG/usr/bin
gzip -9c < $PRGNAM.1 > $PKG/usr/man/man1/$PRGNAM.1.gz

PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC

# Self-test can be disabled, if some future version has issues.
[ "${CHECK:-yes}" = "yes" ] && make check &> $PKGDOC/check-results.txt

cp -a README* LICENSE* doc/* $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