#!/bin/sh

. config/options

$SCRIPTS/build toolchain
$SCRIPTS/build alsa-lib
$SCRIPTS/build libX11
$SCRIPTS/build libXrandr
$SCRIPTS/build Mesa

cd $PKG_BUILD
./configure --host=$TARGET_NAME \
            --build=$HOST_NAME \
            --prefix=/usr \
            --sysconfdir=/etc \
            --localstatedir=/var \
            --enable-shared \
            --disable-static \
            --disable-rpath \
            --enable-libc \
            --enable-audio \
            --enable-video \
            --enable-events \
            --enable-joystick \
            --enable-cdrom \
            --enable-threads \
            --enable-timers \
            --enable-file \
            --enable-loadso \
            --enable-cpuinfo \
            --enable-assembly \
            --disable-oss \
            --enable-alsa \
            --disable-alsatest \
            --enable-alsa-shared \
            --with-alsa-prefix=$SYSROOT_PREFIX/usr/lib \
            --with-alsa-inc-prefix=$SYSROOT_PREFIX/usr/include \
            --disable-esd \
            --disable-esdtest \
            --disable-esd-shared \
            --disable-pulseaudio \
            --disable-pulseaudio-shared \
            --disable-arts \
            --disable-arts-shared \
            --disable-nas \
            --disable-diskaudio \
            --disable-dummyaudio \
            --disable-mintaudio \
            --enable-nasm \
            --disable-altivec \
            --disable-ipod \
            --disable-video-nanox \
            --disable-nanox-debug \
            --disable-nanox-share-memory \
            --disable-nanox-direct-fb \
            --enable-x11-shared \
            --disable-dga \
            --disable-video-dga \
            --disable-video-x11-dgamouse \
            --disable-video-x11-xinerama \
            --disable-video-x11-xme \
            --enable-video-x11-xrandr \
            --disable-video-photon \
            --disable-video-carbon \
            --disable-video-cocoa \
            --disable-video-fbcon \
            --disable-video-directfb \
            --disable-video-ps2gs \
            --disable-video-ggi \
            --disable-video-svga \
            --disable-video-vgl \
            --disable-video-wscons \
            --disable-video-aalib \
            --disable-video-qtopia \
            --disable-video-picogui \
            --disable-video-dummy \
            --enable-video-opengl \
            --disable-osmesa-shared \
            --enable-input-events \
            --disable-input-tslib \
            --disable-pth \
            --enable-pthreads \
            --enable-pthread-sem \
            --disable-stdio-redirect \
            --disable-directx \
            --enable-sdl-dlopen \
            --disable-atari-ldg \
            --disable-clock_gettime \
            --enable-video-x11 \
            --enable-video-x11-vm \
            --enable-video-x11-xv \
            --with-x

make

$MAKEINSTALL

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

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

mkdir -p $ROOT/$TOOLCHAIN/include
  ln -snf `echo $ROOT/$PKG_BUILD/include` $ROOT/$TOOLCHAIN/include/SDL
