#!/bin/bash

if [ "$1" == "clean" -o "$1" == "Clean" -o "$1" == "CLEAN" ]; then
    echo "********************************************************************************"
    echo "* Clean Kernel                                                                 *"
    echo "********************************************************************************"

    test -e out && rm -rf out
    echo " It's done... "
else
    echo "********************************************************************************"
    echo "* Build Kernel                                                                 *"
    echo "********************************************************************************"

    TOOLCHAIN=`pwd`/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
    TOOLCHAIN_PREFIX=arm-eabi-

    export ANDROID_BUILD_TOP=`pwd`
    export CCI_KLOG_COLLECTOR=1

    test -e out || mkdir out
    test -e out/kernel || mkdir out/kernel
    test -e out/system || mkdir out/system

    pushd kernel
    make O=../out/kernel ARCH=arm da80_defconfig
    make -j4 O=../out/kernel ARCH=arm CROSS_COMPILE=$TOOLCHAIN/$TOOLCHAIN_PREFIX
    make O=../out/kernel ARCH=arm CROSS_COMPILE=$TOOLCHAIN/$TOOLCHAIN_PREFIX modules
    popd
fi
