#!/bin/sh

if [ "$PROJ" = "" ] ; then
  echo
  echo Variable PROJ must be defined !!!
  echo
  exit -1
fi

if [ ! -d $PROJ ] ; then
  echo
  echo Invalid PROJECT directory $PROJ !!!
  echo
  exit -1
fi

if [ ! "$1" = "tsxk" -a ! "$1" = "pr3k" ] ; then
  echo "usage : $0 {tsxk | pr3k}"
  exit
fi

if [ "$1" = "tsxk" ] ; then
  ports=32
else
  ports=64
fi

# creates .config for the machine type
cd $PROJ/linux
cp -a .config.$1 .config
make menuconfig < $PROJ/keys_esc_cr

cd $PROJ/target
rm -rf dev/ttyS*

cp -a /opt/hardhat/devkit/ppc/8xx/target/dev/ttyS0 dev/ttyS0 

# build ttyS
cd $PROJ
./mk_devs $ports

# finaly generates the zImage 
cd $PROJ
./ex_make dep clr img


