libtabula

Artifact Content
Login

Artifact 4a50e7fedad32a814b78d841455bc24ec01cc5b2:


#!/bin/sh
BASE="$(dirname "$0")"
BUILD=`pwd`

if [ -z "$1" ]
then
	cat <<USAGE
	usage: $0 [TOOL] <example> [args...]

	   Runs the given example or test program using the library in the
	   build directory instead of using the system library search
	   mechanism.  Accepts an arbitrary number of arguments.

	   TOOL can be 'valgrind', 'gdb', 'lldb', or 'ldd', which causes
	   exrun to run the example or test program under the given tool.

USAGE
	exit 1
fi

TOOL=
PROG=$1
ARGSEP=
if [ "$PROG" = 'valgrind' ]
then
	TOOL='valgrind'
elif [ "$PROG" = 'gdb' ]
then
	TOOL='gdb --args'
elif [ "$PROG" = 'lldb' ]
then
	TOOL='lldb -f'
	ARGSEP="-- "
elif [ "$PROG" = 'ldd' ]
then
	TOOL='ldd'
fi

if [ -n "$TOOL" ]
then
	shift
	PROG=$1
fi

shift

if [ ! -x "$PROG" ]
then
	if [ -x "$BUILD/examples/$PROG" ]
	then
		PROG="$BUILD/examples/$PROG"
	elif [ ! -x "$PROG" -a -x "$BUILD/test/$PROG" ]
	then
		PROG="$BUILD/test/$PROG"
	elif [ `uname -o` = 'Cygwin' ]
	then
		# VC++ build, but using Cygwin's bash as shell to run programs
		cmd.exe /c exrun.bat $PROG $*
	else
		echo "usage: $0 [TOOL] <example> [args...]"
		echo
		echo "   Run $0 without arguments for more detailed usage info."
		echo
		exit 1
	fi
fi

if [ `uname -s` = 'Darwin' ]
then
	DYLD_LIBRARY_PATH=. $TOOL $PROG $ARGSEP"$@"
elif [ `uname -o` = 'Cygwin' ]
then
	# Cygwin build case; see below for bash-as-DOS-shell case
	PATH=. $TOOL $PROG "$@"
elif [ -e /usr/bin/ldd ]
then
	if [ `uname -s` = 'SunOS' ]
	then
		LD_LIBRARY_PATH=.:/usr/mysql/lib/mysql $TOOL $PROG "$@"
	else
		LD_LIBRARY_PATH=. $TOOL $PROG "$@"
	fi
else
	echo "ERROR: I don't grok this system's dynamic linkage system."
fi