development/cproc: Added (small C11 compiler).

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
B. Watson 2023-06-10 08:42:19 +07:00 committed by Willy Sudiarto Raharjo
parent 30a1be57d5
commit cfdd65e299
5 changed files with 207 additions and 0 deletions

14
development/cproc/README Normal file
View File

@ -0,0 +1,14 @@
cproc (small C11 compiler based on QBE)
cproc is a C11 compiler using QBE as a backend. It is released under
the ISC license. Some C23 features and GNU C extensions are also
implemented. There is still much to do, but it currently implements
most of the language and is capable of building software including
itself, mcpp, gcc 4.7, binutils, and more.
This doesn't support 32-bit x86. It supports x86_64 (tested) and
aarch64 (untested; if it doesn't work, send me a patch and I'll
include it).
The build runs cproc's self-test suite. The results will be saved to:
/usr/doc/cproc-$VERSION/check-results.txt

View File

@ -0,0 +1,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

View File

@ -0,0 +1,10 @@
PRGNAM="cproc"
VERSION="20230502_0985a78"
HOMEPAGE="https://sr.ht/~mcf/cproc/"
DOWNLOAD="UNSUPPORTED"
MD5SUM=""
DOWNLOAD_x86_64="https://slackware.uk/~urchlay/src/cproc-20230502_0985a78.tar.xz"
MD5SUM_x86_64="5e6733d2948349948dda78547508f81f"
REQUIRES="qbe"
MAINTAINER="B. Watson"
EMAIL="urchlay@slackware.uk"

View File

@ -0,0 +1,65 @@
#!/bin/sh
# Create source tarball from git repo, with generated version number.
# Takes one optional argument, which is the commit or tag to create a
# tarball of. With no arg, HEAD is used.
# Version number example: 20200227_ad7ec17
# Notes:
# Do not use this if you're packaging a release.
# This script doesn't need to be run as root. It does need to be able
# to write to the current directory it's run from.
# Running this script twice for the same commit will NOT give identical
# tarballs, even if the contents are identical. This is because tar
# includes the current time in a newly-created tarball (plus there may
# be other git-related reasons).
# Once you've generated a tarball, you'll still need a place to host it.
# Ask on the mailing list, if you don't have your own web server to
# play with.
## Config:
# final tarball and slackbuild PRGNAM:
PRGNAM=cproc
# what it says on the tin:
CLONE_URL=https://git.sr.ht/~mcf/cproc
## End of config.
set -e
GITDIR=$( mktemp -dt $PRGNAM.git.XXXXXX )
rm -rf $GITDIR
git clone $CLONE_URL $GITDIR
CWD="$( pwd )"
cd $GITDIR
if [ "$1" != "" ]; then
git reset --hard "$1" || exit 1
fi
GIT_SHA=$( git rev-parse --short HEAD )
DATE=$( git log --date=format:%Y%m%d --format=%cd | head -1 )
VERSION=${DATE}_${GIT_SHA}
rm -rf .git
find . -name .gitignore -print0 | xargs -0 rm -f
cd "$CWD"
rm -rf $PRGNAM-$VERSION $PRGNAM-$VERSION.tar.xz
mv $GITDIR $PRGNAM-$VERSION
tar cvfJ $PRGNAM-$VERSION.tar.xz $PRGNAM-$VERSION
echo
echo "Created tarball: $PRGNAM-$VERSION.tar.xz"
echo "VERSION=\"$VERSION\""
echo "MD5SUM=\"$( md5sum $PRGNAM-$VERSION.tar.xz | cut -d' ' -f1 )\""

View File

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
cproc: cproc (small C11 compiler based on QBE)
cproc:
cproc: cproc is a C11 compiler using QBE as a backend. It is released under
cproc: the ISC license. Some C23 features and GNU C extensions are also
cproc: implemented. There is still much to do, but it currently implements
cproc: most of the language and is capable of building software including
cproc: itself, mcpp, gcc 4.7, binutils, and more.
cproc:
cproc:
cproc:
cproc: