#!/bin/sh

set -e

if [ ! -f make-all.sh ]
then
	echo "This script needs to be run from the top of the source tree" 1>&2
	exit 1
fi

echo 'Building makeline helper'
(cd helpers; make)

scripts/config-one.sh compal-new modem
scripts/config-one.sh compal-old modem
scripts/config-one.sh fcfam irda
scripts/config-one.sh fcfam modem
scripts/config-one.sh pirelli irda
scripts/config-one.sh ti26 irda
scripts/config-one.sh ti26 modem

for i in build-*
do
	echo "Running make in $i"
	(cd $i; make)
done

echo 'Gathering build products in images directory'
mkdir -p images

cp -p build-compal-new-modem/ramimage.srec images/ffsagent-compal-new.srec
cp -p build-compal-old-modem/ramimage.srec images/ffsagent-compal-old.srec
cp -p build-fcfam-irda/ramimage.srec       images/ffsagent-fcfam-irda.srec
cp -p build-fcfam-modem/ramimage.srec      images/ffsagent-fcfam-modem.srec
cp -p build-pirelli-irda/ramimage.srec     images/ffsagent-pirelli-am.srec
cp -p build-ti26-irda/ramimage.srec        images/ffsagent-ti26-irda.srec
cp -p build-ti26-modem/ramimage.srec       images/ffsagent-ti26-modem.srec
