#!/bin/bash

boxmoxDir=$1
boxmoxVersion=$2

# now clean up the superfluous directories and files
rm -rf ${boxmoxDir}/boxmox/compiled_mechs
find . -name "*.DS_Store" -delete
find . -name "*~" -delete
find . -name "*.log" -delete
find . -name "*.aux" -delete
find . -name "*.o" -delete
find . -name "*.dvi" -delete
find . -name "*synctex*" -delete
find . -name "*_CSIRO*" -delete
find . -name "*NO_NO2*" -delete

# replace BOXMOX version strings
sed -i 's/__BOXMOX_VERSION__/'${boxmoxVersion}'/g' ${boxmoxDir}/boxmox/wrapper
sed -i 's/__BOXMOX_VERSION__/'${boxmoxVersion}'/g' ${boxmoxDir}/boxmox/boxmox.f90
sed -i 's/__BOXMOX_VERSION__/'${boxmoxVersion}'/g' ${boxmoxDir}/boxmox/boxmox_adjoint.f90
sed -i 's/__BOXMOX_VERSION__/'${boxmoxVersion}'/g' ${boxmoxDir}/boxmox/bin/new_BOXMOX_experiment
sed -i 's/__BOXMOX_VERSION__/'${boxmoxVersion}'/g' ${boxmoxDir}/boxmox/bin/new_BOXMOX_experiment_from_example
