#!/bin/sh

function pass {
	echo "[OK  ] $@"
}

function optfail {
	echo "[OPT ] $@"
}

function fail {
	echo "[FAIL] $@"
	exit;
}

function libtest {
	(gcc /tmp/configure-$$.o -l$1 -o /tmp/configure-$$.exe 2>/dev/null) && pass "$1 installed" || fail "no $1 devel system"
}

cat > /tmp/configure-$$.c <<EOB
int main()
{
	return 0;
}
EOB
gcc -c /tmp/configure-$$.c -o /tmp/configure-$$.o

test -e "`which pkg-config`" && pass "pkg-config installed" || fail "no pkg-config"
pkg-config --exists raptor && pass "raptor installed" || fail "no raptor library"
pkg-config --exists raptor && pass "rasqal installed" || fail "no rasqal library"
pkg-config --exists glib-2.0 && pass "glib2 installed" || fail "no glib2 devel system"
test -e "`which pcre-config`" && pass "pcre installed" || fail "no pcre devel system installed"
libtest "readline"
libtest "ncurses"
libtest "termcap"
pkg-config --exists avahi && pass "avahi installed" || optfail "no avahi, will build without cluster support"

rm -f /tmp/configure-$$.*
