#!/usr/bin/env bash
#
# add_Id
# ------
#
# This script looks for source code files that do not have a $Id: $ construct in them.
# When such a file is found it will add the particular construct at the end of the file.
#
if [ ${#NWCHEM_TOP} -eq 0 ] ; then
  echo "NWCHEM_TOP not set. Assuming that this script is running in NWChem"
  echo "top directory (i.e. just above the src directory)."
  export NWCHEM_TOP=`pwd`
fi
export ADD_ID_FORTRAN=${NWCHEM_TOP}/contrib/add_Id_Fortran
export ADD_ID_C=${NWCHEM_TOP}/contrib/add_Id_C
export ADD_ID_MAKEFILE=${NWCHEM_TOP}/contrib/add_Id_Makefile
#
echo -n "Adding \$Id: \$ to Fortran header files... "
find . -name "*.fh" ! -exec grep Id: {} \; -exec $ADD_ID_FORTRAN {} \; 2>&1 > /dev/null
echo "Done"
echo -n "Adding \$Id: \$ to Fortran source files... "
find . -name "*.f" ! -exec grep Id: {} \; -exec $ADD_ID_FORTRAN {} \; 2>&1 > /dev/null
find . -name "*.F" ! -exec grep Id: {} \; -exec $ADD_ID_FORTRAN {} \; 2>&1 > /dev/null
echo "Done"
echo -n "Adding \$Id: \$ to C header files...       "
find . -name "make*.h" ! -exec grep Id: {} \; -exec $ADD_ID_MAKEFILE {} \; 2>&1 > /dev/null
find . -name "*.h" ! -exec grep Id: {} \; -exec $ADD_ID_C {} \; 2>&1 > /dev/null
echo "Done"
echo -n "Adding \$Id: \$ to C source files...       "
find . -name "*.c" ! -exec grep Id: {} \; -exec $ADD_ID_C {} \; 2>&1 > /dev/null
echo "Done"
