#!/bin/bash

echo -e '\E[0;34m'"\033[1mLast.fm-1.1.3 Configure\033[0m"

echo "Checking for qmake..."

qmake -v &> /dev/null
if [[ $? = 127 ]]; then
	      ################################################################################
	echo
	echo "Sorry, qmake was not found, is Qt4 installed? You will want to install your "
	echo "distribution's packages of qt4 _and_ qt4-devel."
	exit
fi

echo "Checking the installed version of Qt is correct..."

# valid qmake output
# QMake version 2.01a
# Using Qt version 4.2.2 in /opt/qt/4.2.2/lib

qmake -v | grep '^Using Qt version 4.2' --color=never &> /dev/null

if [[ $? > 0 ]]; then
	      ################################################################################
	echo 
	echo "Your version of Qt seems to be too old, we require Qt 4.2 or above."
	echo
	echo "It is possible you have Qt3 and Qt4 both installed. Locate your qt4 installation"
	echo "and ensure it is placed first in the path, eg:"
	echo
	echo "	PATH=/opt/qt4/bin:\$PATH ./configure"
	echo
	echo "However this configure script is very basic, perhaps we got it wrong.."
	echo "Try typing the following, perhaps it will build for you :)"
	echo
	echo "	qmake -config release && make"
	exit
fi

echo "Generating Makefiles..."

qmake -config release -after "CONFIG-=debug"

echo
echo "Good, your configure is finished. Now type 'make'"
echo "If you have problems during the build, consult the README file."
echo
