#!/bin/bash

action=$1
if [ "$action" == "distclean" ] ; then
    echo rm -rf tmp
    rm -rf tmp
    action=clean
fi

if [ "$action" == "clean" ] ; then
    for dir in rss comp exec pp dep un icmake icmbuild
    do
        cd $dir
    echo -n "cd $dir; "
        build clean
        cd ..
    done
    exit 0
fi

if [ ! -e tmp/INSTALL.im ] ; then

    if [ "$action" == "" ] ; then
        echo "
First run ./icm_prepare, specifying a base directory for icmake (e.g. /), 
or restart $0, and specify a base directory as its first command-line argument
"
        exit 1;
    fi

    ./icm_prepare $action
fi

for dir in rss comp exec pp dep un icmake icmbuild
do
    cd $dir
    echo $dir
    build || exit 1
    cd ..
done




