2020-04-16 19:31:17 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Set initial variables:
|
|
|
|
CWD=$(pwd)
|
|
|
|
|
|
|
|
APP=avr-gcc
|
|
|
|
SRC=gcc
|
|
|
|
VERSION=$(ls $SRC-*.tar.?z* | sed -e 's/\.tar\..z.*//' | rev | cut -d- -f1 | rev)
|
2020-06-04 10:44:54 +02:00
|
|
|
MARCH=${MARCH:-native}
|
2020-04-16 19:31:17 +02:00
|
|
|
ARCH=${ARCH:-x86_64}
|
|
|
|
BUILD=${BUILD:-1}
|
|
|
|
TAG=${TAG:-micu}
|
2022-02-18 19:40:50 +01:00
|
|
|
TMP=${TMP:-/tmp}
|
|
|
|
OUTDIR=${OUTDIR:-$TMP}
|
2020-04-16 19:31:17 +02:00
|
|
|
|
|
|
|
LIBSUFFIX=""
|
|
|
|
BUILDABI=""
|
|
|
|
|
|
|
|
if [ "$MARCH" = "i386" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=i386 -mtune=i686"
|
|
|
|
elif [ "$MARCH" = "i486" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
|
|
|
|
elif [ "$MARCH" = "i586" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
|
|
|
|
elif [ "$MARCH" = "i686" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=i686"
|
|
|
|
elif [ "$MARCH" = "nocona" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=nocona -mtune=generic -mmmx -msse -msse2 -msse3"
|
|
|
|
elif [ "$MARCH" = "core2" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=core2 -mtune=core2 -mmmx -msse -msse2 -msse3"
|
2022-02-18 19:40:50 +01:00
|
|
|
elif [ "$MARCH" = "atom" -o "$MARCH" = "bonnell" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=bonnell -mmmx -msse -msse2 -msse3 -mssse3 -mcx16 -msahf -mmovbe -mfxsr --param l1-cache-size=24 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=bonnell"
|
2020-04-16 19:31:17 +02:00
|
|
|
elif [ "$MARCH" = "sandybridge" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=sandybridge"
|
|
|
|
elif [ "$MARCH" = "pentium3" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=pentium3 -mmmx -msse"
|
|
|
|
elif [ "$MARCH" = "pentium2" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=pentium2 -mmmx"
|
|
|
|
elif [ "$MARCH" = "s390" ]; then
|
|
|
|
SLKCFLAGS="-O2"
|
|
|
|
elif [ "$MARCH" = "armv7l" ]; then
|
|
|
|
BUILDABI="-gnueabi"
|
|
|
|
SLKCFLAGS="-O2 -mcpu=cortex-a53"
|
|
|
|
else
|
2020-06-04 22:04:13 +02:00
|
|
|
SLKCFLAGS="-O2 -march=$MARCH"
|
2020-04-16 19:31:17 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$ARCH" = "x86_64" ]; then
|
|
|
|
LIBSUFFIX=${LIBSUFFIX:-64}
|
|
|
|
SLKCFLAGS="$SLKCFLAGS -fPIC -m64"
|
|
|
|
fi
|
|
|
|
|
2022-02-18 19:40:50 +01:00
|
|
|
MAKE="make -j $(nproc)"
|
2020-04-16 19:31:17 +02:00
|
|
|
|
|
|
|
PKG=$TMP/package-$APP
|
|
|
|
rm -rf $PKG
|
|
|
|
mkdir -p $PKG
|
|
|
|
cd $TMP
|
|
|
|
rm -rf $SRC-$VERSION ${APP}-build
|
|
|
|
tar xvf $CWD/$SRC-$VERSION.tar.?z* || exit 1
|
|
|
|
( cd $SRC-$VERSION || exit 1
|
|
|
|
chown -R root:root .
|
|
|
|
find . -perm 444 -exec chmod 644 {} \;
|
|
|
|
find . -perm 777 -exec chmod 755 {} \;
|
|
|
|
find . -perm 666 -exec chmod 644 {} \; )
|
|
|
|
mkdir ${APP}-build
|
|
|
|
cd ${APP}-build || exit 1
|
|
|
|
|
|
|
|
CFLAGS_FOR_BUILD="$SLKCFLAGS" \
|
|
|
|
CXXFLAGS_FOR_BUILD="$SLKCFLAGS" \
|
|
|
|
../$SRC-$VERSION/configure \
|
|
|
|
--prefix=/usr \
|
|
|
|
--libdir=/usr/lib${LIBSUFFIX} \
|
|
|
|
--sysconfdir=/etc \
|
|
|
|
--localstatedir=/var \
|
|
|
|
--infodir=/usr/info \
|
|
|
|
--mandir=/usr/man \
|
|
|
|
--disable-install-libiberty \
|
|
|
|
--disable-libssp \
|
|
|
|
--disable-libstdcxx-pch \
|
|
|
|
--disable-libunwind-exceptions \
|
|
|
|
--disable-linker-build-id \
|
|
|
|
--disable-nls \
|
|
|
|
--disable-werror \
|
|
|
|
--enable-__cxa_atexit \
|
|
|
|
--enable-checking=release \
|
|
|
|
--enable-clocale=gnu \
|
|
|
|
--enable-cloog-backend=isl \
|
|
|
|
--enable-gnu-unique-object \
|
|
|
|
--enable-gold \
|
|
|
|
--enable-languages=c,c++ \
|
|
|
|
--enable-ld=default \
|
|
|
|
--enable-lto \
|
|
|
|
--enable-plugin \
|
|
|
|
--enable-shared \
|
|
|
|
--target=avr \
|
|
|
|
--with-as=/usr/bin/avr-as \
|
|
|
|
--with-gnu-as \
|
|
|
|
--with-gnu-ld \
|
|
|
|
--with-ld=/usr/bin/avr-ld \
|
|
|
|
--with-plugin-ld=ld.gold \
|
|
|
|
--with-system-zlib \
|
|
|
|
--with-dwarf2 \
|
|
|
|
--program-prefix="avr-" \
|
|
|
|
--program-suffix="" \
|
|
|
|
--build=$ARCH-slackware-linux${BUILDABI} || exit 1
|
|
|
|
|
|
|
|
$MAKE || exit 1
|
|
|
|
make install DESTDIR=$PKG || exit 1
|
|
|
|
|
|
|
|
# Don't ship .la files:
|
|
|
|
rm -f $PKG/{,usr/}lib${LIBSUFFIX}/*.la
|
|
|
|
|
|
|
|
# Remove useless stuff
|
|
|
|
rm -rf $PKG/usr/lib${LIBSUFFIX}/libiberty.a
|
|
|
|
rm -rf $PKG/usr/info
|
|
|
|
rm -rf $PKG/usr/include
|
|
|
|
rm -rf $PKG/usr/share
|
|
|
|
rm -rf $PKG/usr/man/man7
|
|
|
|
rm -rf $PKG/usr/libexec/gcc/avr/$VERSION/install-tools
|
|
|
|
|
2022-05-25 19:54:33 +02:00
|
|
|
chown -R root:bin $PKG/usr/bin
|
2020-04-16 19:31:17 +02:00
|
|
|
|
|
|
|
( cd $PKG
|
|
|
|
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
|
|
|
|
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
|
|
|
|
)
|
|
|
|
|
|
|
|
# Compress and if needed symlink the man pages:
|
|
|
|
if [ -d $PKG/usr/info ]; then
|
|
|
|
rm -f $PKG/usr/info/dir
|
|
|
|
gzip -9 $PKG/usr/info/*
|
|
|
|
fi
|
|
|
|
if [ -d $PKG/usr/man ]; then
|
|
|
|
( cd $PKG/usr/man
|
|
|
|
for manpagedir in $(find . -type d -name "man*") ; do
|
|
|
|
( cd $manpagedir
|
|
|
|
for eachpage in $( find . -type l -maxdepth 1) ; do
|
|
|
|
ln -s $( readlink $eachpage ).gz $eachpage.gz
|
|
|
|
rm $eachpage
|
|
|
|
done
|
|
|
|
gzip -9 *.?
|
|
|
|
)
|
|
|
|
done
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p $PKG/usr/doc/$APP-$VERSION
|
|
|
|
( cd ../$SRC-$VERSION && \
|
|
|
|
cp -a COPYING* ChangeLog MAINTAINERS NEWS README* \
|
|
|
|
$PKG/usr/doc/$APP-$VERSION )
|
|
|
|
|
|
|
|
mkdir -p $PKG/install
|
|
|
|
[ -f $CWD/doinst.sh ] && cat $CWD/doinst.sh > $PKG/install/doinst.sh
|
|
|
|
[ -f $CWD/doinst.sh.gz ] && zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
|
|
|
|
cat $CWD/slack-desc > $PKG/install/slack-desc
|
|
|
|
|
|
|
|
# Allow to run as non-root until now:
|
|
|
|
if [ $(id -u) -ne 0 ]; then
|
|
|
|
echo "*** Running as non-root, skipping makepkg."
|
|
|
|
echo "*** Package contents is in $PKG directory."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $PKG
|
2022-02-18 19:40:50 +01:00
|
|
|
makepkg -l y -c n $OUTDIR/$APP-$VERSION-$ARCH-${BUILD}${TAG}.txz
|
2020-04-16 19:31:17 +02:00
|
|
|
|
|
|
|
# Clean up the extra stuff:
|
|
|
|
if [ "$1" = "--cleanup" ]; then
|
|
|
|
rm -rf $TMP/$SRC-$VERSION $TMP/$APP-build
|
|
|
|
rm -rf $PKG
|
|
|
|
fi
|
|
|
|
|