#!/bin/sh -e
# $Id: build,v 1.2 2005/03/29 18:57:47 querbach Exp $

# build
#----------------------------------------------------------------------------
#
#	Build All
#
#	This script removes all previous builds, then builds all of the
#	source for the RTEMS-Linux TCP/IP via CAN system.
#
#	The location of the RTEMS toolchain and the RTEMS configuration are
#	set in ss555/Config.  If your RTEMS tools are installed in a
#	non-default location, you should modify this file to suit before
#	running this script.
#
#	Note that the RTEMS and lwIP libraries need to be installed before
#	the lwipocan-test program can be built.  This script also takes care
#	of these installations, using sudo(1) to obtain any required
#	privileges in the target directory.
#
#	The Linux components were built on a Debian "sarge" system, and
#	tested on a different Debian "sarge" system with a 2.4.26-1-k7
#	kernel.
#
#	Sponsored by Defence Research and Development Canada -- Suffield,
#	(C) Her Majesty the Queen in Right of Canada (2005).  Authored by
#	Real-Time Systems Inc. (querbach@realtime.bc.ca)
#
#----------------------------------------------------------------------------

# Configure toolchain

source ss555/Config


# Get permission for installation now, rather than waiting for later.

SUDO=sudo	# Comment this out if you don't want to use sudo(8)

if [ "$SUDO" != "" ] ; then
echo 2>&1 << EOF "
The RTEMS and lwIP libraries need to be installed where the RTEMS toolchain
is installed.  The default location is writable only by root, so we use
sudo(8) to obtain temporary write privileges there.  At the following
prompt, give _your_ password (not the root password). If you're refused, see
the sudo(8) man page on how to give yourself sudo privileges. 
"
EOF

$SUDO -k
$SUDO echo
fi


# Build RTEMS

pushd ss555/rtems
rm -rf $(find $PREFIX -name "*${BSP}*"})
./build
$SUDO ./install
popd


# Build lwIP

pushd ss555/lwip
rm -rf $(find $PREFIX -name "*lwip*"})
make clean all
$SUDO make install
popd


# Build lwipocan-test

pushd ss555/lwipocan-test
make clean all
popd


exit 0

