#! /bin/bash

trap "echo '*** BUILD FAILED! ***' 1>&2" ERR
set -ex -o pipefail
umask 022
export PATH='/bin:/usr/bin:/usr/local/bin'
export CFLAGS=${CFLAGS:--Os}
export CXXFLAGS=${CXXFLAGS:--Os}

rebuild () {
    tar xjf apr-1.4.5.tar.bz2
    cd apr-1.4.5
    ./configure --prefix=/usr/local --with-pic --enable-threads \
	    --disable-shared
    make
    sudo make install
    cd ..
    rm -rf apr-1.4.5
}

while read FN; do
    eval "[ -e $FN ] || rebuild"
done < MANIFEST
