#!/bin/sh

export ROOT=/home/scbuild/gba/gba_root
if [ "$1" != "" ]; then rm -rf $ROOT; fi
mkdir -p $ROOT

export PATH=${PATH}:${ROOT}/usr/bin/x86:/usr/bin

export NCV=/ecad/cadence/tools.lnx86/bin
export PATH=${PATH}:${NCV}
export NCV_LIB_PATH=${NCV}/../lib:${NCV}/../inca/lib:${NCV}/../ict/Linux/pli/ncv1_21
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NCV_LIB_PATH}
export CDS_LIC_FILE="/ecad/cadence/license/license.filestore:5280@filestore"
export IOSIM_PORT=1114

#
# It is necessary to make clobber and make headers after the clobber
# to make sure we get the correct version of addr_map.h for RVL.
#
cd /home/scbuild/gba/sw
time make -k headers &&
time make -k clobber &&
time make -k headers &&
time make -k exports &&
time make -k &&
time make -k install &&
time make -k runtests

#
# Now build just the RVL portion again with RVL_MEM == 64 to
# get the RVL modules built for a production RVL platform,
# using a different ROOT.
#
# This requires "make clobber" to avoid getting a mishmash 
# of 128MB and 64MB object files in the rvl portion of the tree.
#
time make -k clobber

export RVL_MEM=64
export ROOT=/home/scbuild/gba/gba_root/rvl_64
if [ "$1" != "" ]; then rm -rf $ROOT; fi
mkdir -p $ROOT
time make -k headers &&
time make -k exports &&
time make -k &&
time make -k install
