#!/bin/bash

if [ -z "$1" ]; then
	exit 0
fi
libtool="$1"; shift
input="$1"; shift
output="$1"; shift

case "$input" in #((
	*.la)
		. "$input"
		if test -z "$dlname"; then
			exit 0
		fi
		real=$(dirname "$input")"/.libs/$dlname"
		if ldd -r "$real" | c++filt | grep "undefined symbol"; then
			exit 1
		fi
		;;
	*)
		if "${libtool}" --mode=execute ldd -r "$input" | c++filt | \
		   grep "undefined symbol"; then
			exit 1
		fi
		;;
esac
if test -n "$output"; then
	>"$output"
fi
exit 0
