#!/bin/sh 

#-----------------------------------------------------------------------
# Get the system and processor type information via uname(1)
#-----------------------------------------------------------------------

SYS=`uname -s`
ARCH=`uname -p`

CONFIG="Makefile.config"

#-----------------------------------------------------------------------
# check for a predefined config and use it if found
#-----------------------------------------------------------------------

if [ -f configs/${CONFIG}_${SYS}_${ARCH} ]
   then

   echo ""
   echo "Copying configs/${CONFIG}_${SYS}_${ARCH} to ${CONFIG}"
   if [ -f ${CONFIG} ]
      then
      mv ${CONFIG} ${CONFIG}_old

   fi

   cp configs/${CONFIG}_${SYS}_${ARCH} ${CONFIG} 

else
#-----------------------------------------------------------------------
# use the generic template
#-----------------------------------------------------------------------

   echo ""
   echo "I don't find a predefined ${CONFIG} for your system.   "
   echo "A generic template has been used."
   echo ""
   echo "You need to edit the file to describe your system."
   echo "Pay particular attention to the CWP_ENDIAN flag."

   echo "Copying configs/${CONFIG}_generic to ${CONFIG}"
   if [ -f ${CONFIG} ]
      then
      mv ${CONFIG} ${CONFIG}_old

   fi

   cp configs/${CONFIG}_generic ${CONFIG} 

fi

echo ""
echo "${CONFIG} is now configured for this system.  Please review the"
echo "settings to ensure that the desired features have been selected."

echo ""
echo "The default is to compile w/ debugging (-g).  For better "
echo "performance you may want to select a higher level of "
echo "optimization."
