# 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
             export LIBDIRSUFFIX=""
             export SLK_ARCH_BUILDTARGET="$ARCH-slackware-linux"
             gcc -v 2>&1| grep -Eq ".*slack.*gnueabihf" && ARMARCH=hard || ARMARCH=soft
             [ $ARMARCH == soft ] && {
                  export SLKCFLAGS="-O2 -march=armv5te"
                  export SLK_ARCH_BUILDTARGET="${SLK_ARCH_BUILDTARGET}-gnueabi" ;}
             [ $ARMARCH == hard ] && {
                  export SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
                  export SLK_ARCH_BUILDTARGET="${SLK_ARCH_BUILDTARGET}-gnueabihf" ;} ;;
  aarch64)   export ARCH=aarch64
             export LIBDIRSUFFIX="64"
             export SLKCFLAGS="-O2"
             export SLK_ARCH_BUILDTARGET="$ARCH-slackware-linux-gnu" ;;
    # Unless $ARCH is already set, use uname -m for all other archs:
    *)       export ARCH=$MARCH ;;
  esac
fi

cat << EOF
ARCH: $ARCH
SLKCFLAGS: $SLKCFLAGS
SLK_ARCH_BUILDTARGET: $SLK_ARCH_BUILDTARGET (used for ./configure --build=$SLK_ARCH_BUILDTARGET)
LIBDIRSUFFIX: $LIBDIRSUFFIX
EOF

