

function plumed_preliminary_test(){
# check if the README contains the word GROMACS and if gromacs has been already configured
  grep -q GROMACS README 1>/dev/null 2>/dev/null && test -f src/kernel/Makefile
}

function plumed_before_patch(){
  mv src/kernel/Makefile src/kernel/Makefile.plumedbck
  echo "Ad-hoc modification src/kernel/Makefile - saved to src/kernel/Makefile.plumedbck"
  awk 'BEGIN{
     print "include ../../Plumed.inc"
   }{if($1=="mdrun_LDADD" && $2=="="){print $0" $(PLUMED_LOAD) "}else{print }}' src/kernel/Makefile.plumedbck > src/kernel/Makefile
}

function plumed_after_revert(){
  echo "Restoring src/kernel/Makefile from src/kernel/Makefile.plumedbck"
  mv src/kernel/Makefile.plumedbck src/kernel/Makefile
}

function plumed_patch_info(){
cat << EOF

PLUMED can be incorporated into gromacs using the standard patching procedure.
Patching must be done in the gromacs source directory  _after_ gromacs has been configured but  _before_ gromacs is compiled.
Gromacs should be configured with ./configure (not cmake).

To enable PLUMED in a gromacs simulation one should use
mdrun with an extra -plumed flag. The flag can be used to
specify the name of the PLUMED input file, e.g.:

mdrun -plumed plumed.dat

For more information on gromacs you should visit http://www.gromacs.org

EOF
}

