| 1 | #!/usr/bin/perl |
|---|
| 2 | # |
|---|
| 3 | # Check whether dependency files in ../BINDEP |
|---|
| 4 | # match arb-binaries in ../bin |
|---|
| 5 | |
|---|
| 6 | # ignore the following binaries (i.e. do not expect dependency files for them): |
|---|
| 7 | my @ignored_binaries = qw/arb_perf_test arb_test arb_readseq/; |
|---|
| 8 | my %ignored_binaries = map { $_ => 1; } @ignored_binaries; |
|---|
| 9 | |
|---|
| 10 | # ignore the following dependency files (i.e. do not expect binaries for them): |
|---|
| 11 | # [ |
|---|
| 12 | # useful if binary is not build under certain build conditions |
|---|
| 13 | # - arb_sub2ascii only build when tests enabled |
|---|
| 14 | # ] |
|---|
| 15 | my @ignored_depfiles = qw/arb_sub2ascii/; |
|---|
| 16 | my %ignored_depfiles = map { $_ => 1; } @ignored_depfiles; |
|---|
| 17 | |
|---|
| 18 | my $ARBHOME = $ENV{ARBHOME}; |
|---|
| 19 | if (not -d $ARBHOME) { |
|---|
| 20 | die "ARBHOME has to be defined and has to mark a directory"; |
|---|
| 21 | } |
|---|
| 22 | chdir($ARBHOME); |
|---|
| 23 | |
|---|
| 24 | sub check_dependencies($$) { |
|---|
| 25 | my ($bindir,$depdir) = @_; |
|---|
| 26 | |
|---|
| 27 | my %used_dep = (); |
|---|
| 28 | my $fail = 0; |
|---|
| 29 | |
|---|
| 30 | opendir(BIN,$bindir) || die "Failed to read directory '$bindir' (Reason: $!)"; |
|---|
| 31 | opendir(DEP,$depdir) || die "Failed to read directory '$depdir' (Reason: $!)"; |
|---|
| 32 | |
|---|
| 33 | foreach (readdir(BIN)) { |
|---|
| 34 | if ($_ ne '.' and $_ ne '..') { |
|---|
| 35 | my $fullbin = $bindir.'/'.$_; |
|---|
| 36 | |
|---|
| 37 | if (-d $fullbin) { ; } # skip subdirs |
|---|
| 38 | elsif (-l $fullbin) { ; } # skip links |
|---|
| 39 | elsif (not -x $fullbin) { ; } # skip non-executables |
|---|
| 40 | elsif (not /^arb_/) { ; } # skip non-arb-tools |
|---|
| 41 | elsif (/\.(sh|pl)$/) { ; } # skip perl- and shell-scripts |
|---|
| 42 | elsif (defined $ignored_binaries{$_}) { ; } # skip ignored_binaries |
|---|
| 43 | else { |
|---|
| 44 | my $dep_file = $depdir.'/needs_libs.'.$_; |
|---|
| 45 | if (-e $dep_file) { # dependencies defined. ok. |
|---|
| 46 | $used_dep{$_} = 1; |
|---|
| 47 | } |
|---|
| 48 | else { |
|---|
| 49 | print "$dep_file:1: missing dependency for '$_'\n"; |
|---|
| 50 | $fail = 1; |
|---|
| 51 | } |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | foreach (readdir(DEP)) { |
|---|
| 57 | if (/^needs_libs\./o) { |
|---|
| 58 | my $name = $'; |
|---|
| 59 | if ($used_dep{$name}) { ; } # ok, have seen binary |
|---|
| 60 | elsif (not defined $ignored_depfiles{$name}) { |
|---|
| 61 | my $fulldep = $depdir.'/'.$_; |
|---|
| 62 | print $fulldep.":1: unused dependency file (no such binary '$name')\n"; |
|---|
| 63 | $fail = 1; |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | closedir(DEP); |
|---|
| 69 | closedir(BIN); |
|---|
| 70 | |
|---|
| 71 | if ($fail==1) { |
|---|
| 72 | die "Error: dependencies not defined correctly\n"; |
|---|
| 73 | } |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | sub main() { |
|---|
| 77 | check_dependencies($ARBHOME.'/bin', $ARBHOME.'/BINDEP'); |
|---|
| 78 | } |
|---|
| 79 | main(); |
|---|