#!/bin/sh

if [ $# != 1 -o $0 != "./install_eka2_tools" ]; then
  echo "Usage: ./install_eka2_tools <target-dir>"
  echo " e.g.: ./install_eka2_tools ~/csl-gcc"
  exit 1
fi

DEST=`echo $1 | sed s:/\$::`

mkdir -p $DEST/bin

MAKE=make
if [ "`which gmake`" != "" ]; then
	MAKE=gmake
fi

TRUE=`which true`

while read a
do
  echo "$a"
  sh -c "$a"
  if test $? != 0; then
    echo "Unexcpected error: aborting."
    exit 1
  fi
done << __END

cd petran-1.1.0 && $MAKE && cp e32uid/uidcrc $DEST/bin
cd bmconv-1.1.0-2 && $MAKE && cp src/bmconv $DEST/bin
cd rcomp-7.0.1 && $MAKE && cp src/rcomp $DEST/bin
cd makesis-4 && $MAKE && cp src/makesis src/signsis src/makekeys $DEST/bin
cd make-3.81 && ./configure && $MAKE && cp make $DEST/bin/extmake
cd elf2e32 && $MAKE -f Makefile.local-libelf libelf.a elf2e32 && cp elf2e32 $DEST/bin
g++ mifconv.cpp -o $DEST/bin/mifconv
ln -sf $TRUE $DEST/bin/rem
cp del $DEST/bin

__END

