2011-06-18 02:44:31 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Slackware build script for pcc (Portable C Compiler)
|
2014-10-31 20:51:07 +01:00
|
|
|
|
|
|
|
# Originally written by Armin Besirovic <armin[at]linux[dot]org[dot]ba>
|
|
|
|
|
|
|
|
# Modified by B. Watson <yalhcru@gmail.com>
|
|
|
|
|
|
|
|
# 20141031 bkw:
|
|
|
|
# - took over maintentance.
|
|
|
|
# - upgraded for 1.1.0 beta series.
|
|
|
|
# - combined pcc and pcc-libs into one build, since either one is
|
|
|
|
# useless without the other.
|
|
|
|
# - removed pcc-lib's 002-build-libpcc-with-pcc.patch as it's been
|
|
|
|
# applied upstream in the 1.1.0 branch.
|
|
|
|
# - use private /usr/libexec/pcc/ dir instead of installing stuff
|
|
|
|
# directly in /usr/libexec. Probably just paranoia.
|
|
|
|
# - rename cpp-pcc man page to pcpp, since the beta installs a
|
|
|
|
# /usr/bin/pcpp.
|
|
|
|
# - get rid of -j1 in make command, seems to no longer be needed.
|
|
|
|
# - add logic to choose which compiler to use if CC not set.
|
|
|
|
# - extract license from source, install to /usr/doc
|
|
|
|
|
2015-01-29 01:14:44 +01:00
|
|
|
# 20150126 bkw:
|
|
|
|
# - upgraded for pcc-1.1.0 release, no more beta
|
|
|
|
# - add seddery to fix typo in cc.c (ifdef => ifndef)
|
2011-06-18 02:44:31 +02:00
|
|
|
|
|
|
|
PRGNAM=pcc
|
2015-01-29 01:14:44 +01:00
|
|
|
VERSION=${VERSION:-1.1.0}
|
2014-10-31 20:51:07 +01:00
|
|
|
BUILD=${BUILD:-1}
|
2011-06-18 02:44:31 +02:00
|
|
|
TAG=${TAG:-_SBo}
|
|
|
|
|
|
|
|
if [ -z "$ARCH" ]; then
|
|
|
|
case "$( uname -m )" in
|
|
|
|
i?86) ARCH=i486 ;;
|
|
|
|
arm*) ARCH=arm ;;
|
|
|
|
*) ARCH=$( uname -m ) ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
CWD=$(pwd)
|
|
|
|
TMP=${TMP:-/tmp/SBo}
|
|
|
|
PKG=$TMP/package-$PRGNAM
|
|
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
|
2014-10-31 20:51:07 +01:00
|
|
|
# non-standard stanza here: we're not going to use -march= or -mtune=
|
|
|
|
# on 32-bit Slackware, because doing so prevents pcc from being used
|
|
|
|
# to compile itself. I could add logic to use those flags only if
|
|
|
|
# CC is gcc, but the extra complexity isn't worth the dubious benefit.
|
|
|
|
SLKCFLAGS="-O2 -fPIC"
|
|
|
|
if [ "$ARCH" = "x86_64" ]; then
|
2011-06-18 02:44:31 +02:00
|
|
|
LIBDIRSUFFIX="64"
|
|
|
|
else
|
|
|
|
LIBDIRSUFFIX=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2014-10-31 20:51:07 +01:00
|
|
|
# which compiler shall we use?
|
|
|
|
if [ "$CC" = "" ]; then
|
|
|
|
# user didn't specify, autodetect.
|
|
|
|
if pcc --version &>/dev/null; then
|
|
|
|
CC=pcc
|
|
|
|
elif gcc --version &>/dev/null; then
|
|
|
|
CC=gcc
|
|
|
|
elif clang --version &>/dev/null; then
|
|
|
|
CC=clang
|
|
|
|
else
|
|
|
|
echo "Can't find any of pcc, gcc, or clang in \$PATH. Giving up." 1>&2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
export CC
|
|
|
|
WITHCC="$( basename $CC )"
|
|
|
|
[ "$CC" = "pcc" ] && WITHCC="pcc itself"
|
|
|
|
|
|
|
|
# enable TLS? upstream disables it by default.
|
|
|
|
TLSOPT="--disable-tls"
|
|
|
|
if [ "${TLS:-no}" = "yes" ]; then
|
|
|
|
TLSOPT="--enable-tls"
|
|
|
|
fi
|
|
|
|
|
2015-01-29 01:14:44 +01:00
|
|
|
rm -rf $PKG $TMP/$PRGNAM
|
2014-10-31 20:51:07 +01:00
|
|
|
mkdir -p $TMP/$PRGNAM $PKG $OUTPUT
|
|
|
|
cd $TMP/$PRGNAM
|
2015-01-29 01:14:44 +01:00
|
|
|
tar xvf $CWD/$PRGNAM-$VERSION.tgz
|
|
|
|
tar xvf $CWD/$PRGNAM-libs-$VERSION.tgz
|
2011-06-18 02:44:31 +02:00
|
|
|
chown -R root:root .
|
2013-11-16 01:36:55 +01:00
|
|
|
find -L . \
|
|
|
|
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
|
|
|
|
-o -perm 511 \) -exec chmod 755 {} \; -o \
|
|
|
|
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
|
2014-10-31 20:51:07 +01:00
|
|
|
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
|
2011-06-18 02:44:31 +02:00
|
|
|
|
2014-10-31 20:51:07 +01:00
|
|
|
# first, the compiler itself:
|
2015-01-29 01:14:44 +01:00
|
|
|
cd $PRGNAM-$VERSION
|
|
|
|
|
|
|
|
# fix typo, ref http://marc.info/?l=pcc-list&m=141824411830017&w=2
|
|
|
|
sed -i '0,/^#ifdef MULTI/!s,^#ifdef \(MULTI\),#ifndef \1,' cc/cc/cc.c
|
|
|
|
|
2011-06-18 02:44:31 +02:00
|
|
|
CFLAGS="$SLKCFLAGS" \
|
|
|
|
CXXFLAGS="$SLKCFLAGS" \
|
|
|
|
./configure \
|
2014-10-31 20:51:07 +01:00
|
|
|
$TLSOPT \
|
2011-06-18 02:44:31 +02:00
|
|
|
--prefix=/usr \
|
|
|
|
--mandir=/usr/man \
|
|
|
|
--libdir=/usr/lib${LIBDIRSUFFIX} \
|
2014-10-31 20:51:07 +01:00
|
|
|
--libexecdir=/usr/libexec/$PRGNAM \
|
2011-06-18 02:44:31 +02:00
|
|
|
--build=$ARCH-slackware-linux
|
|
|
|
|
2014-10-31 20:51:07 +01:00
|
|
|
# no install-strip, but binaries are already stripped by default.
|
|
|
|
make
|
2011-06-18 02:44:31 +02:00
|
|
|
make install DESTDIR=$PKG
|
|
|
|
|
|
|
|
gzip -9 $PKG/usr/man/man?/*.?
|
2012-09-29 22:16:07 +02:00
|
|
|
# Don't overwrite Slackware's man page.
|
2014-10-31 20:51:07 +01:00
|
|
|
mv $PKG/usr/man/man1/cpp.1.gz $PKG/usr/man/man1/pcpp.1.gz
|
2011-06-18 02:44:31 +02:00
|
|
|
|
2014-10-31 20:51:07 +01:00
|
|
|
# why are there no docs in the @##!$^ tarball?!
|
2011-06-18 02:44:31 +02:00
|
|
|
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
|
|
|
|
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
|
|
|
|
|
2014-10-31 20:51:07 +01:00
|
|
|
# license is BSD-style, in comments in the code.
|
|
|
|
sed -n '/Copyright/,/^ *$/s,^...,,p' cc/cc/cc.c \
|
|
|
|
> $PKG/usr/doc/$PRGNAM-$VERSION/LICENSE
|
|
|
|
|
|
|
|
# now, build the libs. we don't attempt to build them with the just-built
|
|
|
|
# pcc (maybe possible, but not worth the effort).
|
2015-01-29 01:14:44 +01:00
|
|
|
cd $TMP/$PRGNAM/$PRGNAM-libs-$VERSION
|
2014-10-31 20:51:07 +01:00
|
|
|
|
|
|
|
CFLAGS="$SLKCFLAGS" \
|
|
|
|
CXXFLAGS="$SLKCFLAGS" \
|
|
|
|
./configure \
|
|
|
|
--prefix=/usr \
|
|
|
|
--libdir=/usr/lib${LIBDIRSUFFIX} \
|
|
|
|
--build=$ARCH-slackware-linux
|
|
|
|
|
|
|
|
# pcc-libs installs nothing we can strip.
|
|
|
|
make
|
|
|
|
make install DESTDIR=$PKG
|
|
|
|
|
|
|
|
# there is a bit of documentation included with pcc-libs, but nothing
|
|
|
|
# really relevant unless you're hacking on pcc itself, not gonna bother.
|
|
|
|
|
2011-06-18 02:44:31 +02:00
|
|
|
mkdir -p $PKG/install
|
2014-10-31 20:51:07 +01:00
|
|
|
sed -e "s,@WITHCC@,$WITHCC," \
|
|
|
|
-e "s,@TLSOPT@,$TLSOPT," \
|
|
|
|
$CWD/slack-desc > $PKG/install/slack-desc
|
2011-06-18 02:44:31 +02:00
|
|
|
|
|
|
|
cd $PKG
|
|
|
|
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
|