You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
4.4 KiB
159 lines
4.4 KiB
4 years ago
|
#!/bin/bash
|
||
|
# Build script for Slackware
|
||
|
# Copyright (C) 2018 Damien Goutte-Gattat
|
||
|
#
|
||
|
# Redistribution and use of this script, with or without modifications,
|
||
|
# 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.
|
||
|
#
|
||
|
# Contact: Damien Goutte-Gattat <dgouttegattat@incenp.org>
|
||
|
#
|
||
|
# Latest gcc sourcecode is available at: <http://sourceware.org/>.
|
||
|
#
|
||
|
# Depends: d/newlib-arm-none-eabi
|
||
|
|
||
|
# Source package infos
|
||
|
NAMESRC=${NAMESRC:-gcc}
|
||
|
VERSION=${VERSION:-6.3.1}
|
||
|
REVISION=${REVISION:-253039}
|
||
|
ARCHIVE=${ARCHIVE:-$NAMESRC-${VERSION}svn$REVISION.tar.xz}
|
||
|
REPOURL=${REPOURL:-svn://gcc.gnu.org/svc/gcc/branches/ARM/embedded-6-branch}
|
||
|
|
||
|
# Build infos
|
||
|
NAMEPKG=${NAMEPKG:-gcc-arm-none-eabi}
|
||
|
BUILD=${BUILD:-1GGD}
|
||
|
ARCH=${ARCH:-$(uname -m | sed 's/^i.86$/i486/;s/^arm.*/arm/')}
|
||
|
JOBS=${JOBS:-1}
|
||
|
EXT=${EXT:-txz}
|
||
|
|
||
|
# Directories
|
||
|
TMP=${TMP:-/tmp}
|
||
|
OUT=${OUT:-$TMP/build}
|
||
|
PKG=${PKG:-$OUT/$NAMEPKG}
|
||
|
CWD=$(pwd)
|
||
|
|
||
|
LIBDIRSUFFIX=
|
||
|
[ "x$ARCH" == xx86_64 ] && LIBDIRSUFFIX=64
|
||
|
|
||
|
set -e # Quit if a command returns non-zero
|
||
|
|
||
|
# Sanity checks
|
||
|
if [ $UID -eq 0 ]; then
|
||
|
echo "You should NOT run this script as ROOT!"
|
||
|
exit 1
|
||
|
fi
|
||
|
if [ ! -d $TMP ]; then
|
||
|
echo "$TMP does not exists or is not a directory!"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# Get and verify the source archive
|
||
|
NAME=gcc-${VERSION}svn$REVISION
|
||
|
if [ ! -r $ARCHIVE ]; then
|
||
|
svn co $REPOURL@$REVISION $NAME
|
||
|
tar -c --xz \
|
||
|
--exclude=".svn" \
|
||
|
--exclude="libffi" \
|
||
|
--exclude="libgomp" \
|
||
|
--exclude="libquadmath" \
|
||
|
--exclude="libssp" \
|
||
|
--exclude="libada" \
|
||
|
--exclude="libgfortran" \
|
||
|
--exclude="libcilkrts" \
|
||
|
--exclude="libgo" \
|
||
|
--exclude="libjava" \
|
||
|
--exclude="zlib" \
|
||
|
--exclude="gcc/testsuite/ada" \
|
||
|
--exclude="gcc/testsuite/gfortran.dg" \
|
||
|
--exclude="gcc/testsuite/gfortran.fortran-torture" \
|
||
|
--exclude="gcc/testsuite/go.dg" \
|
||
|
--exclude="gcc/testsuite/go.go-torture" \
|
||
|
--exclude="gcc/testsuite/go.test" \
|
||
|
--exclude="gcc/testsuite/objc" \
|
||
|
--exclude="gcc/testsuite/obj-c++.dg" \
|
||
|
--exclude="gcc/testsuite/objc.dg" \
|
||
|
--exclude="gcc/testsuite/objc-obj-c++-shared" \
|
||
|
--exclude="gcc/ada/doc" \
|
||
|
-f $NAME.tar.xz $NAME
|
||
|
rm -rf $NAME
|
||
|
fi
|
||
|
sha256sum -c $ARCHIVE.sha256
|
||
|
|
||
|
# Compile 2nd stage GCC
|
||
|
cd $TMP
|
||
|
echo "Building $ARCHIVE..."
|
||
|
tar xf $CWD/$ARCHIVE
|
||
|
mkdir buildgcc && cd buildgcc
|
||
|
../$NAME/configure \
|
||
|
--prefix=/usr \
|
||
|
--libdir=/usr/lib$LIBDIRSUFFIX \
|
||
|
--build=$ARCH-slackware-linux \
|
||
|
--target=arm-none-eabi \
|
||
|
--with-sysroot=/usr/arm-none-eabi \
|
||
|
--enable-languages=c,c++ \
|
||
|
--enable-plugins \
|
||
|
--disable-decimal-float \
|
||
|
--disable-libffi \
|
||
|
--disable-libgomp \
|
||
|
--disable-libmudflap \
|
||
|
--disable-libquadmath \
|
||
|
--disable-libssp \
|
||
|
--disable-libstdcxx-pch \
|
||
|
--disable-nls \
|
||
|
--disable-shared \
|
||
|
--disable-threads \
|
||
|
--disable-tls \
|
||
|
--with-gnu-as \
|
||
|
--with-gnu-ld \
|
||
|
--with-newlib \
|
||
|
--with-headers=yes \
|
||
|
--with-python-dir=share/gcc-arm-none-eabi
|
||
|
make -j $JOBS INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"
|
||
|
make install DESTDIR=$PKG
|
||
|
rmdir $PKG/usr/include
|
||
|
rm $PKG/usr/lib$LIBDIRSUFFIX/libcc1.*
|
||
|
|
||
|
# Strip binaries
|
||
|
find $PKG/usr/bin | xargs file | grep "ELF \(32\|64\)-bit LSB" | cut -d : -f 1 | \
|
||
|
xargs strip --strip-unneeded 2> /dev/null
|
||
|
|
||
|
# Remove man and info pages
|
||
|
rm -rf $PKG/usr/share/{man,info}
|
||
|
|
||
|
# Copy slack-desc file
|
||
|
install -D -m 644 $CWD/slack-desc $PKG/install/slack-desc
|
||
|
|
||
|
# Add dependency infos
|
||
|
cat <<EOF > $PKG/install/slack-required
|
||
|
newlib-arm-none-eabi
|
||
|
EOF
|
||
|
|
||
|
# Package the tree
|
||
|
cd $PKG
|
||
|
mkdir -p $OUT
|
||
|
PACKAGING="
|
||
|
chown root:root . -R
|
||
|
/sbin/makepkg -l y -c n $OUT/$NAMEPKG-$VERSION-$ARCH-$BUILD.$EXT
|
||
|
rm -rf $PKG
|
||
|
rm -rf $TMP/$NAME $TMP/buildgcc
|
||
|
"
|
||
|
if type -p fakeroot ; then
|
||
|
echo "$PACKAGING" | fakeroot
|
||
|
else
|
||
|
su -c "$PACKAGING"
|
||
|
fi
|