#!/bin/ksh93 BASEDIR='@CLIENT_BASEDIR@' function findPath { typeset -n P=$1 typeset X=${.sh.file} [[ $X =~ /.*/ ]] || return 1 # unqualified name - should not happen X=${X%/*} # strip off basename X=${X%/*} # strip off last path component (/bin) if [[ ${X: -7:7} == '/camlp5' ]]; then [[ -e $X/camlp5.a ]] && P[LDIR]="$X" && return 0 elif [[ -e $X/lib/ocaml/camlp5/camlp5.a ]]; then P[LDIR]="$X/lib/ocaml/camlp5" && return 0 elif [[ -e ${BASEDIR}/lib/ocaml/camlp5/camlp5.a ]]; then P[LDIR]="${BASEDIR}/lib/ocaml/camlp5" && return 0 fi return 1 } typeset -A T=( [BN]=${.sh.file##*/} ) # don't pollute NS if [[ ${T[BN]} == 'camlp5wrap' ]]; then print 'This is just a simple wrapper around camlp5 tools' \ '\nto make them relocatable.' exit 0 fi findPath T if [[ -z ${T[LDIR]} ]]; then print -u2 'Unable to determine the camlp5 lib directory.' \ "\nShould be ${BASEDIR}/lib/ocaml/camlp5/ but isn't." \ "\nExiting." exit 95 fi [[ -z ${CAMLP5LIB} ]] && export CAMLP5LIB="${T[LDIR]}" [[ -x ${T[LDIR]}/bin/${T[BN]} ]] && exec "${T[LDIR]}/bin/${T[BN]}" "$@" print -u2 "${T[LDIR]}/bin/${T[BN]} does not exist - exiting." exit 95