#!/bin/sh

. config/options $1

# Fails to compile with GCC link time optimization, outputing the error:
# "mem-overflow.c:137:1: sorry, unimplemented: gimple bytecode streams do not support the optimization attribute".
  strip_lto

cd $PKG_BUILD
mkdir -p .build-target && cd .build-target

ac_cv_func_posix_getpwuid_r='yes' \
ac_cv_func_posix_getgrgid_r='yes' \
glib_cv_uscore='no' \
glib_cv_stack_grows='no' \
../configure --host=$TARGET_NAME \
             --build=$HOST_NAME \
             --prefix=/usr \
             --sysconfdir=/etc \
             --localstatedir=/var \
             --enable-shared \
             --disable-static \
             --disable-debug \
             --disable-silent-rules \
             --disable-selinux \
             --disable-fam \
             --enable-xattr \
             --enable-regex \
             --with-gnu-ld \
             --with-threads=posix \
             --disable-man \
             --disable-dtrace \
             --disable-systemtap \
             --disable-gcov \
             --enable-Bsymbolic \
             --disable-rebuilds \
             --disable-gtk-doc \

make

$MAKEINSTALL

#mkdir -p $SYSROOT_PREFIX/usr/include/glib-2.0
#  cp glib/glibconfig.h $SYSROOT_PREFIX/usr/include/glib-2.0
mkdir -p $SYSROOT_PREFIX/usr/lib/pkgconfig
  cp g*-2.0.pc $SYSROOT_PREFIX/usr/lib/pkgconfig

mkdir -p $SYSROOT_PREFIX/usr/share/aclocal
  cp ../m4macros/glib-gettext.m4 $SYSROOT_PREFIX/usr/share/aclocal