189 lines
5.4 KiB
Bash
Executable File
189 lines
5.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# GCC package build script (written by volkerdi@slackware.com)
|
|
#
|
|
# Copyright 2003, 2004 Slackware Linux, Inc., Concord, California, USA
|
|
# Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2021 Patrick J. Volkerding, Sebeka, MN, USA
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use of this script, with or without modification, is
|
|
# permitted provided that the following conditions are met:
|
|
#
|
|
# 1. Redistributions of this script must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
#
|
|
|
|
# Modified 2011 by Eric Hameleers <alien at slackware.com> for OpenJDK.
|
|
# Modified 2022 by Eugen Wissner <belka@caraus.de> for gcc-latest.
|
|
|
|
cd $(dirname $0) ; CWD=$(pwd)
|
|
|
|
PRGNAM=gcc-latest
|
|
VERSION=${VERSION:-12.2.0}
|
|
BUILD=${BUILD:-1}
|
|
TAG=${TAG:-_SBo}
|
|
PKGTYPE=${PKGTYPE:-tgz}
|
|
|
|
# Automatically determine the architecture we're building on:
|
|
if [ -z "$ARCH" ]; then
|
|
case "$(uname -m)" in
|
|
i?86) ARCH=i586 ;;
|
|
arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;;
|
|
# Unless $ARCH is already set, use uname -m for all other archs:
|
|
*) ARCH=$(uname -m) ;;
|
|
esac
|
|
export ARCH
|
|
fi
|
|
|
|
# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
|
|
# the name of the created package would be, and then exit. This information
|
|
# could be useful to other scripts.
|
|
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" = "i386" ]; then
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=i386
|
|
elif [ "$ARCH" = "i486" ]; then
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=i386
|
|
elif [ "$ARCH" = "i586" ]; then
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=i386
|
|
elif [ "$ARCH" = "i686" ]; then
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=i386
|
|
elif [ "$ARCH" = "s390" ]; then
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=s390
|
|
elif [ "$ARCH" = "x86_64" ]; then
|
|
LIBDIRSUFFIX="64"
|
|
LIB_ARCH=amd64
|
|
elif [ "$ARCH" = "armv7hl" ]; then
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=armv7hl
|
|
else
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=$ARCH
|
|
fi
|
|
|
|
case "$ARCH" in
|
|
arm*) TARGET=$ARCH-slackware-linux-gnueabi ;;
|
|
*) TARGET=$ARCH-slackware-linux ;;
|
|
esac
|
|
|
|
set -e # Exit on most errors
|
|
|
|
rm -rf $PKG
|
|
mkdir -p $TMP $PKG $OUTPUT
|
|
cd $TMP
|
|
rm -rf $PRGNAM-$VERSION
|
|
|
|
mkdir -p $PRGNAM-$VERSION
|
|
cd $PRGNAM-$VERSION
|
|
tar xvf $CWD/gcc-$VERSION.tar.?z
|
|
cd gcc-$VERSION
|
|
chown -R root:root .
|
|
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 \
|
|
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
|
|
|
|
# Smite the fixincludes:
|
|
patch -p1 --verbose -i $CWD/patches/gcc-no_fixincludes.diff
|
|
|
|
mkdir ../objdir
|
|
cd ../objdir
|
|
|
|
if [ "$ARCH" != "x86_64" ]; then
|
|
GCC_ARCHOPTS="--with-arch=$ARCH"
|
|
else
|
|
GCC_ARCHOPTS="--disable-multilib"
|
|
fi
|
|
|
|
../gcc-$VERSION/configure \
|
|
--prefix=/usr \
|
|
--libdir=/usr/lib$LIBDIRSUFFIX \
|
|
--mandir=/usr/man \
|
|
--infodir=/usr/info \
|
|
--enable-shared \
|
|
--disable-bootstrap \
|
|
--enable-languages=c,c++,d \
|
|
--enable-threads=posix \
|
|
--enable-checking=release \
|
|
--with-system-zlib \
|
|
--disable-libquadmath-support \
|
|
--with-default-libstdcxx-abi=new \
|
|
--disable-libstdcxx-pch \
|
|
--disable-libunwind-exceptions \
|
|
--enable-__cxa_atexit \
|
|
--disable-libssp \
|
|
--enable-gnu-unique-object \
|
|
--enable-plugin \
|
|
--enable-lto \
|
|
--disable-install-libiberty \
|
|
--disable-werror \
|
|
--with-gcc-major-version-only \
|
|
--with-isl \
|
|
--program-suffix=-12 \
|
|
--with-arch-directory=$LIB_ARCH \
|
|
--disable-gtktest \
|
|
--enable-clocale=gnu \
|
|
$GCC_ARCHOPTS \
|
|
--target=${TARGET} \
|
|
--build=${TARGET} \
|
|
--host=${TARGET}
|
|
|
|
make
|
|
make install-strip DESTDIR=$PKG
|
|
|
|
rm $PKG/usr/lib${LIBDIRSUFFIX}/*.la
|
|
|
|
mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/gcc-12
|
|
mkdir -p $PKG/usr/share/gdb/auto-load/usr/lib$LIBDIRSUFFIX
|
|
|
|
mv $PKG/usr/lib$LIBDIRSUFFIX/*-gdb.py \
|
|
$PKG/usr/share/gdb/auto-load/usr/lib$LIBDIRSUFFIX/
|
|
mv $PKG/usr/lib${LIBDIRSUFFIX}/*.{a,o,spec,so*} \
|
|
$PKG/usr/lib${LIBDIRSUFFIX}/gcc-12
|
|
|
|
cd ../gcc-$VERSION
|
|
|
|
# They conflict with the stock package.
|
|
rm -rf $PKG/usr/man/man7 \
|
|
$PKG/usr/info \
|
|
$PKG/usr/share/locale
|
|
|
|
# Compress man pages
|
|
find $PKG/usr/man -type f -exec gzip -9 {} \;
|
|
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
|
|
|
|
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
|
|
cp -a \
|
|
COPYING* ChangeLog* INSTALL LAST_UPDATED MAINTAINERS NEWS README* \
|
|
$PKG/usr/doc/$PRGNAM-$VERSION
|
|
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$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
|