#!/bin/bash

bindir="`pwd`/sablink/scripts"
confdir="`pwd`/sablink/config"

get_flavourconfigs() {
    for file in `find $confdir`; do
	if echo $file | egrep -q "config\.flavour\..*[^~]$"; then
            basename $file | awk -F . '{ print $3 }'
        fi
    done
}

get_arch() {
    if find . -name config.flavour.$1 | grep -q x86; then
        echo x86
    elif find . -name config.flavour.$1 | grep -q amd64; then
        echo x86
    else
        echo arm
    fi
}

for flavour in $(get_flavourconfigs); do
    echo $flavour $(get_arch $flavour)
    $bindir/prepareconfig $flavour
    yes "" | make ARCH=$(get_arch $flavour) oldconfig
    cp .config .config-$flavour
done

