#!/bin/sh

# Following should be defined in SDKdefs
#export REVOLUTION_SDK_ROOT="$HOME/bw/RVL_SDK"
#export CWFOLDER_RVL="$HOME/bw/CW_RVL"
#export REVOLUTION_EXT_ROOT="$HOME/bw/RevoEx"
#export RVLDWC_ROOT="$HOME/bw/RVLDWC"

export CYGWIN_PATH="C:\cygwin"
export REVOLUTION_P2P_ROOT=`cygpath -m "$HOME/bw/p2p_root"`
export BCC_TREE=`cygpath -m $HOME/bcc`

#export PATH="`cygpath $REVOLUTION_SDK_ROOT/X86/bin`:`cygpath $CWFOLDER_RVL/bin`:`cygpath $NDEV_TOOLS`:$PATH"
#export LM_LICENSE_FILE=$CWFOLDER_RVL/license.dat

# Use same source as NC build, which also builds on this machine
export GBA=$HOME/bw/sw

rm -rf $REVOLUTION_P2P_ROOT
mkdir -p $REVOLUTION_P2P_ROOT
cd $GBA/bw/build 

#
# 1. Need two different 'make' commands because if NANDAPP is declared before
#    object files are created (i.e. clean tree) then some of the implicit rules
#    are not treated correctly by MAKE
#
# 2. Need 'INSTALL=install' so each test module is called with BUILDFLAG install
#    and so we do not override $(INSTALL) directives
#

make NDEBUG=1 clean all
make libraries 

#create wad file and export all files
make NDEBUG=1 NANDAPP=1 INSTALL=install all

#do wiishop building
make -C tests/wiishop final release debug

#
# Create P2P SDK image
cd $GBA/tools/p2p-sdk
make install

#
# Create ECDK image
cd $GBA/tools/ecdk
make install

#
# Create ECSHOP image
cd $GBA/tools/ecshop
make install
