#! /bin/sh # # Find the filename part of the second argument without the directory. # For example, take /opt/mx/lib/libMx.dylib and return libMx.dylib. # FILENAME=`/bin/echo $2 | /usr/bin/rev | cut -d'/' -f1 | rev` # # Find the existing pathname in the binary. # PATHNAME=`/usr/bin/otool -L $1 | /usr/bin/grep ${FILENAME} | /usr/bin/awk '{print $1}'` /bin/echo "$1: Changing library path ${PATHNAME} to $2" # # Replace the existing pathname with the new pathname. # /usr/bin/install_name_tool -change ${PATHNAME} $2 $1 # # Apparently install_name_tool does not necessarily return an error, if the # pathname change was not successfully made. Because of this, we explicitly # check to verify that the name change succeeded. # PATHNAME_NEW=`/usr/bin/otool -L $1 | /usr/bin/grep ${FILENAME} | /usr/bin/awk '{print $1}'` if [ ${PATHNAME_NEW} != $2 ]; then /bin/echo "ERROR: The library path name was NOT changed to $2." exit 1 fi exit 0