#!/usr/bin/perl -w

$usage = "usage: configure [--help] [--exclude-kdelibs]\n";


sub evaluateArguments()
{
	$help = 0;
	$excludeKde = 0;
	foreach(@ARGV)
	{
		if ($_ eq "--help")
		{
			$help = 1;
		}
		elsif ($_ eq "--exclude-kdelibs")
		{
			$excludeKde = 1;
		}
		else	# not one of the keywords
		{
			print $usage;
			exit (1);
		}
	}
}

evaluateArguments();

if ($help)
{
	print "configure [--exclude-kdelibs]\n";
	print "\t--exclude-kdelibs - use this flag to compile without using the kde library\n";
	print "\t                    some nifty features like debtags update might be implemented\n";
	print "\t                    in a bad way";
	exit(0);
}

my $additionalOptions;
if ($excludeKde)
{
	$additionalOptions .= "\"USE_KDE_LIBS=false\"";
}
else
{
	$additionalOptions .= "\"USE_KDE_LIBS=true\"";
}

system("qmake \"CONFIG+=release\" $additionalOptions packagesearch.pro");
# print "Do you want to download the debtags database which is needed to ";
# print "run Debian Package Seach now? You need to be online to do this ";
# print "and need the debtags tool (apt-get install debtags).\n";
# print "If you say no, you will be able to build the packagesearch utility, ";
# print "but will get an error starting it. You can allways download (or ";
# print "update) it manually using 'debtags update'.\n";

print "You have to download the debtags database which is needed to ";
print "run Debian Package Seach. You ";
print "need the program debtags (apt-get install debtags) for this.\n";
print "Get the database e.g. while packagesearch is compiling using ";
print "'debtags update'.\n";


# $decide = "";
# while ( ($decide ne "y") && ($decide ne "n"))
# {
# 	print "\nDownload it now (y/n) (you will have to become root to do this.)\n";
# 	print "If unsure say y.\n";
# 	$decide = <STDIN>;
# 	chomp($decide);
# 	# read( STDIN,$decide);
# 	$decide = lc($decide);
# }
# print ("OK, getting package database.");
# system("debtags update") if ($decide eq "y");
