Index: configure.sh
===================================================================
--- configure.sh	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ configure.sh	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -106,5 +106,34 @@
 fi
 
-meson "${SOURCE_DIR}" '.' --cross-file "${SOURCE_DIR}/meson/cross/${cross_target}" || exit 1
+cross_def="${SOURCE_DIR}/meson/cross/${cross_target}"
+cc_arch=`sed -n "s:cc_arch = '\(.*\)':\1:p" "$cross_def"`
+
+compname="$cc_arch-helenos-gcc"
+
+if which "$compname"; then
+	# Compiler is in PATH
+	compprefix="$cc_arch-helenos-"
+
+elif [ -n "$CROSS_PREFIX" ]; then
+	if ! which "$CROSS_PREFIX/bin/$compname"; then
+		echo "ERROR: \$CROSS_PREFIX defined but $compname is not present in $CROSS_PREFIX/bin."
+		echo "Run tools/toolchain.sh to build cross-compiling toolchain."
+		exit 1
+	fi
+
+	compprefix="$CROSS_PREFIX/bin/$cc_arch-helenos-"
+else
+	if ! which "/usr/local/cross/bin/$compname"; then
+		echo "ERROR: \$CROSS_PREFIX is not defined and $compname is not present in /usr/local/cross/bin."
+		echo "Run tools/toolchain.sh to build cross-compiling toolchain."
+		exit 1
+	fi
+
+	compprefix="/usr/local/cross/bin/$cc_arch-helenos-"
+fi
+
+sed "s:@COMPPREFIX@:$compprefix:g" "$cross_def" > crossfile || exit 1
+
+meson "${SOURCE_DIR}" '.' --cross-file crossfile || exit 1
 
 echo
