@files = `find $builddir/breakpad/breakpad-distro/src/client/mac/build/Release/ -type f`;
foreach $file ( @files ) {
@references =`otool -L $file`;
foreach $reference ( @references ) {
if ($reference =~ m|\@executable_path/../Frameworks|) {
print "Changing \@executable_path to \@loader_path for $file\n";
$estring = "\@executable_path/../Frameworks/";
$lstring = "$builddir/breakpad/breakpad-distro/src/client/mac/build/Release/";
my ($oldref, $reftail) = split / /, $reference, 2;
$newref =~ s/$estring/$lstring/g;
print "Old ref: $oldref\n";
print "New ref: $newref\n";
system( "/usr/bin/install_name_tool -change $oldref $newref $file " ) == 0
or die "/usr/bin/install_name_tool failed to update rpath. Fix your configuration or disable Breakpad build";
elsif ($reference =~ m|\@executable_path/../Resources|) {
print "Changing \@executable_path to \@loader_path for $file\n";
$estring = "\@executable_path/../Resources/";
$lstring = "$builddir/breakpad/breakpad-distro/src/client/mac/build/Release/";
my ($oldref, $reftail) = split / /, $reference, 2;
$newref =~ s/$estring/$lstring/g;
print "Old ref: $oldref\n";
print "New ref: $newref\n";
system( "/usr/bin/install_name_tool -change $oldref $newref $file " ) == 0
or die "install_name_tool failed to update rpath. Fix your configuration or disable Breakpad build";
foreach $file ( @files ) {
@references =`otool -L $file`;
foreach $reference ( @references ) {
if ($reference =~ m|\@executable_path/../|) {
print "Changing id for $file\n";
$estring = "\@executable_path/../Frameworks/";
$lstring = "$builddir/breakpad/breakpad-distro/src/client/mac/build/Release/";
my ($oldref, $reftail) = split / /, $reference, 2;
$newref =~ s/$estring/$lstring/g;
print "Old ref: $oldref\n";
print "New ref: $newref\n";
`/usr/bin/install_name_tool -id $newref $file `;