#!/bin/sh
#

setup_config()
{
	cat config.in > config.h
}

define_macro()
{
	echo \#define	$1	1 >> config.h
}

locate_s()
{
	r=`cat $1 | grep "struct.*$2"`
	if (test -z "$r"); then
		return 1
	fi
}

locate_h()
{
	echo -n checking for header file "$1... "
	HEADERS="/usr/include /usr/local/include"

	for header in $HEADERS
	do
		f="0"
		if (test -f "$header/$1"); then
			f="found"
			echo found \($header/$1\)
			break
		fi
	done
	if (test "$f" != "found"); then
		echo not found \(This may cause trouble in the build\)
		return 1
	fi
}

locate_l()
{
	echo -n checking for library "$1... "
	LIBS="/lib /usr/lib /usr/local/lib"
	for lib in $LIBS
	do
		f="0"
		if (test -f "$lib/lib$1.so"); then
			echo found \($lib/lib$1.so\)
			f="found"
			break
		fi
		if (test -f "$lib/lib$1.a"); then
			echo found \($lib/lib$1.a\)
			f="found"
			break
		fi
	done
	if (test "$f" != "found"); then
		echo not found \(This may cause trouble in the build\)
		return 1
	fi
}

locate_f()
{
	echo -n checking for program "$1... "
	for path in `echo $PATH | sed "s/:/ /g"`
	do
		f="0"
		if (test -f "$path/$1"); then
			echo found \($path/$1\)
			f="found"
			break
		fi
	done
	if (test "$f" != "found"); then
		echo not found EXITING\! $f is required.
		exit 1
	fi
}


syntax highlighted by Code2HTML, v. 0.9.1