#! /bin/ksh
withdefaultrpath=yes
withenvrpath=no
runpath=
libpathargs=
args=
while [[ $# -gt 0 ]]
do
	arg=$1
	shift
	case "X$arg" in
	X+nodefaultrpath) withdefaultrpath=no ;;
	X+defaultrpath) withdefaultrpath=yes ;;
	X+s)
		[[ ${runpath:+set} = set ]] && withenvrpath=second || withenvrpath=first
		continue
		;;
	X+b)
		if [[ $# -gt 0 ]]; then
			runpath="${runpath}${runpath:+:}${1}"
			shift
			continue
		fi
		;;
	X+b*)
		runpath="${runpath}${runpath:+:}${arg#+b}"
		continue
		;;
	X-L)
		if [[ $# -gt 0 ]]; then
			libpathargs="${libpathargs} '-L${1}'"
			shift
			continue
		fi
		;;
	X-L*)
		libpathargs="${libpathargs} '${arg}'"
		continue
		;;
	esac
	args="${args} '${arg}'"
done

libpathargs="${libpathargs} '-L/mnt/toolsjunk/snapshot/toolsbox-3.5.4pre.20071011/hppa2.0w-hp-hpux11.11/lib'"

# must explicitly add my runpath ?
[[ ${runpath:+set} = set || ${withdefaultrpath} = no ]] &&
runpath="${runpath}${runpath:+:}/mnt/toolsjunk/snapshot/toolsbox-3.5.4pre.20071011/hppa2.0w-hp-hpux11.11/lib"

[[ ${withenvrpath} = first  ]] && args="${args} +s"
[[ ${runpath:+set} = set    ]] && args="${args} +b '${runpath}'"
[[ ${withenvrpath} = second ]] && args="${args} +s"

eval exec '/usr/ccs/bin/ld' ${libpathargs} ${args}
