#!/bin/sh

if test -z "$LIBRND_PREFIX"
then
	for P in /usr/local /opt/librnd /usr $HOME/usr
	do
		if test -e "$P/include/librnd4/librnd/core/config.h"
		then
			LIBRND_PREFIX="$P"
			break
		fi
	done
fi


case "$LIBRND_PREFIX" in
	"") 
		echo "

ERROR: Can not find librnd (required for sch-rnd).

If librnd is not installed, please read INSTALL for details.

If librnd is installed at a non-standard prefix, please read
doc/INSTALL.librnd.txt and set LIBRND_PREFIX accordingly
(e.g. export LIBRND_PREFIX=/home/foo/sw/librnd) before running ./configure

" >&2
		exit 1
		;;
	/usr/include) ;;
	/usr/local/include) ;;
	*) LIBRND_EXTRA_INCLUDE="$LIBRND_PREFIX/include/librnd4"
esac

cd scconfig
make "LIBRND_PREFIX=$LIBRND_PREFIX" LIBRND_EXTRA_INCLUDE="-I$LIBRND_EXTRA_INCLUDE" && \
./configure prefix/libs/sul/librnd-3rd=$LIBRND_PREFIX "$@"

