--- /dev/null
+#!/bin/sh
+# Canonicalize CHOST.
+# In particular, converts Debian multiarch tuples into GNU triplets.
+# See also
+# https://wiki.debian.org/Multiarch/Tuples
+# https://wiki.gentoo.org/wiki/CHOST
+# If you need an architecture not listed here, file a bug at github.com/zlib-ng/zlib-ng
+# and work around the problem by dropping libtool's much more comprehensive config.sub
+# on top of this file, see
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+
+case "$1" in
+*-*-linux-gnu) echo $1;;
+i686-linux-gnu|x86_64-linux-gnu*) echo $1 | sed 's/-linux-gnu/-pc-linux-gnu/';;
+*-linux-gnu*) echo $1 | sed 's/-linux-gnu/-unknown-linux-gnu/';;
+*) echo $1;;
+esac
# set command prefix for cross-compilation
if [ -n "${CHOST}" ]; then
- uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
+ # normalize the chost before parsing it
+ NORM_CHOST=$(sh "$SRCDIR"/config.sub $CHOST)
+ uname="$(echo "${NORM_CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/')"
CROSS_PREFIX="${CHOST}-"
- ARCH="`echo "${CHOST}" | sed -e 's/-.*//'`"
+ ARCH="$(echo "${NORM_CHOST}" | sed -e 's/-.*//')"
else
ARCH="`uname -m`"
fi