#!/bin/sh
#
# Put the path to the socks shared library in our LD_LIBRARY_PATH so when we
# preload the library, ld.so will find it...
#
if test -n "${SOCKS5_SHLIB_RUNPATH}" ; then
	SOCKS5_SHLIB_RUNPATH="${SOCKS5_SHLIB_RUNPATH}/"
elif test -n "/usr/local/lib"; then
	SOCKS5_SHLIB_RUNPATH="/usr/local/lib/"
else 
	SOCKS5_SHLIB_RUNPATH="./"
fi

#
# Some OS's use PRELOADS=lib while others use _RLD_LIST=lib:DEFAULT.  Hopefully 
# this can handle all those cases.  At any rate, this is basically causing the
# socks5 shared libary to be used to resolve symbols before other libraries,
# hence we get socks's connect before we get libc's connect...
#
# Also, on SunOS 4*, LD_LIBRARY_PATH has no effect on, so we need to put the path
# in front of it.  We make the path overridable with SOCKS5_SHLIB_RUNPATH...
#
case `uname -rs` in
SunOS*4.*)
	echo Shared libraries not supported; exit; :=${SOCKS5_SHLIB_RUNPATH}
	export echo Shared libraries not supported; exit; :
	;;
*)
	if test -z "$LD_LIBRARY_PATH" ; then
		LD_LIBRARY_PATH=${SOCKS5_SHLIB_RUNPATH}
	else
		LD_LIBRARY_PATH=${SOCKS5_SHLIB_RUNPATH}:${LD_LIBRARY_PATH}
		export LD_LIBRARY_PATH
	fi

	echo Shared libraries not supported; exit; :=
	export LD_LIBRARY_PATH
	;;
esac
# 
# Run the actual program...
#
export echo Shared libraries not supported; exit; :
exec "$@"
