#!/bin/sh

. config/options

$SCRIPTS/build toolchain
$SCRIPTS/build zlib

# unset LIBTOOL because freetype uses its own
unset LIBTOOL

cd $PKG_BUILD
./configure --host=$TARGET_NAME \
            --build=$HOST_NAME \
            --prefix=/usr \
            --sysconfdir=/etc \
            --localstatedir=/var \
            --disable-static \
            --enable-shared \
            --with-zlib

make

$MAKEINSTALL

$SED "s:\(['= ]\)/usr:\\1$SYSROOT_PREFIX/usr:g" \
  $SYSROOT_PREFIX/usr/bin/$1-config

mv $SYSROOT_PREFIX/usr/bin/$1-config $ROOT/$TOOLCHAIN/bin

ln -v -sf $SYSROOT_PREFIX/usr/include/freetype2/freetype $SYSROOT_PREFIX/usr/include
