VERSION=2.2.0
ROOT=$PWD
TGZ=expat-$VERSION.tar.bz2
DST=$PWD/Modules/expat

set -e -x

if [ ! -d "$DST" ]; then
    echo "Unable to find $DST"
    exit 1
fi

tar -xf $TGZ
SRC=$PWD/expat-$VERSION/

rm -rf $DST
mkdir $DST
cp $SRC/COPYING $DST/
cp $SRC/lib/*.[ch] $DST/

# FIXME: drop support for VMS
# VMS support removed from Python 3.4
# cp $SRC/vms/expat_config.h $DST/
git checkout $DST/expat_config.h

# FIXME: drop support for the Open Watcom compiler
# Compiler not supported by Python
git checkout $DST/watcomconfig.h

# FIXME: Header file used to build expat DLL on Windows:
# "Namespace all expat exported symbols to avoid dynamic loading symbol
# collisions when embedding Python"
git checkout $DST/pyexpatns.h

echo "Directory $DST synchronized with Expat $VERSION from $TGZ"
