#!/bin/sh

expat_dir="./expat-2.0.1/"

common_stuff="../commhub/commhub.c ../commhub/client_utils.c ../common/common_defs.c"
video_stuff="fbutil.c smallfont.c medfont.c bigfont.c"
xml_stuff="${expat_dir}.libs/libexpat.a"

if grep -q "CC = $target_cc" ${expat_dir}Makefile; then
	echo "Expat already configured for our target."
	(cd $expat_dir; make)
else
	echo "Expat must be re-configured to use $target_cc";
	tgtflag=`echo $target_cc | sed -r "s/-?gcc//" | tr -d "\n"`
	if [ -n "$tgtflag" ]; then tgtflag="--host $tgtflag"; fi
	(cd $expat_dir; ./configure $tgtflag; make clean; make)
fi

rm -f diu_minder
$target_cc $target_ccopts -o diu_minder -lcrypto diu_main.c menu.c mkgmtime.c $common_stuff $video_stuff $xml_stuff

rm -f showmessage
$target_cc $target_ccopts -o showmessage showmessage.c $video_stuff
