#!/bin/csh
#
# DART software - Copyright UCAR. This open source software is provided
# by UCAR, "as is", without charge, subject to all terms of use at
# http://www.image.ucar.edu/DAReS/DART/DART_download
#
# DART $Id$
#
# usage: mkmf_wakeup_filter [ -mpi | -nompi ]
#
# without any args, builds wakeup_filter without mpi libraries, and it will run
# as a normal executable. if -mpi is given, it will be compiled with the mpi
# libraries and can run with multiple cooperating processes.

if ( $#argv > 0 ) then
  if ("$argv[1]" == "-mpi") then
    setenv usingmpi 1
  else if ("$argv[1]" == "-nompi") then
    setenv usingmpi 0
  else
    echo "Unrecognized argument to mkmf_wakeup_filter: $argv[1]"
    echo "Usage: mkmf_wakeup_filter [ -mpi | -nompi ]"
    echo " default is to generate a Makefile without MPI support."
    exit -1
  endif
else
  setenv usingmpi 0
endif


# make a backup copy of the path_names file, and then use
# sed to make sure it includes either the non-mpi subroutines,
# or the subroutines which really call mpi.
cp -f path_names_wakeup_filter path_names_wakeup_filter.back

if ( $usingmpi ) then

  echo "Making Makefile with MPI"
  touch using_mpi_for_wakeup_filter
  sed -e 's;/null_mpi_util;/mpi_util;' path_names_wakeup_filter.back >! path_names_wakeup_filter
  setenv wrapper_arg -w

else

  echo "Making Makefile without MPI"
  rm -f using_mpi_for_wakeup_filter
  sed -e 's;/mpi_util;/null_mpi_util;' path_names_wakeup_filter.back >! path_names_wakeup_filter
  setenv wrapper_arg ""

endif

# remove temp file and now really call mkmf to generate makefile
rm -f path_names_wakeup_filter.back

../../../build_templates/mkmf -p wakeup_filter -t ../../../build_templates/mkmf.template \
        -a "../../.." ${wrapper_arg} path_names_wakeup_filter

exit $status

# <next few lines under version control, do not edit>
# $URL$
# $Revision$
# $Date$

