#!/bin/bash -ex
# This is a historical record of how we did the merge between our
# fork of glib 1.2.12 and the vendor update to 1.2.13
# It may be of use when we sync up with a future vendor update.
# It should not be expected to work without being modified!
rm -fr zlib
rm -fr zlib.old
rm -fr zlib.new
git checkout -- zlib

mv zlib zlib.old

tar -xzvf ../../Downloads/zlib-1.2.13.tar.gz
mv zlib-1.2.13 zlib
cd zlib

mv doc/algorithm.txt .

rm -f .gitignore
rm -fr amiga
rm -fr doc
rm -fr examples
rm -fr msdos
rm -fr nintendods
rm -fr old
rm -fr os400
rm -fr qnx
rm -fr test
rm -fr watcom
rm -fr win32
rm -f configure
rm -f CMakeLists.txt
rm -f INDEX
rm -f Makefile
rm -f make_vms.com
rm -f treebuild.xml
rm -f zlib2ansi
rm -f zconf.h.cmakein
rm -f zlib.3.pdf
rm -f zlib.map
rm -f zlib.pc.cmakein
rm -f zlib.pc.in
rm -fr contrib/ada
rm -fr contrib/blast
rm -fr contrib/delphi
rm -fr contrib/dotzlib
rm -fr contrib/gcc_gvmat64
rm -fr contrib/infback9
rm -fr contrib/iostream
rm -fr contrib/iostream2
rm -fr contrib/iostream3
rm -fr contrib/pascal
rm -fr contrib/puff
rm -fr contrib/README.contrib
rm -fr contrib/testzlib
rm -fr contrib/untgz
rm -fr contrib/vstudio

# copy our unique files
cp -p ../zlib.old/README.gpsbabel .

cd ..
find zlib | sort > zlib.new.list
find zlib.old | sort > zlib.old.list

# copy patches
cp -p zlib.old/contrib/minizip/ioapi.c.patch zlib/contrib/minizip

# apply patches
cd zlib/contrib/minizip
patch < ioapi.c.patch
cd ../..

cd ..
cp resync_zlib zlib

echo "you must manually edit README.gpsbabel"
echo "Done"
