#!/bin/sh

VERSION=3.0
prefix=/usr/local
configured_profiles=
moonlight_sdk_location=
monotouch_sdk_location="`pwd`/../mono/mcs/class/lib/monotouch"
monodroid_sdk_location="`pwd`/../mono/mcs/class/lib/monodroid"
while test x$1 != x; do
        case $1 in
                --prefix=*)
                        prefix=`echo $1 | sed 's/--prefix=//'`
                        ;;
                --moonlight-sdk-location=*)
                        moonlight_sdk_location=`echo $1 | sed 's/--moonlight-sdk-location=//'`
                        configured_profiles="moonlight $configured_profiles"
                        ;;
                --prefix)
                        echo --prefix needs an argument: --prefix=directory >&2
                        ;;
                --with-monotouch=yes)
                        configured_profiles="monotouch $configured_profiles"
                        ;;
                --monotouch-sdk-location=*)
                        configured_profiles="monotouch $configured_profiles"
                        monotouch_sdk_location=`echo $1 | sed 's/--monotouch-sdk-location=//'`
                        ;;
                --with-monodroid=yes)
                        configured_profiles="monodroid $configured_profiles"
                        ;;
                --monodroid-sdk-location=*)
                        configured_profiles="monodroid $configured_profiles"
                        monodroid_sdk_location=`echo $1 | sed 's/--monodroid-sdk-location=//'`
                        ;;
                --with-moonlight=yes)
                        configured_profiles="moonlight $configured_profiles"
                        ;;
                *)
                        echo Unknown argument $1 >&2
        esac
        shift
done

if test "x$moonlight_sdk_location" = "x"; then
	if test "x`echo $configured_profiles | grep moonlight`" != "x"; then
		echo Configure error: --with-moonlight=yes requires --moonlight-sdk-location
		exit 1
	fi
fi

echo "prefix=$prefix" > build/config.make
echo "exec_prefix=\${prefix}" >> build/config.make
echo "mono_libdir=\${exec_prefix}/lib" >> build/config.make
echo "man_dir=\${exec_prefix}/share/man" >> build/config.make
echo "man1_dir=\${man_dir}/man1" >> build/config.make
echo "MCS_FLAGS=-debug+" >> build/config.make
echo "RUNTIME=mono" >> build/config.make
echo "MONO_BASIC_VERSION=$VERSION" >> build/config.make
echo "VERSION :=$VERSION" >> build/config.make
echo "CONFIGURED_PROFILES :=$configured_profiles" >> build/config.make
echo "MOONLIGHT_SDK_LOCATION :=$sdk_location" >> build/config.make
echo "MONOTOUCH_SDK_LOCATION=$monotouch_sdk_location" >> build/config.make
echo "MONODROID_SDK_LOCATION=$monodroid_sdk_location" >> build/config.make

echo "mono-basic $VERSION module configured to use prefix=$prefix"

