#!/bin/bash

# Download zlib into parent directory, and verify
cd ..
curl -Of http://zlib.net/zlib-1.3.tar.gz
last_exit_code=$?
if [ $last_exit_code -ne 0 ]; then
    # There's a newer zlib, and we might want to update this script.  But
    # download the hardcoded version for now to make the static build work...
    curl -O http://zlib.net/fossils/zlib-1.3.tar.gz
fi

EXPECTEDCHECKSUM=04d053e4d4064a0fb8f0cbd127f0bfb5fe4eb554
CHECKSUM=$(shasum zlib-1.3.tar.gz | cut -b-40)
if [ "$EXPECTEDCHECKSUM" != "$CHECKSUM" ]; then
    echo "Zlib checksum verification failure"
    exit 1
fi;

# Unpack and compile zlib
tar -xzvf zlib-1.3.tar.gz
cd zlib-1.3
./configure
make

# Compile
cd ../1.9
make
