#!/bin/sh


ROOT="/home/andy.hsu"
KERNEL_VERSION="2.6.35.8"
CHIP=eiffel



THEALE_PATH="$ROOT/THEALE"
PHOTOSPHERE_ROOT="$ROOT/DAILEO/Supernova"


function build()
{
DFB_NEEDED_PATH="$PHOTOSPHERE_ROOT/develop/include"
UTOPIA_INCLUDE_PATH="$PHOTOSPHERE_ROOT/develop/include/utopia/eiffel"
KERNEL_PATH="$ROOT/THEALE/RedLion/$KERNEL_VERSION"


echo "======= DFB needed library ======="
echo $PHOTOSPHERE_ROOT
echo $DFB_NEEDED_PATH
echo $UTOPIA_INCLUDE_PATH
echo $KERNEL_PATH
echo "=================================="



CFLAGS_SETTING="-pthread -I$DFB_NEEDED_PATH/png -I$DFB_NEEDED_PATH/zlib -I$DFB_NEEDED_PATH/jpeg -I$DFB_NEEDED_PATH/freetype/freetype2 -I$DFB_NEEDED_PATH/freetype -I$UTOPIA_INCLUDE_PATH -I$KERNEL_PATH/include -I$KERNEL_PATH/usr/include -I$KERNEL_PATH/drivers/mstar/include -I$KERNEL_PATH/arch/mips/include -DMSOS_TYPE_LINUX"

CPPFLAGS_SETTING="-pthread "


# For fix reference libapiGOP.so 
cp -f ./unittest/build/Makefile.am.IDirectFBImageProvider ./interfaces/IDirectFBImageProvider/Makefile.am ;
cp -f ./unittest/build/Makefile.am.IDirectFBVideoProvider ./interfaces/IDirectFBVideoProvider/Makefile.am ;


# **********************************************
# Reference Libs
# **********************************************
echo "Running autoconf & automake"
autoreconf
autoconf
automake


./configure     CC="cpptestscan --cpptestscanProjectName=UT_DFBProject gcc -m32" \
		LD="cpptestscan --cpptestscanProjectName=UT_DFBProject ld"\
                CFLAGS="$CFLAGS_SETTING" \
                LDFLAGS="$LD_LIB_PATH" \
                CPPFLAGS="$CPPFLAGS_SETTING" \
                FREETYPE_CFLAGS="-I$DFB_NEEDED_PATH/freetype " \
                FREETYPE_LIBS="-lfreetype -lz" \
                LIBS="$MSTAR_LIB $HW_DECODEJPEG_LIBS" \
                --host= \
                --build=i386-linux \
                --enable-jpeg \
                --enable-zlib \
                --enable-png \
                --enable-gif \
		--enable-gopc \
                --enable-vec \
                --enable-freetype \
                --disable-profiling \
                --disable-unique \
                --with-gfxdrivers=mstargfx,mstargfx_g2 \
                --with-inputdrivers=mstarlinuxinput,mstarir,mstarkeypad,mstarloopbackinput \
                --enable-multi \
                --with-tests=no \
		--with-tools=no \
                --disable-fbdev \
                --disable-x11 \
                --disable-vnc \
                --disable-sdl \
                --enable-devmem \
                --enable-hwdecodejpeg \
                --disable-OBAMA_BUILD \
		--disable-dependency-tracking
}

function genbdf()
{
	echo "Build BDF"
	cat ./gfxdrivers/mstar_g2/cpptestscan.bdf  ./interfaces/IDirectFBImageProvider/cpptestscan.bdf ./interfaces/IDirectFBVideoProvider/cpptestscan.bdf  > cpptestscan.bdf
}

case $1 in
"genbdf")
		echo
    echo "################ Gen BDF ################"
 		genbdf $2
 		echo "Done!!!"
 		echo   
    ;;

 *)
     echo
     echo "################  Configure DFB UT ################"
     build $1
     ;;
 esac

