#!/bin/bash # u-boot-tools.SlackBuild # Build the tools for Das U-Boot # by Stuart Winter # CWD=$(pwd) NAME="u-boot" VERSION=${VERSION:-$(echo $NAME-*.tar.?z* | cut -d - -f3 | rev | cut -d . -f3- | rev)} BUILD="1" NUMJOBS=${NUMJOBS:-" -j$(grep -c ^processor /proc/cpuinfo 2>/dev/null) "} # Automatically determine the architecture we're building on: MARCH=$( uname -m ) if [ -z "$ARCH" ]; then case "$MARCH" in i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$MARCH ;; esac fi if [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O3 -march=i686 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O3 -fPIC" LIBDIRSUFFIX="64" elif [ "$ARCH" = "arm" ]; then SLKCFLAGS="-O3 -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard" LIBDIRSUFFIX="" elif [ "$ARCH" = "aarch64" ]; then SLKCFLAGS="-O3 -fPIC" LIBDIRSUFFIX="64" elif [ "$ARCH" = "riscv64" ]; then SLKCFLAGS="-O3 -fPIC" LIBDIRSUFFIX="64" else SLKCFLAGS="-O2" LIBDIRSUFFIX="" fi case "$ARCH" in arm*) TARGET=$ARCH-slackware-linux-gnueabi ;; *) TARGET=$ARCH-slackware-linux ;; esac # Establishment tmp directory for TMP=${TMP:-/tmp} PKG=$TMP/package-$NAME rm -rf $PKG mkdir -p $PKG # Delete a directory previous build / create new and change rights cd $TMP rm -rf $NAME-$VERSION tar xvf $CWD/$NAME-$VERSION.tar.?z* || exit 1 cd $NAME-${VERSION} chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; # Configuration make distclean make defconfig || exit 1 # Compilation make $NUMJOBS tools-all CONFIG_KIRKWOOD=y || exit 1 make $NUMJOBS env || exit 1 # Install into package: mkdir -vpm755 $PKG/usr/doc/$NAME-tools-$VERSION/ mkdir -vpm755 $PKG/usr/man/man1 mkdir -vpm755 $PKG/etc mkdir -vpm755 $PKG/usr/{bin,sbin} install -m755 tools/{fit_{check_sign,info},jtagconsole,gen_eth_addr,img2srec,dumpimage,mkimage,mkenvimage,netconsole,ncb,proftool,env/fw_printenv,kwboot} $PKG/usr/bin ln -vfsr $PKG/usr/bin/fw_printenv $PKG/usr/sbin/fw_setenv install -vpm644 README $PKG/usr/doc/$NAME-tools-$VERSION/README.envtools install -vpm644 $CWD/fw_env.config.new $PKG/etc/ install -vpm644 doc/{mkimage,kwboot}.1 $PKG/usr/man/man1/ # Copy docs: install -vpm644 \ CHANGELOG COPYING CREDITS MAINTAINERS README \ $PKG/usr/doc/$NAME-tools-$VERSION/ # Strip binaries: find $PKG | xargs file | grep -e "executable" -e "shared object" \ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null # Compress manual 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 # Description and installation script mkdir -p $PKG/install zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh cat $CWD/slack-desc > $PKG/install/slack-desc # Package creation cd $PKG makepkg -l n -c n $TMP/${NAME}-tools-${VERSION}-${ARCH}-${BUILD}.txz