#!/usr/bin/env bash
# Run this script to copy over all the files of a (new) CompCert
# version into the vst repository.
#
# Usage:  cd vst/compcert_new; ../util/GRABNEW ~/compcert_new
# assuming it is ~/compcert_new where you have done the svn checkout
# of the compcert distribution (or repository)
#
# WARNING: This will first delete all the .v files of your
# current vst local copy!
#
#
if [ -e "$1" -a ./GRAB ]; then
    rm -f */*.v flocq/*/*.v
    cp $1/LICENSE $1/README.md $1/VERSION $1/Makefile.config .
    cp $1/x86_32/Archi.v x86_32
    mkdir -p x86_64
    cp $1/x86_64/Archi.v x86_64
    cp $1/lib/*.v lib
    cp $1/common/*.v common
    cp $1/cfrontend/{Clight,ClightBigstep,Cop,Csem,Cstrategy,Csyntax,Ctypes}.v cfrontend
    cp $1/flocq/*.v flocq
    cp $1/flocq/Core/*.v flocq/Core
    cp $1/flocq/Prop/*.v flocq/Prop
    cp $1/flocq/Calc/*.v flocq/Calc
    mkdir -p flocq/IEEE754; cp $1/flocq/IEEE754/*.v flocq/IEEE754
    cp $1/exportclight/*.v exportclight
    cp $1/x86/{Asm,Conventions1,Machregs,Op,Stacklayout}.v x86
    cp $1/backend/{Bounds,Conventions,Linear,Locations,LTL}.v backend
else
    echo "Usage:  ./GRABNEW ~/compcert_new"
fi
