1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/bundlelibs.pl Sun Jun 29 03:51:33 2008 +0000
1.5 +# Script for OS X to copy all non-core library dependencies into the bundle, and fixup the lib naming
1.6 +# Run after the executable is already in the bundle.
1.9 + die( "Usage: bundlelibs.pl <target-binary> <target-lib-path>\n" );
1.12 +my $BINARY=shift();
1.13 +my $TARGETDIR=shift();
1.15 +my $NTOOL="install_name_tool";
1.20 +my @worklist = ($BINARY);
1.22 +while( $#worklist >= 0 ) {
1.23 + my $target = shift @worklist;
1.24 + $done{$target} = 2;
1.26 + open FH, "$OTOOL -L $target|" || die "Unable to run otool";
1.31 + $lib =~ s/^\s+([^\s]+)\s.*$/$1/s;
1.32 + if( $lib !~ /^\/System\/Library/ && $lib !~ /^\/usr\/lib/ && $lib !~ /^\@executable_path\// ) {
1.34 + $libname =~ s#^.*/##;
1.35 + $targetpath = "$TARGETDIR/$libname";
1.36 + $libid = "\@executable_path/../Frameworks/$libname";
1.37 + if( !$done{$libname} ) {
1.38 + $done{libname} = 1;
1.39 + push @worklist, $targetpath;
1.40 + system( ("cp", $lib, $targetpath) ) == 0 || die "Failed to copy $lib to $targetpath";
1.41 + system( ($NTOOL, "-id", $libid, $targetpath) ) == 0 || die "Failed to set $lib ID to $libid";
1.42 + print "Copied $lib => $targetpath\n";
1.44 + system( ($NTOOL, "-change", $lib, $libid, $target ) ) == 0 || die "Failed to change $lib ID to $libid";