#!/bin/sh
echo Update CP2K manual:
if [[ -z $1 ]]; then
   if [[ -z ${regtest} ]]; then
      arch=Linux-x86-64-${FORT_C_NAME}
   else
      arch=Linux-x86-64-${FORT_C_NAME}-regtest
   fi
else
   arch=$1
   shift
fi
if [[ -z $1 ]]; then
   version=pdbg
else
   version=$1
   shift
fi
cp2kexe=../../exe/${arch}/cp2k.${version}
echo "CP2K executable:  ${cp2kexe}"
if [[ -z $1 ]]; then
   mandir=
else
   mandir=$1
   shift
fi
echo "CP2K manual path: ${mandir}"
rm -rf cp2k_input.xml CP2K_INPUT.html index.html references.html units.html generate_manual_howto.html html_tables.html cp2k.vim CP2K_INPUT/
if [[ -s ${cp2kexe} ]]; then
   ${cp2kexe} --xml
   ./xml2htm
   if [[ -n ${mandir} ]]; then
      scp -r cp2k.vim toggle_folding.js cp2k_input.xsl cp2k_input.xml CP2K_INPUT.html html_tables.html index.html references.html units.html generate_manual_howto.html favicon.png CP2K_INPUT/ ${mandir}
   fi
   echo "CP2K manual update done."
else
   echo "ERROR in $(basename $0): CP2K executable file ${cp2kexe} not found"
fi
