#! /bin/sh case $# in 1) if [ -d $1 ] ; then prefix=$1 else echo "$1: not a directory (specify GraphViz installation directory)" exit 1 fi ;; *) prefix=$(dirname $(dirname $0)) if [ ! -x $prefix/bin/dot ] ; then echo "specify your GraphViz installation directory, please" exit 0 fi ;; esac if [ -x ${prefix}/bin/dot ] ; then # GraphViz is already installed at $prefix dotmsg=$(${prefix}/bin/dot -V 2>&1) if echo $dotmsg | grep "^dyld: .*can't open library: " > /dev/null ; then olddir=$(echo $dotmsg | sed -e "s/^dyld: .*can't open library: \(.*\)\/lib\/graphviz\/.* (No such file.*$/\1/") else echo GraphViz seems OK: $dotmsg exit fi installdir=$prefix else # GraphViz not yet installed installdir=. if [ ! -x $installdir/bin/dot ] ; then echo "GraphViz not present in $prefix, and also not in $(pwd); bailing out" exit fi olddir=/Local/Users/js/pkg/graphviz-1.10 fi echo "adapting GraphViz installation to run from $prefix (was: $olddir)" libdir=$prefix/lib/graphviz for arg in $installdir/bin/* $installdir/lib/graphviz/*.dylib ; do case $arg in *.dylib) id=$(otool -l $arg | grep ' name ' | grep $olddir | awk '{print $2}') if [ -n "${id}" ] ; then id=$(basename $(otool -l $arg | grep ' name ' | grep $olddir | awk '{print $2}')) install_name_tool -id $libdir/$id $arg fi ;; *) libs=`otool -L $arg | grep $olddir | awk '{print $1}'` for lib in $libs; do case $lib in ${olddir}/*) install_name_tool -change $lib $libdir/`basename $lib` $arg ;; *) ;; esac done ;; esac done