#! /bin/bash

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

rebuild () {
    tar xjf freetype-2.1.7.tar.bz2
    cd freetype-2.1.7
    ./configure --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var \
	    --disable-static --without-old-mac-fonts
    make
    sudo make install
    cd ..
    rm -rf freetype-2.1.7
}

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