#! /bin/sh

OS=$OSTYPE

if test "x$OS" = x; then 
  echo "please set the environment variable OSTYPE "
  echo "to a value appropriate for your system."
  echo "to do so type: setenv OSTYPE `uname`   for the csh, tcsh"
  echo "               export OSTYPE=`uname`   for other shells"
  exit 1
fi

ALL_DIR=`pwd`
SUBSTFILE=setup/$OS/substit

while test \! -f $SUBSTFILE; do
    cd ..
    if test `pwd` = /; then
	echo "Can't find top directory!"
	exit 1
    fi
done

# create makefiles
for each in $ALL_DIR; do
    DIR=$each/$OS
    # create Makefile in directory
    if test -r $each/Makefile.in ; then
        # create directory
        if test ! -d $DIR; then
            echo "Creating Directory: $DIR..."
	    mkdir $DIR
        fi
	echo "Creating: $DIR/Makefile..."
	cat $each/Makefile.in | sed -f $SUBSTFILE > $DIR/Makefile
    fi
done
