Permalink
Browse files

added checklibs.pl

  • Loading branch information...
1 parent 462d551 commit a285ced114b8409d4a63fd9c394ef7115a539859 @liyanage committed Jul 4, 2009
Showing with 42 additions and 0 deletions.
  1. +42 −0 checklibs.pl
View
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+#
+# Check the dynamic library dependencies of a
+# Mac OS X binary
+#
+# Written by Marc Liyanage <http://www.entropy.ch>
+#
+#
+
+use strict;
+use warnings;
+
+
+my ($file) = @ARGV;
+die "Usage: $0 file\n" unless $file;
+
+die $! unless (-f $file);
+
+my $libs = {};
+check_libs(file => $file, libs => $libs);
+
+print
+ map {("\n$_:\n", map {"\t$_\n"} sort {lc($a) cmp lc($b)} @{$libs->{$_}})}
+ sort {lc($a) cmp lc($b)}
+ grep {@{$libs->{$_}}}
+ keys(%$libs);
+
+sub check_libs {
+ my (%args) = @_;
+ my $libs = $args{libs};
+ my @file_libs = grep {$_ ne $args{file}} grep {$_} map {/^\s+(\S+)/} qx(otool -L '$args{file}');
+ $libs->{$args{file}} = \@file_libs;
+ foreach my $lib (grep {!$libs->{$_}} @file_libs) {
+ unless (-f $lib) {
+ $libs->{$lib} = ['(missing)'];
+ next;
+ }
+ check_libs(%args, file => $lib);
+ }
+}
+
+

0 comments on commit a285ced

Please sign in to comment.