Index: meson/cross/amd64
===================================================================
--- meson/cross/amd64	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/amd64	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'amd64-helenos-gcc'
-cpp = 'amd64-helenos-g++'
-ar = 'amd64-helenos-ar'
-strip = 'amd64-helenos-strip'
-nm = 'amd64-helenos-nm'
-objcopy = 'amd64-helenos-objcopy'
-objdump = 'amd64-helenos-objdump'
-as = 'amd64-helenos-as'
-ld = 'amd64-helenos-ld'
+c = '@COMPPREFIX@gcc'
+cpp = '@COMPPREFIX@g++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
Index: meson/cross/amd64_clang
===================================================================
--- meson/cross/amd64_clang	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/amd64_clang	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'amd64-helenos-clang'
-cpp = 'amd64-helenos-clang++'
-ar = 'amd64-helenos-ar'
-strip = 'amd64-helenos-strip'
-nm = 'amd64-helenos-nm'
-objcopy = 'amd64-helenos-objcopy'
-objdump = 'amd64-helenos-objdump'
-as = 'amd64-helenos-as'
-ld = 'amd64-helenos-ld'
+c = '@COMPPREFIX@clang'
+cpp = '@COMPPREFIX@clang++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
Index: meson/cross/arm32
===================================================================
--- meson/cross/arm32	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/arm32	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'arm-helenos-gcc'
-cpp = 'arm-helenos-g++'
-ar = 'arm-helenos-ar'
-strip = 'arm-helenos-strip'
-nm = 'arm-helenos-nm'
-objcopy = 'arm-helenos-objcopy'
-objdump = 'arm-helenos-objdump'
-as = 'arm-helenos-as'
-ld = 'arm-helenos-ld'
+c = '@COMPPREFIX@gcc'
+cpp = '@COMPPREFIX@g++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
Index: meson/cross/arm64
===================================================================
--- meson/cross/arm64	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/arm64	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'aarch64-helenos-gcc'
-cpp = 'aarch64-helenos-g++'
-ar = 'aarch64-helenos-ar'
-strip = 'aarch64-helenos-strip'
-nm = 'aarch64-helenos-nm'
-objcopy = 'aarch64-helenos-objcopy'
-objdump = 'aarch64-helenos-objdump'
-as = 'aarch64-helenos-as'
-ld = 'aarch64-helenos-ld'
+c = '@COMPPREFIX@gcc'
+cpp = '@COMPPREFIX@g++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
Index: meson/cross/ia32
===================================================================
--- meson/cross/ia32	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/ia32	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'i686-helenos-gcc'
-cpp = 'i686-helenos-g++'
-ar = 'i686-helenos-ar'
-strip = 'i686-helenos-strip'
-nm = 'i686-helenos-nm'
-objcopy = 'i686-helenos-objcopy'
-objdump = 'i686-helenos-objdump'
-as = 'i686-helenos-as'
-ld = 'i686-helenos-ld'
+c = '@COMPPREFIX@gcc'
+cpp = '@COMPPREFIX@g++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
Index: meson/cross/ia64
===================================================================
--- meson/cross/ia64	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/ia64	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'ia64-helenos-gcc'
-cpp = 'ia64-helenos-g++'
-ar = 'ia64-helenos-ar'
-strip = 'ia64-helenos-strip'
-nm = 'ia64-helenos-nm'
-objcopy = 'ia64-helenos-objcopy'
-objdump = 'ia64-helenos-objdump'
-as = 'ia64-helenos-as'
-ld = 'ia64-helenos-ld'
+c = '@COMPPREFIX@gcc'
+cpp = '@COMPPREFIX@g++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
Index: meson/cross/mips32
===================================================================
--- meson/cross/mips32	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/mips32	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'mipsel-helenos-gcc'
-cpp = 'mipsel-helenos-g++'
-ar = 'mipsel-helenos-ar'
-strip = 'mipsel-helenos-strip'
-nm = 'mipsel-helenos-nm'
-objcopy = 'mipsel-helenos-objcopy'
-objdump = 'mipsel-helenos-objdump'
-as = 'mipsel-helenos-as'
-ld = 'mipsel-helenos-ld'
+c = '@COMPPREFIX@gcc'
+cpp = '@COMPPREFIX@g++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
Index: meson/cross/mips32eb
===================================================================
--- meson/cross/mips32eb	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/mips32eb	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'mips-helenos-gcc'
-cpp = 'mips-helenos-g++'
-ar = 'mips-helenos-ar'
-strip = 'mips-helenos-strip'
-nm = 'mips-helenos-nm'
-objcopy = 'mips-helenos-objcopy'
-objdump = 'mips-helenos-objdump'
-as = 'mips-helenos-as'
-ld = 'mips-helenos-ld'
+c = '@COMPPREFIX@gcc'
+cpp = '@COMPPREFIX@g++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
Index: meson/cross/ppc32
===================================================================
--- meson/cross/ppc32	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/ppc32	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'ppc-helenos-gcc'
-cpp = 'ppc-helenos-g++'
-ar = 'ppc-helenos-ar'
-strip = 'ppc-helenos-strip'
-nm = 'ppc-helenos-nm'
-objcopy = 'ppc-helenos-objcopy'
-objdump = 'ppc-helenos-objdump'
-as = 'ppc-helenos-as'
-ld = 'ppc-helenos-ld'
+c = '@COMPPREFIX@gcc'
+cpp = '@COMPPREFIX@g++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
Index: meson/cross/riscv64
===================================================================
--- meson/cross/riscv64	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/riscv64	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'riscv64-helenos-gcc'
-cpp = 'riscv64-helenos-g++'
-ar = 'riscv64-helenos-ar'
-strip = 'riscv64-helenos-strip'
-nm = 'riscv64-helenos-nm'
-objcopy = 'riscv64-helenos-objcopy'
-objdump = 'riscv64-helenos-objdump'
-as = 'riscv64-helenos-as'
-ld = 'riscv64-helenos-ld'
+c = '@COMPPREFIX@gcc'
+cpp = '@COMPPREFIX@g++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
Index: meson/cross/sparc64
===================================================================
--- meson/cross/sparc64	(revision 521669df78ef00a0fd9c13e99c801d6b1540f568)
+++ meson/cross/sparc64	(revision a42be380ec77e0657e09ad87b44154917913e8ea)
@@ -2,13 +2,13 @@
 
 [binaries]
-c = 'sparc64-helenos-gcc'
-cpp = 'sparc64-helenos-g++'
-ar = 'sparc64-helenos-ar'
-strip = 'sparc64-helenos-strip'
-nm = 'sparc64-helenos-nm'
-objcopy = 'sparc64-helenos-objcopy'
-objdump = 'sparc64-helenos-objdump'
-as = 'sparc64-helenos-as'
-ld = 'sparc64-helenos-ld'
+c = '@COMPPREFIX@gcc'
+cpp = '@COMPPREFIX@g++'
+ar = '@COMPPREFIX@ar'
+strip = '@COMPPREFIX@strip'
+nm = '@COMPPREFIX@nm'
+objcopy = '@COMPPREFIX@objcopy'
+objdump = '@COMPPREFIX@objdump'
+as = '@COMPPREFIX@as'
+ld = '@COMPPREFIX@ld'
 
 [properties]
