#!/bin/bash

if [[ $# != 0 ]]; then
    echo "Usage: $0" 1>&2
    exit 1
fi

git clone --recurse-submodules --depth 1 https://github.com/libAtoms/QUIP
pushd QUIP 

./bin/gitversion > GIT_VERSION
pushd src/GAP
./gapversion > GAP_VERSION
popd

echo -n "QUIP git version: "
cat GIT_VERSION
echo -n "GAP git version: "
cat src/GAP/GAP_VERSION
cd src/GAP/soap_turbo
echo -n "soap_turbo git version: "
git describe --always --tags --dirty
cd ../../..
cd src/fox
echo -n "fox git version: "
git describe --always --tags --dirty
cd ../..

# finished setting up source, leave QUIP directory
popd

rm -rf QUIP/.git QUIP/src/GAP/.git QUIP/src/GAP/soap_turbo/.git QUIP/doc QUIP/src/fox/wkml/test QUIP/src/FilePot_drivers/cp2k_driver/benchmark_job QUIP/src/FilePot_drivers/cp2k_driver/silica_benchmark
tar cjf QUIP.tar.bz2 QUIP
rm -rf QUIP