cat << welcome
Retro Native Forth, Release 6
Advanced Build System
-----------------------------
This will build the base system with the following
optional components:
welcome

grep -h \#\!\  CONFIG | sed 's/#! /   /' | sed 's/ \.//'
sleep 1
echo -e -----------------------------
echo -e \* Setting up base system
tar xzf base.tar.gz
echo -e \* Copying in optional components
grep -h \#\!\  CONFIG | sed 's/#! /cp optional\//' > grab
. grab

# -------------------------------
echo "* Searching for known ports"
if [ -r linux.tar.gz ]; then
  tar xzf linux.tar.gz
  . rpatch
  rm rpatch
fi
if [ -r vgalinux.tar.gz ]; then
  tar xzf vgalinux.tar.gz
  . rpatch
  rm rpatch
fi
if [ -r sdllinux.tar.gz ]; then
  tar xzf sdllinux.tar.gz
  . rpatch
  rm rpatch
fi
# -----------------------------

echo -e \* Setting up optional components
grep -h \;\#\1\  * | sed 's/;#1//' > rpatch
. rpatch
echo -e \* Cleaning up intermediate files...
mkdir safty
cp CONFIG safty/
cp README safty/
cp INSTALL safty/
cp base.tar.gz safty/
cp abuild safty/
rm *
cp safty/* .
rm -rf safty
echo -e \* Now building Retro 6 Kernel
cd source
. build
cd ..
echo -e \* Completed!
