#!/bin/sh

#Sanity check for deliverables (i.e. load dependencies are met)

if [ -z "$1" ]; then
	exit 0
fi
if [ ! -f "$1" ]; then
	exit 0
fi

RETVAL=0

for FILE in `cat $1`; do 
	LOADDEP=`ldd $FILE 2> /dev/null | grep -v linux-gate | cut -d ' ' -f 1,3`
	if [ ! -z "$LOADDEP" ]; then
		DEP=
		for ITEM in $LOADDEP; do
			if [ -z "$DEP" ]; then
				DEP=$ITEM
				continue
			fi
			if [ ! -f $ITEM ]; then
				echo "The binary \"$FILE\" depends on \"$DEP\"."
				case "$DEP" in
				*snmp*)
					echo "Hint: Install hp's or your distribution's SNMP daemon."
					echo "See the Agent HOWTO document for more information."
					;;
				*stdc*)
					echo "Hint: Install your distribution's compatibility"
					echo "standard C++ library, often called compat-libstdc++."
					;;
				*pthr*)
					echo "Hint: Install your distribution's pthreading library."
					;;
				*crypt*)
					echo "Hint: Install your distribution's cryptological package."
					;;
				*ssl*)
					echo "Hint: Install your distribution's ssl package."
					;; 
				esac
				RETVAL=1
			fi
			DEP=
		done
	fi
done
exit $RETVAL 
