#!/usr/bin/env bash
# Build Path: /app/.heroku/python/

OUT_PREFIX=$1

echo "Building autoconf..."


git clone git://git.sv.gnu.org/autoconf
cd autoconf
./configure --prefix=$OUT_PREFIX
make
make install
cd ..
rm -fr autoconf

# Use new Python path, containing autoconf.
export PATH="/app/.heroku/python/bin/:$PATH"

echo "Building libffi..."

SOURCE_TARBALL='https://github.com/atgreen/libffi/archive/master.tar.gz'

curl -L $SOURCE_TARBALL | tar xz
mv libffi-master libffi

cd libffi
./autogen.sh
./configure --prefix=$OUT_PREFIX
make
make install

# Cleanup
cd ..
rm -fr libffi
