#!/bin/csh -f

cont1:

if ( !  -e configure.wrf  ) then
   ./configure
   set dontask
endif

if ( ! $?dontask && $?prompt ) then
  echo "This script assumes you have configured the code already."
  echo "You only need to configure once."
  echo "If you wish to reconfigure, type c at the prompt below"
  echo " "
  echo "Ready to compile? [ync]"
  set resp=$<

  if ( "$resp" == "c" ) then
    ./configure
    goto cont1
  endif

  if ( "$resp" == "n" ) then
    exit 2
  endif
endif

/bin/cp src/Makefile src/makefile.tmp
set arglist=""
foreach a ( $argv )
  if      ( "$a" == "-f" ) then
    echo Warning: fast compile -- not checking for dependencies
    sed '/DEPENDENCIES/,$d' src/Makefile >! src/makefile.tmp
  else if ( "$a" == "-h" ) then
    goto hlp
  else
    set arglist = ( $arglist $a )
  endif
end

if ( $arglist == "" ) then
  goto hlp
else
  make $arglist
endif

exit 0

hlp:

echo 'Usage:'
echo '  compile wrf           compile wrf in run dir'
echo '  test cases (see README_test_cases):'
foreach d ( `/bin/ls test` )
  if ( "$d" != "CVS" ) then
    echo "   compile $d"
  endif
end
echo '  compile -f [...]           fast compile (no dep check)'
echo '  compile -h                 help message'


