#!/bin/sh
#
#  Simple utility to make every tool for this host.
#  Run as:
#	build [target]
#  The build utility also supports various
#  makefile targets.
#  For example:
#	build -target=install
#

export PATH || (echo "OOPS, this isn't sh.  Desperation time."; sh $0 $argv; kill $$)

. ../../../sdkshell.conf

subdirs="include common gnumake bit pvc list strip ic4mat srec srom repeat objtest makerom uload sysgen rcsv hex32 hexpad"

gnumakesubdirs="hfcomp mini_dbg"

# Build the bulk of the utilities

for dir in $subdirs ; do
    if [ ! -f $dir/Makefile ] ; then
	echo "***** No Makefile in $dir"
    else
	echo "##### Building $dir #####"
        (cd $dir ; make -f Makefile ; make -f Makefile install)
    fi
done


# Build those that need gnumake
for dir in $gnumakesubdirs ; do
    if [ ! -f $dir/Makefile ] ; then
	echo "***** No Makefile in $dir"
    else
	echo "##### Building $dir #####"
        (cd $dir ; $EB_TOOLBOX/gnumake -f Makefile ; $EB_TOOLBOX/gnumake -f Makefile install)
    fi
done

