#!/bin/sh

for arg in "$@" ; do
    case $arg in
        -echo)
            set -x
            ;;
        -show)
            Show=echo
            ;;
        -help|-u|-usage|-h)
cat <<EOF

    Prepare the slog2sdk distribution for TAU, remove directories that
    are not needed in TAU.

Usage:
      cleandist4tau [options]

-h|-help         - Display this message.
-echo            - Do set -x.
-show            - Print out the commands to be executed, no actual action.
EOF
            exit 1
            ;;
    esac
done

RM="rm"

# The parent directory of where this script is located
saved_wd=`pwd`
cd `dirname $0`/.. && master_dir=`pwd`
cd $saved_wd

isOK2proceed=""
while [ "X$isOK2proceed" = "X" ] ; do
    echo 
    echo -n "Are you ready to prune $master_dir for TAU release ? [yes or no] "
    read answer remaining
    case $answer in
        y* | Y*)
            isOK2proceed=1
            ;;
        n* | N*)
            echo "It appears that you ain't ready.  Exiting..."
            exit 0
            ;;
    esac
done

for file in $master_dir/lib/clog*.jar \
            $master_dir/bin/clog* \
            $master_dir/logfiles/*.clog ; do
    if [ "X$Show" = "X" ] ; then
        echo "Removing file $file ..."
    fi
    $Show $RM -f $file
done

for dir in $master_dir/src/logformat/clog* \
           $master_dir/trace_rlog \
           $master_dir/trace_sample ; do
    if [ "X$Show" = "X" ] ; then
        echo "Removing directory $dir ..."
    fi
    $Show $RM -rf $dir
done

