function print_message
{
	echo "   " $@
}

function print_error
{
	echo "!! " $@
}

function print_warning
{
	echo "** " $@
}

function print_separator
{
	echo "------------------------------------------------------------"
}

######################################################################
function check_command_line
{
	local arg
	for arg in $@; do
		case $arg in
			--enable-sdl )
			  	ENABLE_SDL="yes"
				;;
			--disable-sdl )
				ENABLE_SDL="no"
				;;
			--enable-smpeg )
				ENABLE_SMPEG="yes"
				;;
			--disable-smpeg )
				ENABLE_SMPEG="no"
				;;
			--enable-vorbis )
				ENABLE_VORBIS="yes"
				;;
			--disable-vorbis )
				ENABLE_VORBIS="no"
				;;
			--enable-setup )
				ENABLE_SETUP="yes"
				;;
			--disable-setup )
				ENABLE_SETUP="no"
				;;
			*)
				print_command_line_options
				exit 1
				;;
		esac
	done
}

function print_command_line_options
{
	echo ""
	echo "USEAGE:"
	echo "--enable-<option>     enable option"
	echo "--disable-<option>    disable option"
	echo ""
	echo "OPTIONS:"
	echo "sdl     enable use of SDL libarary    (default: $ENABLE_SDL)"
	echo "smpeg   enable SMPEG for MP3 playback (default: $ENABLE_SMPEG)"
	echo "vorbis  enable Ogg/Vorbis support     (default: $ENABLE_VORBIS)"
	echo "setup   build chromium-setup utility  (default: $ENABLE_SETUP)"
	echo ""
	echo "EXAMPLE:"
	echo "./configure --enable-smpeg --disable-vorbis"
	echo ""
}

######################################################################
function check_for_sdl_config
{
	local directory
	
	for directory in $std_bin_dirs; do
		if [ -f $directory/sdl-config ]; then
			SDL_CONFIG=$directory/sdl-config
			return 0
		fi
	done
	return 1
}

function check_sdl_version
{
	SDL_THIS_VERSION=`$SDL_CONFIG --version`
	
	i_major_version=`echo $SDL_THIS_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
	i_minor_version=`echo $SDL_THIS_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
	i_micro_version=`echo $SDL_THIS_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
	  
	r_major_version=`echo $SDL_MIN_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
	r_minor_version=`echo $SDL_MIN_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
	r_micro_version=`echo $SDL_MIN_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`

	if [ $i_major_version -gt $r_major_version ]; then
		return 0; else
	if [ $i_major_version -ge $r_major_version ]; then
		if [ $i_minor_version -gt $r_minor_version ]; then
			return 0
		fi
	fi
	fi
	
	if [ $i_major_version -ge $r_major_version ]; then
		if [ $i_minor_version -ge $r_minor_version ]; then
			if [ $i_micro_version -ge $r_micro_version ]; then
				return 0
			fi
		fi
	fi
		
	return 1
}

function print_sdl_error
{
	print_error "Chromium B.S.U. requires that SDL version $SDL_MIN_VERSION or greater"
	print_error "be installed. You can aquire the latest version of SDL at"
	print_error "http://www.libsdl.org"
	print_error ""
}

######################################################################
function check_for_smpeg_config
{
	local directory
	
	for directory in $std_bin_dirs; do
		if [ -f $directory/smpeg-config ]; then
			SMPEG_CONFIG=$directory/smpeg-config
			return 0
		fi
	done
	return 1
}

function check_smpeg_version
{
	SMPEG_THIS_VERSION=`$SMPEG_CONFIG --version`
	
	i_major_version=`echo $SMPEG_THIS_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
	i_minor_version=`echo $SMPEG_THIS_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
	i_micro_version=`echo $SMPEG_THIS_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
	  
	r_major_version=`echo $SMPEG_MIN_VERSION  | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
	r_minor_version=`echo $SMPEG_MIN_VERSION  | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
	r_micro_version=`echo $SMPEG_MIN_VERSION  | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`

	if [ $i_major_version -gt $r_major_version ]; then
		return 0; else
	if [ $i_major_version -ge $r_major_version ]; then
		if [ $i_minor_version -gt $r_minor_version ]; then
			return 0
		fi
	fi
	fi
	
	if [ $i_major_version -ge $r_major_version ]; then
		if [ $i_minor_version -ge $r_minor_version ]; then
			if [ $i_micro_version -ge $r_micro_version ]; then
				return 0
			fi
		fi
	fi	
	return 1
}
	
function print_smpeg_warning
{
	print_warning "smpeg is *NOT* a requirement for Chromium B.S.U."
	print_warning "However, if version $SMPEG_MIN_VERSION or greater is installed, "
	print_warning "Chomium B.S.U. will be able to play MP3 files as background "
	print_warning "music. http://www.lokigames.com/development/smpeg.php3"
	print_warning ""
}

######################################################################
function check_for_vorbis_libs
{
	local directory
	local LIBVORBISDIR
	local LIBVORBIS
	local LIBVORBISFILE
	
	for directory in $std_lib_dirs; do
		if [ -f $directory/libvorbis.so ]; then
			LIBVORBISDIR=$directory
			LIBVORBIS="-lvorbis"
		fi
	done
	
	if [ -z $LIBVORBISDIR ]; then
		echo "" > /dev/null
		return 1
	else
		if [ -f $LIBVORBISDIR/vorbisfile.a ]; then
			LIBVORBISFILE="$LIBVORBISDIR/vorbisfile.a"
		else 
			if [ -f $LIBVORBISDIR/libvorbisfile.a ]; then
				LIBVORBISFILE="-lvorbisfile"
			else
				LIBVORBISDIR=""
			fi
		fi
	fi
	
	if [ -z $LIBVORBISDIR ]; then
		echo "" > /dev/null
		return 1
	else
		VORBIS_LIBS="-L$LIBVORBISDIR $LIBVORBIS $LIBVORBISFILE"
		return 0
	fi
}

function print_vorbis_warning
{
	print_warning "Ogg/Vorbis is *NOT* a requirement for Chromium B.S.U."
	print_warning "However, if the Ogg/Vorbis libs are correctly installed, "
	print_warning "Chomium B.S.U. will be able to play OGG files as background "
	print_warning "music. http://www.xiph.org/ogg/vorbis/index.html"
	print_warning ""
}

function print_vorbis_notes
{
	print_warning ""
	print_warning "Detection of Ogg/Vorbis has been enabled."
	print_warning "BE AWARE THAT OGG/VORBIS MAY NOT BE AUTOMATICALLY DETECTED BY OPENAL! "
	print_warning "If the build process succeeds, Ogg/Vorbis support may still not "
	print_warning "be available. If this is the case, you will need to go into "
	print_warning "support/openal/linux and edit the config.h file to enable it. "
	print_warning "After that, rebuild OpenAL, copy openal/linux/src/libopenal.a to "
	print_warning "openal/lib, then rebuild chromium and chromium-setup. "
	print_warning ""
	print_warning "Please do not send me questions about how to enable Ogg/Vorbis, "
	print_warning "you will have to figure it out yourself. Sorry. "
	print_warning ""

}



