#!/bin/sh

## Set your symbol link to the arm rtai patched linux source tree
ln -sf /usr/src/arm-linux-2.4.18-rtai linux-2.4.18

## Set your Arm Cross directory path
ARM_PREFIX='/usr/local/arm-linux'

export PATH=$ARM_PREFIX/bin:$PATH


# Check RTAI package
if [ ! -f rtai-24.1.10.tgz ]; then
 echo "RTAI 24.1.10 seems to be missing"
 exit 1
fi


#
# Build Arm SA1110 patched RTAI-24.1.10
#
gunzip -c rtai-24.1.10.tgz | tar -xvf -
cd rtai-24.1.10
patch -p1 < ../patch-rtai-24.1.10-arm-cep1000
patch -p1 < ../patch-rtai-24.1.10-arm-SAtime
patch -p1 < ../patch-rtai-24.1.10-arm-SAirqs
patch -p1 < ../patch-rtai-24.1.10-arm-SArttimer
make oldconfig
make dep
make
if [ ! -f rtaidir/rtai.o -o ! -f upscheduler/rtai_sched_up.o -o ! -f fifos/rtai_fifos.o -o ! -f shmem/rtai_shm.o -o ! -f posix/src/rtai_pthread.o -o ! -f posix/src/rtai_pqueue.o -o ! -f posix/src/rtai_utils.o ]; then
 echo "***"
 echo "*** Error building rtai-24.1.10"
 echo "***"
 exit 1
fi


# Information
echo ""
echo ""
echo "***"
echo "***  INFO:"
echo "***"
echo "***  StrongARM patched RTAI was successfully built."
echo "***"
echo ""

