#!/bin/sh
set -e

uboot() {
    . ./u-boot-brain/.config
    case "${CONFIG_SYS_CPU}" in
        arm926ejs) echo -n "arm-linux-gnueabi-"; return;;
        armv7) echo -n "arm-linux-gnueabihf-"; return;;
        *) exit 1;;
    esac
}

linux() {
    . ./linux-brain/.config
    case "${CONFIG_CPU_ARM926T}_${CONFIG_ARCH_MULTI_V7}" in
        y_) echo -n "arm-linux-gnueabi-"; return;;
        _y) echo -n "arm-linux-gnueabihf-"; return;;
        *) exit 1;;
    esac
}

rootfs() {
    . ./linux-brain/.config
    case "${CONFIG_CPU_ARM926T}_${CONFIG_ARCH_MULTI_V7}" in
        y_) echo -n "armel"; return;;
        _y) echo -n "armhf"; return;;
        *) exit 1;;
    esac
}

case "$1" in
    u-boot) uboot ;;
    linux) linux ;;
    rootfs) rootfs ;;
    *) exit 1; ;;
esac
