case "$MODE" in
    configure)
        if [ "$HOST_ARCH" != "$ARCH" ] && [ -z "$CROSS_ARCH_EMULATOR" ]; then
            # cross-architecture binary support needs binfmt_misc associated
            # qemu and the appropriate binaries for the specified architecture
            case $ARCH in
                armel) # tested with qemu 0.11.0-rc0
                    CROSS_ARCH_EMULATOR=qemu-arm
                    ;;
                powerpc) # semi-functional with qemu 0.12.1
                    CROSS_ARCH_EMULATOR=qemu-ppc
                    ;;
                i386)
                    # building i386 on amd64 doesn't require qemu
                    if [ "$HOST_ARCH" != "amd64" ]; then
                        # untested
                        CROSS_ARCH_EMULATOR=qemu-i386
                    fi
                    ;;
                amd64) # untested
                    CROSS_ARCH_EMULATOR=qemu-x86_64
                    ;;
                mips|mipsel) # semi-functional with qemu 0.12.1
                    CROSS_ARCH_EMULATOR=qemu-"$ARCH"
                    ;;
                *) echo "WARNING: unknown cross-architecture combination: $ARCH on $HOST_ARCH"
                    ;;
            esac
            if [ -z "$CROSS_ARCH_EMULATOR" ]; then
                : # no cross-architecture emulator detected
            elif [ -x "/usr/bin/${CROSS_ARCH_EMULATOR}-static" ]; then
                # prefer static variants
                CROSS_ARCH_EMULATOR="/usr/bin/${CROSS_ARCH_EMULATOR}-static"
            elif [ -x "/usr/bin/${CROSS_ARCH_EMULATOR}" ]; then
                CROSS_ARCH_EMULATOR="/usr/bin/${CROSS_ARCH_EMULATOR}"
            else
                echo "WARNING: unable to find: $CROSS_ARCH_EMULATOR in /usr/bin"
                unset CROSS_ARCH_EMULATOR
            fi
        fi
        if [ -n "$CROSS_ARCH_EMULATOR" ] && [ ! -x "$CROSS_ARCH_EMULATOR" ]; then
            echo "WARNING: cross architecture support requested, but binary not installed: $CROSS_ARCH_EMULATOR" 
            unset CROSS_ARCH_EMULATOR
        fi
        ;;
esac
