#!/bin/sh

PREFIX="/usr/local/cross-tools"
TARGET=i586-mingw32msvc
PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PATH"
export PATH
for opt in $*; do
	if expr $opt : "--prefix=.*"; then
		has_prefix=1
		break
	fi
done

if test -z $has_prefix; then
	cross_configure_prefix="--prefix=$PREFIX/$TARGET"
fi

if test $use_directx8; then
	cross_configure_extra_includes="--with-extra-includes=$PREFIX/$TARGET/include/dx8"
fi

if test -f "$PREFIX/$TARGET/bin/$TARGET-sdl-config"; then
	SDL_CONFIG="$PREFIX/$TARGET/bin/$TARGET-sdl-config"
	export SDL_CONFIG
fi

if test -d "$PREFIX/$TARGET/lib/pkgconfig"; then
	PKG_CONFIG_PATH="$PREFIX/$TARGET/lib/pkgconfig"
	export PKG_CONFIG_PATH
fi

cache=cross-config.cache
if test -e configure; then
	configure=configure
else
	configure=../configure
fi

sh $configure --cache-file="$cache" \
	--target=$TARGET --host=$TARGET --build=i586-linux \
	$cross_configure_prefix $cross_configure_extra_includes\
	$*
status=$?
rm -f "$cache"
exit $status

