#!/bin/csh

set BUILD_PREFIX = /Users/glehmann/Stable/VTK-4.2.0/Build/bin
set INSTALL_PREFIX = /sw/lib/vtk

cd ${INSTALL_PREFIX};

set LIBS = `ls *.dylib *.so`;

foreach lib (${LIBS})
    set baselib = ${INSTALL_PREFIX}/${lib}

    echo "Working on ${baselib}";

    foreach dependentlib (${LIBS})
    set changelib = ${INSTALL_PREFIX}/${dependentlib};
    set buildlib = ${BUILD_PREFIX}/${dependentlib};

    echo "... Changing ${buildlib} to ${changelib}";

    install_name_tool -change ${buildlib} ${changelib} -id ${baselib} ${baselib};

    end
end
