#!/bin/sh
curdir=`dirname $0`

OS=`uname -s`
case "$OS" in
    Darwin)
        CPU=`uname -p`
        if [ "$CPU" = "i386" ] ; then
            OS=darwin-x86
        else
            OS=darwin-ppc
        fi
        ;;
    CYGWIN*)
		echo "Do not compile this library with Cygwin, use MSYS instead !!"
		exit 2
		;;
    *_NT-5.1)
        OS=windows
        ;;
esac


PREFIX=
for opt do
  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
  case "$opt" in
  --prefix=*) PREFIX=$optarg
  ;;
  esac
done

if [ -z "$PREFIX" ] ; then
    if [ -z "$TOP" ] ; then
        echo "please define the TOP environment variable, or use the --prefix option"
        exit 3
    fi
    PREFIX=$TOP/prebuilt/$OS/sdl
fi

# list of enabled SDL modules, we absolutely require these
ENABLED=""

# list of disabled SDL modules, since we're generating a static library
DISABLED="shared rpath diskaudio video-directfb video-svga video-fbcon video-aalib cdrom joystick timer"

if [ "$OS" = darwin-x86 -o "$OS" = darwin-ppc ] ; then
  DISABLED="$DISABLED video-x11"
else
  DISABLED="$DISABLED file"
fi

if [ "$OS" = windows ] ; then
    # on Windows, disable C library support, otherwise a library compiled with MSys (mingw32)
    # cannot be properly linked on Cygwin
    DISABLED="$DISABLED video-directx libc"
fi

if [ "$OS" = Linux ] ; then
    DISABLED="$DISABLED nas arts pulseaudio"
    ENABLED="$ENABLED alsa esd video-x11"
fi

ALL_DISABLED=""
for  dd in $DISABLED; do
    ALL_DISABLED="$ALL_DISABLED --disable-$dd"
done

echo "$curdir/configure --prefix=$PREFIX $ALL_DISABLED"
$curdir/configure --prefix=$PREFIX $ALL_DISABLED

