#!/bin/csh -f

# this is a very low-tech version of configure, not built by autoconf.

# user needs to supply:
# --opsdir : top-level of operations

set opsdir  = ""

set args    = ""

while ("$1" != "") 
 switch ("$1")
   # we need to strip the --opt word and --opt=word versions
   set word = `echo $1 | tr = ' '`
   if ($#word == 1) shift
   breaksw;
  case --opsdir*
   if ("$1" == "--opsdir") then
     shift
     set opsdir = $1
   else
     set opsdir = `echo $1 | tr = ' ' | awk '{print $2}'`
   endif
   breaksw;
  case --help:
   goto usage
  case -*: 
   echo ""
   echo "Unknown option: $1"
   goto usage
  default:
   set args=($args $1);
   breaksw;
 endsw
 shift
end
if ($#args != 1) goto usage

echo
echo "opsdir: $opsdir"
echo

if ("$opsdir" == "") goto usage

# convert Makefile.in to Makefile:
if (-e Makefile) mv -f Makefile Makefile~
cat Makefile.in | sed "s|@OPSDIR@|$opsdir|" > Makefile

exit 0

usage:
if ($#args > 1) then
  echo unrecognized options: $args
endif

cat <<EOF
USAGE: configure [OPTION]

set the installation operations directory with --opsdir

Configuration:
  -h, --help              display this help and exit

EOF
 exit 2;
